openHAB - RS232 Bricklet

Bemerkung

Zur Zeit ist nur die englische openHAB-Dokumentation verfügbar.

This is the description of the openHAB API bindings for the RS232 Bricklet. General information and technical specifications for the RS232 Bricklet are summarized in its hardware description.

An installation guide for the openHAB API bindings is part of their general description.

Thing

UID:
  • tinkerforge:brickletrs232:[UID]
Required firmware version:
  • 2.0.4
Firmware update supported:
  • yes
Channels:
Actions:
Parameters:
  • Baud Rate – Type: Choice, Default: 115200
  • The baud rate to send/receive with.
  • Options: 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, 115200, 230400

  • Parity – Type: Choice, Default: None
  • The parity mode to use. See `here `__.
  • Options: None, Odd, Even, Forced Parity 1, Forced Parity 0

  • Stop Bits – Type: Choice, Default: 1
  • The number of stop bits to send/expect.
  • Options: 1, 2

  • Word Length – Type: Choice, Default: 8
  • The length of a serial word. Typically one byte.
  • Options: 5, 6, 7, 8

  • Flow Control – Type: Choice, Default: Off
  • The flow control mechanism to use. Software uses control characters in-band. Hardware uses the RTS and CTS lines.
  • Options: Off, Software, Hardware

  • Frame Size – Type: integer, Default: 1, Min: 0, Max: 100
  • The size of receivable data frames in bytes. Set this to something other than 1, if you want to receive data with a fix frame size. The frame readable channel will trigger every time a frame of this size is ready to be read, but will wait until this frame is read before triggering again. This means, you can use this channel as a trigger in a rule, that will read exactly one frame.

Channels

Frame Readable

This channel is triggered in when a new frame was received and can be read out. The channel will only trigger again if the frame was read.

Type:
  • Trigger (system.trigger)
UID:
  • tinkerforge:brickletrs232:[UID]:BrickletRS232FrameReadable
Read only:
  • No
Overrun Error

Triggers if an overrun error occures.

Type:
  • Trigger (system.trigger)
UID:
  • tinkerforge:brickletrs232:[UID]:BrickletRS232OverrunError
Read only:
  • No
Parity Error

Triggers if a parity error occures.

Type:
  • Trigger (system.trigger)
UID:
  • tinkerforge:brickletrs232:[UID]:BrickletRS232ParityError
Read only:
  • No
Framing Error

Triggers if a framing error occures.

Type:
  • Trigger (system.trigger)
UID:
  • tinkerforge:brickletrs232:[UID]:BrickletRS232FramingError
Read only:
  • No

Actions

Actions can be used in rules by creating an action object. All actions return a Map<String, Object>. Returned values can be accessed by name, sometimes the type deduction needs some hints, as shown below:

val actions = getActions("tinkerforge", "tinkerforge:brickletrs232:[UID]")
val hwVersion = actions.brickletRS232GetIdentity().get("hardwareVersion") as short[]
logInfo("Example", "Hardware version: " + hwVersion.get(0) + "." + hwVersion.get(1) + "." + hwVersion.get(2))

Basic Actions

brickletRS232Write(char[] message, short length)
Parameters:
  • message – Type: char[], Length: 60
  • length – Type: short, Range: [0 to 60]
Return Map:
  • written – Type: short, Range: [0 to 60]

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 the thing configuration for configuration possibilities regarding baudrate, parity and so on.

brickletRS232Read()
Return Map:
  • message – Type: char[], Length: 60
  • length – Type: short, Range: [0 to 60]

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

brickletRS232ReadFrame()
Return Map:
  • message – Type: char[], Length: 60
  • length – Type: short, Range: [0 to 60]

Returns up to one frame of bytes from the read buffer. The frame size is configured with the thing configuration. If the returned length is 0, no new data was available.

Neu in Version 2.0.4 (Plugin).

brickletRS232GetConfiguration()
Return Map:
  • baudrate – Type: short, Range: See constants, Default: 11
  • parity – Type: short, Range: See constants, Default: 0
  • stopbits – Type: short, Range: See constants, Default: 1
  • wordlength – Type: short, Range: See constants, Default: 8
  • hardwareFlowcontrol – Type: short, Range: See constants, Default: 0
  • softwareFlowcontrol – Type: short, Range: See constants, Default: 0

Returns the configuration as set by the thing configuration.

The following constants are available for this function:

For baudrate:

  • val BAUDRATE_300 = 0
  • val BAUDRATE_600 = 1
  • val BAUDRATE_1200 = 2
  • val BAUDRATE_2400 = 3
  • val BAUDRATE_4800 = 4
  • val BAUDRATE_9600 = 5
  • val BAUDRATE_14400 = 6
  • val BAUDRATE_19200 = 7
  • val BAUDRATE_28800 = 8
  • val BAUDRATE_38400 = 9
  • val BAUDRATE_57600 = 10
  • val BAUDRATE_115200 = 11
  • val BAUDRATE_230400 = 12

For parity:

  • val PARITY_NONE = 0
  • val PARITY_ODD = 1
  • val PARITY_EVEN = 2
  • val PARITY_FORCED_PARITY_1 = 3
  • val PARITY_FORCED_PARITY_0 = 4

For stopbits:

  • val STOPBITS_1 = 1
  • val STOPBITS_2 = 2

For wordlength:

  • val WORDLENGTH_5 = 5
  • val WORDLENGTH_6 = 6
  • val WORDLENGTH_7 = 7
  • val WORDLENGTH_8 = 8

For hardwareFlowcontrol:

  • val HARDWARE_FLOWCONTROL_OFF = 0
  • val HARDWARE_FLOWCONTROL_ON = 1

For softwareFlowcontrol:

  • val SOFTWARE_FLOWCONTROL_OFF = 0
  • val SOFTWARE_FLOWCONTROL_ON = 1
brickletRS232SetBreakCondition(int breakTime)
Parameters:
  • breakTime – Type: int, Unit: 1 ms, Range: [0 to 216 - 1]

Sets a break condition (the TX output is forced to a logic 0 state). The parameter sets the hold-time of the break condition.

Neu in Version 2.0.2 (Plugin).

Advanced Actions

brickletRS232GetIdentity()
Return Map:
  • uid – Type: String, Length: up to 8
  • connectedUid – Type: String, Length: up to 8
  • position – Type: char, Range: ['a' to 'h', 'i', 'z']
  • hardwareVersion – Type: short[], Length: 3
    • 0: major – Type: short, Range: [0 to 255]
    • 1: minor – Type: short, Range: [0 to 255]
    • 2: revision – Type: short, Range: [0 to 255]
  • firmwareVersion – Type: short[], Length: 3
    • 0: major – Type: short, Range: [0 to 255]
    • 1: minor – Type: short, Range: [0 to 255]
    • 2: revision – Type: short, Range: [0 to 255]
  • deviceIdentifier – Type: int, Range: [0 to 216 - 1]

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). The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet connected to an Isolator Bricklet is always as position 'z'.

The device identifier numbers can be found here