pub struct Rs232Bricklet { /* private fields */ }
Expand description

Communicates with RS232 devices

Implementations

Creates an object with the unique device ID uid. This object can then be used after the IP Connection ip_connection is connected.

Returns the response expected flag for the function specified by the function ID parameter. It is true if the function is expected to send a response, false otherwise.

For getter functions this is enabled by default and cannot be disabled, because those functions will always send a response. For callback configuration functions it is enabled by default too, but can be disabled by set_response_expected. For setter functions it is disabled by default and can be enabled.

Enabling the response expected flag for a setter function allows to detect timeouts and other error conditions calls of this setter as well. The device will then send a response for this purpose. If this flag is disabled for a setter function then no response is send and errors are silently ignored, because they cannot be detected.

See set_response_expected for the list of function ID constants available for this function.

Changes the response expected flag of the function specified by the function ID parameter. This flag can only be changed for setter (default value: false) and callback configuration functions (default value: true). For getter functions it is always enabled.

Enabling the response expected flag for a setter function allows to detect timeouts and other error conditions calls of this setter as well. The device will then send a response for this purpose. If this flag is disabled for a setter function then no response is send and errors are silently ignored, because they cannot be detected.

Changes the response expected flag for all setter and callback configuration functions of this device at once.

This receiver 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 receiver, use Enable Read Receiver.

This receiver is called if an error occurs. Possible errors are overrun, parity or framing error.

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

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.

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 Read Receiver and get_read_callback_receiver receiver.

Enables the get_read_callback_receiver receiver.

By default the receiver is disabled.

Disables the get_read_callback_receiver receiver.

By default the receiver is disabled.

Returns true if the get_read_callback_receiver receiver is enabled, false otherwise.

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 either be on or off but not both simultaneously on.

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

Associated constants:

  • RS232BRICKLET_BAUDRATE_300
  • RS232BRICKLET_BAUDRATE_600
  • RS232BRICKLET_BAUDRATE_1200
  • RS232BRICKLET_BAUDRATE_2400
  • RS232BRICKLET_BAUDRATE_4800
  • RS232BRICKLET_BAUDRATE_9600
  • RS232BRICKLET_BAUDRATE_14400
  • RS232BRICKLET_BAUDRATE_19200
  • RS232BRICKLET_BAUDRATE_28800
  • RS232BRICKLET_BAUDRATE_38400
  • RS232BRICKLET_BAUDRATE_57600
  • RS232BRICKLET_BAUDRATE_115200
  • RS232BRICKLET_BAUDRATE_230400
  • RS232BRICKLET_PARITY_NONE
  • RS232BRICKLET_PARITY_ODD
  • RS232BRICKLET_PARITY_EVEN
  • RS232BRICKLET_PARITY_FORCED_PARITY_1
  • RS232BRICKLET_PARITY_FORCED_PARITY_0
  • RS232BRICKLET_STOPBITS_1
  • RS232BRICKLET_STOPBITS_2
  • RS232BRICKLET_WORDLENGTH_5
  • RS232BRICKLET_WORDLENGTH_6
  • RS232BRICKLET_WORDLENGTH_7
  • RS232BRICKLET_WORDLENGTH_8
  • RS232BRICKLET_HARDWARE_FLOWCONTROL_OFF
  • RS232BRICKLET_HARDWARE_FLOWCONTROL_ON
  • RS232BRICKLET_SOFTWARE_FLOWCONTROL_OFF
  • RS232BRICKLET_SOFTWARE_FLOWCONTROL_ON

Returns the configuration as set by Set Configuration.

Associated constants:

  • RS232BRICKLET_BAUDRATE_300
  • RS232BRICKLET_BAUDRATE_600
  • RS232BRICKLET_BAUDRATE_1200
  • RS232BRICKLET_BAUDRATE_2400
  • RS232BRICKLET_BAUDRATE_4800
  • RS232BRICKLET_BAUDRATE_9600
  • RS232BRICKLET_BAUDRATE_14400
  • RS232BRICKLET_BAUDRATE_19200
  • RS232BRICKLET_BAUDRATE_28800
  • RS232BRICKLET_BAUDRATE_38400
  • RS232BRICKLET_BAUDRATE_57600
  • RS232BRICKLET_BAUDRATE_115200
  • RS232BRICKLET_BAUDRATE_230400
  • RS232BRICKLET_PARITY_NONE
  • RS232BRICKLET_PARITY_ODD
  • RS232BRICKLET_PARITY_EVEN
  • RS232BRICKLET_PARITY_FORCED_PARITY_1
  • RS232BRICKLET_PARITY_FORCED_PARITY_0
  • RS232BRICKLET_STOPBITS_1
  • RS232BRICKLET_STOPBITS_2
  • RS232BRICKLET_WORDLENGTH_5
  • RS232BRICKLET_WORDLENGTH_6
  • RS232BRICKLET_WORDLENGTH_7
  • RS232BRICKLET_WORDLENGTH_8
  • RS232BRICKLET_HARDWARE_FLOWCONTROL_OFF
  • RS232BRICKLET_HARDWARE_FLOWCONTROL_ON
  • RS232BRICKLET_SOFTWARE_FLOWCONTROL_OFF
  • RS232BRICKLET_SOFTWARE_FLOWCONTROL_ON

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)

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

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.