Init(RS485,...)

Init(RS485,...)

Description

Initializes RS485 interface for data transfer and monitoring.

Syntax

Init(RS485, speed, word_length, stop_bits, parity);

Parameters

Variable

Input

Variable

Input

speed

This is serial port data transfer speed in bit/s. Speed (baud rate) can be one of the following: 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 56000, 57600, 115200, 128000 or 256000

word_length

This is data size in bits. For example: WORDLENGTH_7 - 7 bit long data packet. Can be:

WORDLENGTH_7WORDLENGTH_8 or WORDLENGTH_9

stop_bits

This number of bits that shows end of a single packet. Can be:

STOPBITS_1 or STOPBITS_2

parity

Parity is error detection bit, which show that data is made out of even or odd number of ones.

Parity is either - PARITY_NONE, PARITY_EVEN, PARITY_ODD

Returns

Return value

Return explanation

SCRIPT_OPERATION_SUCCESS

Success

SCRIPT_OPERATION_FAILED

Failed

SCRIPT_NO_ACCESS

Peripheral already initialized.

SCRIPT_PARAM_INVALID

Passed invalid init parameters.

Function call example

RS485 initialization example
new string[50]; main(){ Init(RS485, 9600, WORDLENGTH_8, STOPBITS_1, PARITY_NONE); while(1){ write_buf(RS485, 12 ,"Hello world "); //write some data. See write_buf documentation for more detail read_buf(RS485, 6, string); //read some data. See read_buf documentation for more detail Delay(100); } }

Notes and Warnings

WARNING: Do not initialize RS485 on separate threads. In order to use RS485 on separate threads first do DeInit on thread where it was previously initialized.

Used in Examples

Call by reference example

EEPROM example