Introduction
Warnings for proper use of SERIAL communication from R3 applications:
•Use the ser_con instruction or the dev_con command to set the serial channel parameters (baud rate, etc...)
•Use the ser_mod instruction to set the working mode of the serial channel
Mode 0 strings terminated
This mode requires that the channel is configured in ascii mode (PSER ASCII command).
In this mode, incoming strings on the receive buffer can follow two paths:
1) If the string is prefixed by the characters :DtR: and terminates with the terminator character set (default "LF" (10 dec. - 0AH) or the one set as active terminator) it is taken over by the RTE manager and the prefixed response :aSw: is sent and terminated with the terminator character set (default "LF" (10 dec. - 0AH) or the one set as active terminator).
RTE is able to honor all device command type commands.
NOTE: The use of dle_ascii communication is recommended.
2) If the string is not prefixed, then by program it is possible:
•Know if there is a terminated string on the indicated device, via the ser_ready() function.
•Download the terminated string via the ser_in() function
•Send a terminated string via the ser_out() function
Mode 1 single character
In this mode from program you can:
•Know the number of characters in the receive buffer of the specified device via the ser_bin_ready() function
•Download the desired number of characters via the ser_bin_in() function
•Send the desired number of characters via the function ser_bin_out()
Mode 2 single character with handshake disabled
In this mode from program you can:
•Know the number of characters in the receive buffer of the specified device via the ser_bin_ready() function
•Download the desired number of characters via the ser_bin_in() function
•Send the desired number of characters via the function ser_bin_out()
•Read the status word via the function ser_r_sts()
•Set the two signals DTR and RTS via the instruction ser_w_sts()
Mode 12 RS 485
Using this physical communication standard, multipoint connections can be made using only 3 wires (Line+, Line- and common). The use of only three wires implies that the communication is Half Duplex, without interlocking on the data flow.
This protocol on Robox controllers can be used on RS422/485 type ports. It is necessary to join the pin of TX+ to that of RX+ (thus obtaining Line+) and the pin of TX- to that of Rx- (thus obtaining Line-).
The RS485 standard requires a communication protocol involving a station identifier. Since there is no single standard on the protocol, implementation is left to the user to meet all his needs.
The RTE manager is able to recognize if transmitted messages have not collided with those transmitted by other stations, but the handling of the error and possible re-sending of the message is up to the user.
Operation
This standard is activated using the ser_mod instruction. From this point on, the line is kept floating. When the user writes to the serial (ser_bin_out()) occurs:
•Enabling the line
•Transmission of the message
Since the transmit line is connected to the receive line, it is verified that what is being transmitted is being received correctly. A negative result signals a collision and the transmission is aborted. When the transmission of all characters is finished, the transmitter empty is waited for to release the line.
The presence of a disconnected line (no TX reclose on RX) is diagnosed by the use of a timeout on data reception. What to do if the timeout is triggered, the transmission is considered failed and the line is released.
When the line is released, RTE puts itself on hold for receiving characters. The line is released after the transmission of the last character.
In this program mode it is possible to:
•Know the number of characters in the receive buffer of the specified device via the ser_bin_ready() function.
•Download the desired number of characters via the function ser_bin_in()
•Send the desired number of characters via the function ser_bin_out()
•Have information about the transmission via the function ser_485_tx_sts()
•Use the support function, valid in all modes, ser_buff_free() to know the number of free bytes on the buffer in TX
•Use the support function, valid in all modes, ser_buff_queue() to know the number of occupied bytes on the buffer in TX
NOTE: You can get transmission information by acting on the predefined variable sys_flag bit 12.