This is the description of the TCP/IP protocol for the RS232 Bricklet. General information and technical specifications for the RS232 Bricklet are summarized in its hardware description.
A general description of the TCP/IP protocol structure can be found here.
BrickletRS232.
write
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Writes a string of up to 60 characters to the RS232 interface. The string can be binary data, ASCII or similar is not necessary.
The length of the string has to be given as an additional parameter.
The return value is the number of bytes that could be written.
See set_configuration
for configuration possibilities
regarding baudrate, parity and so on.
BrickletRS232.
read
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the currently buffered message. The maximum length of message is 60. If the returned length is 0, no new data was available.
Instead of polling with this function, you can also use
callbacks. See enable_read_callback
and CALLBACK_READ
callback.
BrickletRS232.
set_configuration
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Sets the configuration for the RS232 communication.
Hard-/Software flow control can either be on or off but not both simultaneously on.
The following meanings are defined for the elements of this function:
For baudrate:
For parity:
For stopbits:
For wordlength:
For hardware_flowcontrol:
For software_flowcontrol:
BrickletRS232.
get_configuration
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the configuration as set by set_configuration
.
The following meanings are defined for the elements of this function:
For baudrate:
For parity:
For stopbits:
For wordlength:
For hardware_flowcontrol:
For software_flowcontrol:
BrickletRS232.
set_break_condition
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Sets a break condition (the TX output is forced to a logic 0 state). The parameter sets the hold-time of the break condition.
New in version 2.0.2 (Plugin).
BrickletRS232.
read_frame
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns up to one frame of bytes from the read buffer.
The frame size is configured with set_frame_readable_callback_configuration
.
If the returned length is 0, no new data was available.
New in version 2.0.4 (Plugin).
BrickletRS232.
get_identity
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier.
The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port). A Bricklet connected to an Isolator Bricklet is always at position 'z'.
The device identifier numbers can be found here.
BrickletRS232.
enable_read_callback
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Enables the CALLBACK_READ
callback. This will disable the CALLBACK_FRAME_READABLE
callback.
By default the callback is disabled.
BrickletRS232.
disable_read_callback
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Disables the CALLBACK_READ
callback.
By default the callback is disabled.
BrickletRS232.
is_read_callback_enabled
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns true if the CALLBACK_READ
callback is enabled,
false otherwise.
BrickletRS232.
set_frame_readable_callback_configuration
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Configures the CALLBACK_FRAME_READABLE
callback. The frame size is the number of bytes, that have to be readable to trigger the callback.
A frame size of 0 disables the callback. A frame size greater than 0 enables the callback and disables the CALLBACK_READ
callback.
By default the callback is disabled.
New in version 2.0.4 (Plugin).
BrickletRS232.
get_frame_readable_callback_configuration
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the callback configuration as set by set_frame_readable_callback_configuration
.
New in version 2.0.4 (Plugin).
BrickletRS232.
CALLBACK_READ
¶Function ID: |
|
---|---|
Response: |
|
This callback is called if new data is available. The message has a maximum size of 60 characters. The actual length of the message is given in addition.
To enable this callback, use enable_read_callback
.
BrickletRS232.
CALLBACK_ERROR
¶Function ID: |
|
---|---|
Response: |
|
This callback is called if an error occurs. Possible errors are overrun, parity or framing error.
The following meanings are defined for the elements of this function:
For error:
New in version 2.0.1 (Plugin).
BrickletRS232.
CALLBACK_FRAME_READABLE
¶Function ID: |
|
---|---|
Response: |
|
This callback is called if at least one frame of data is readable. The frame size is configured with set_frame_readable_callback_configuration
.
The frame count parameter is the number of frames that can be read.
This callback is triggered only once until read
or read_frame
is called. This means, that if you have configured a frame size of X bytes,
you can read exactly X bytes using the read_frame
function, every time the callback triggers without checking the frame count response value.
New in version 2.0.4 (Plugin).