TCP/IP - RS232 Bricklet – Tinkerforge

- Getting Started
- Hardware
- Software
- Starter Kits
- Embedded Boards
- Specifications

# TCP/IP - RS232 Bricklet

Note

This Bricklet is currently in the prototype stage and the software/hardware as well as the documentation is in an incomplete state.

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.

## API

A general description of the TCP/IP protocol structure can be found here.

### Basic Functions

`BrickletRS232.``write`

  Function ID: | 1

  Request:

  - message -- char[60]
  - length -- uint8

  Response:

  - written -- uint8

  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 `SetConfigurations()` for configuration possibilities regarding baudrate, parity and so on.

`BrickletRS232.``read`

  Function ID: | 2
  Request: | empty payload

  Response:

  - message -- char[60]
  - length -- uint8

  Returns the currently buffered message. The maximum length of message is 60. If the length is given as 0, there was no new data available.

  Instead of polling with this function, you can also use callbacks. See `enable_callback` and `CALLBACK_READ_CALLBACK`.

`BrickletRS232.``set_configuration`

  Function ID: | 6

  Request:

  - baudrate -- uint8
  - parity -- uint8
  - stopbits -- uint8
  - wordlength -- uint8
  - hardware_flowcontrol -- uint8
  - software_flowcontrol -- uint8

  Response: | no response

  Sets the configuration for the RS232 communication. Available options:

  - Baudrate between 300 and 230400 baud.
  - Parity of none, odd, even or forced parity.
  - Stopbits can be 1 or 2.
  - Word length of 5 to 8.
  - Hard-/Software flow control can each be on or off.

  The default is: 115200 baud, parity none, 1 stop bit, word length 8, hard-/software flow control off.

`BrickletRS232.``get_configuration`

  Function ID: | 7
  Request: | empty payload

  Response:

  - baudrate -- uint8
  - parity -- uint8
  - stopbits -- uint8
  - wordlength -- uint8
  - hardware_flowcontrol -- uint8
  - software_flowcontrol -- uint8

  Returns the configuration as set by `set_configuration`.

### Advanced Functions

`BrickletRS232.``get_identity`

  Function ID: | 255
  Request: | empty payload

  Response:

  - uid -- char[8]
  - connected_uid -- char[8]
  - position -- char
  - hardware_version -- uint8[3]
  - firmware_version -- uint8[3]
  - device_identifier -- uint16

  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' or 'd'.

  The device identifier numbers can be found here.

### Callback Configuration Functions

`BrickletRS232.``enable_callback`

  Function ID: | 3
  Request: | empty payload
  Response: | no response

  Enables the `CALLBACK_READ_CALLBACK`.

  By default the callback is disabled.

`BrickletRS232.``disable_callback`

  Function ID: | 4
  Request: | empty payload
  Response: | no response

  Disables the `CALLBACK_READ_CALLBACK`.

  By default the callback is disabled.

`BrickletRS232.``is_callback_enabled`

  Function ID: | 5
  Request: | empty payload

  Response:

  - enable -- bool

  Returns true if the `CALLBACK_READ_CALLBACK` is enabled, false otherwise.

### Callbacks

`BrickletRS232.``CALLBACK_READ_CALLBACK`

  Function ID: | 8

  Response:

  - message -- char[60]
  - length -- uint8

  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_callback`.

The content of this page is licensed under Creative Commons Attribution 3.0 Unported License.