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_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_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 length is given as 0, there was no new data 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.

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

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 (in ms).

.. versionadded:: 2.0.2$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' or 'd'.

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