NAME

Tinkerforge::BrickletRS232 - Communicates with RS232 devices

CONSTANTS

DEVICE_IDENTIFIER

This constant is used to identify a RS232 Bricklet.

The get_identity() subroutine and the CALLBACK_ENUMERATE callback of the IP Connection have a device_identifier parameter to specify the Brick's or Bricklet's type.

DEVICE_DISPLAY_NAME

This constant represents the display name of a RS232 Bricklet.

CALLBACK_READ

This constant is used with the register_callback() subroutine to specify the CALLBACK_READ callback.

CALLBACK_ERROR

This constant is used with the register_callback() subroutine to specify the CALLBACK_ERROR callback.

CALLBACK_FRAME_READABLE

This constant is used with the register_callback() subroutine to specify the CALLBACK_FRAME_READABLE callback.

CALLBACK_READ_CALLBACK

This constant is used with the register_callback() subroutine to specify the CALLBACK_READ_CALLBACK callback.

CALLBACK_ERROR_CALLBACK

This constant is used with the register_callback() subroutine to specify the CALLBACK_ERROR_CALLBACK callback.

FUNCTION_WRITE

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_READ

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_ENABLE_READ_CALLBACK

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_DISABLE_READ_CALLBACK

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_IS_READ_CALLBACK_ENABLED

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_SET_CONFIGURATION

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_GET_CONFIGURATION

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_SET_BREAK_CONDITION

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_SET_FRAME_READABLE_CALLBACK_CONFIGURATION

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_GET_FRAME_READABLE_CALLBACK_CONFIGURATION

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_READ_FRAME

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_GET_IDENTITY

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTIONS

new()

Creates an object with the unique device ID *uid* and adds it to the IP Connection *ipcon*.

write()

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 :func:`Set Configuration` for configuration possibilities regarding baudrate, parity and so on.

read()

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 :func:`Enable Read Callback` and :cb:`Read` callback.

enable_read_callback()

Enables the :cb:`Read` callback. This will disable the :cb:`Frame Readable` callback.

By default the callback is disabled.

disable_read_callback()

Disables the :cb:`Read` callback.

By default the callback is disabled.

is_read_callback_enabled()

Returns *true* if the :cb:`Read` callback is enabled, *false* otherwise.

set_configuration()

Sets the configuration for the RS232 communication.

Hard-/Software flow control can either be on or off but not both simultaneously on.

get_configuration()

Returns the configuration as set by :func:`Set Configuration`.

set_break_condition()

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

.. versionadded:: 2.0.2$nbsp;(Plugin)

set_frame_readable_callback_configuration()

Configures the :cb:`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 :cb:`Read` callback.

By default the callback is disabled.

.. versionadded:: 2.0.4$nbsp;(Plugin)

get_frame_readable_callback_configuration()

Returns the callback configuration as set by :func:`Set Frame Readable Callback Configuration`.

.. versionadded:: 2.0.4$nbsp;(Plugin)

read_frame()

Returns up to one frame of bytes from the read buffer. The frame size is configured with :func:`Set Frame Readable Callback Configuration`. If the returned length is 0, no new data was available.

.. versionadded:: 2.0.4$nbsp;(Plugin)

get_identity()

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 :ref:`Isolator Bricklet <isolator_bricklet>` is always as position 'z'.

The device identifier numbers can be found :ref:`here <device_identifier>`. |device_identifier_constant|