UART¶
See the UART Entity for generic information.
- class brainstem.entity.UART(module, index)[source]¶
A UART is a “Universal Asynchronous Receiver/Transmitter. Many times referred to as a COM (communication), Serial, or TTY (teletypewriter) port. The UART Class allows the enabling and disabling of the UART data lines.
- getAvailableProtocols()[source]¶
Returns a bitmask containing a list of protocols that this UART entity is capable of selecting, and has an available protocol resource to assign.
- Returns:
- Object containing error code and returned value on success.
- errorunsigned byte
An error result from the list of defined error codes
- valueunsigned int
Bitmask containing list of protocols that are available to select. The value of the uartProtocol is mapped to the bit index (e.g. uartProtocol_Undefined is bit 0, uartProtocol_ExtronResponder_Value is bit 1, etc.)
- Return type:
- getBaudRate()[source]¶
Get the UART baud rate. If zero, automatic baud rate selection is used.
- Returns:
- Object containing error code and returned value on success.
- errorunsigned byte
An error result from the list of defined error codes
- valueunsigned int
Pointer variable to be filled with baud rate.
- Return type:
- getCapableProtocols()[source]¶
Returns a bitmask containing a list of protocols that this UART entity is allowed to select. This does not guarantee that selecting a protocol with “setProtocol” will have an available resource.
- Returns:
- Object containing error code and returned value on success.
- errorunsigned byte
An error result from the list of defined error codes
- valueunsigned int
Bitmask containing list of protocols that may be selected. The value of the uartProtocol is mapped to the bit index (e.g. uartProtocol_Undefined is bit 0, uartProtocol_ExtronResponder_Value is bit 1, etc.)
- Return type:
- getDataBits()[source]¶
Get the number of bits per character
- Returns:
- Object containing error code and returned value on success.
- errorunsigned byte
An error result from the list of defined error codes
- valueunsigned char
Pointer to where result is placed.
- Return type:
- getEnable()[source]¶
Get the enabled state of the uart.
- Returns:
- Object containing error code and returned value on success.
- errorunsigned byte
An error result from the list of defined error codes
- valuebool
true: enabled, false: disabled.
- Return type:
- getFlowControl()[source]¶
Set the UART flow control configuration
- Returns:
- Object containing error code and returned value on success.
- errorunsigned byte
An error result from the list of defined error codes
- valueunsigned char
- Pointer to bitmask where result is placed. Possible bits:
uartFlowControl_RTS_CTS_Bit
uartFlowControl_DSR_DTR_Bit
uartFlowControl_XON_XOFF_Bit
- Return type:
- getLinkChannel()[source]¶
Gets the index of the UART Entity that this entity is linked to.
- Returns:
- Object containing error code and returned value on success.
- errorunsigned byte
An error result from the list of defined error codes
- valueunsigned char
Pointer to where result is placed.
- Return type:
- getParity()[source]¶
Get the UART parity.
- Returns:
- Object containing error code and returned value on success.
- errorunsigned byte
An error result from the list of defined error codes
- valueunsigned char
- Pointer variable to be filled with value. Possible values:
uartParity_None_Value
uartParity_Odd_Value
uartParity_Even_Value
uartParity_Mark_Value
uartParity_Space_Value
- Return type:
- getProtocol()[source]¶
Get the UART protocol.
- Returns:
- Object containing error code and returned value on success.
- errorunsigned byte
An error result from the list of defined error codes
- valueunsigned char
Pointer to where result is placed.
- Return type:
- getStopBits()[source]¶
Set the UART stop bit configuration
- Returns:
- Object containing error code and returned value on success.
- errorunsigned byte
An error result from the list of defined error codes
- valueunsigned char
- Pointer to where result is placed. Possible values:
uartStopBits_1_Value
uartStopBits_1p5_Value
uartStopBits_2_Value
- Return type:
- setBaudRate(rate)[source]¶
Set the UART baud rate. If zero, automatic baud rate selection is used.
- Parameters:
rate (unsigned int) – baud rate.
- Returns:
An error result from the list of defined error codes in brainstem.result.Result
- Return type:
unsigned byte
- setDataBits(data_bits)[source]¶
Set the number of bits per character
- Parameters:
data_bits (unsigned char) – Data Bits of UART Channel.
- Returns:
An error result from the list of defined error codes in brainstem.result.Result
- Return type:
unsigned byte
- setEnable(enabled)[source]¶
Enable the UART channel.
- Parameters:
enabled (bool) – true: enabled, false: disabled.
- Returns:
An error result from the list of defined error codes in brainstem.result.Result
- Return type:
unsigned byte
- setFlowControl(flow_control)[source]¶
Set the UART flow control configuration
- Parameters:
flow_control (unsigned char) –
- Flow Control of UART Channel as a bitmask. Allowed bits:
uartFlowControl_RTS_CTS_Bit
uartFlowControl_DSR_DTR_Bit
uartFlowControl_XON_XOFF_Bit
- Returns:
An error result from the list of defined error codes in brainstem.result.Result
- Return type:
unsigned byte
- setLinkChannel(channel)[source]¶
Set the index of another UART Entity that should be linked to this UART.
If set to the index of this entity, the channel will not be linked. If set to the index of another UART entity, data will be sent between the two UART entities with no additional processing.
- Parameters:
channel (unsigned char) – Index of the UART Entity to link
- Returns:
An error result from the list of defined error codes in brainstem.result.Result
- Return type:
unsigned byte
- setParity(parity)[source]¶
Set the UART parity.
- Parameters:
parity (unsigned char) –
- Parity of UART Channel. Allowed options:
uartParity_None_Value
uartParity_Odd_Value
uartParity_Even_Value
uartParity_Mark_Value
uartParity_Space_Value
- Returns:
An error result from the list of defined error codes in brainstem.result.Result
- Return type:
unsigned byte
- setProtocol(protocol)[source]¶
Set the UART protocol.
- Parameters:
protocol (unsigned char) – An enumeration of serial protocols.
- Returns:
An error result from the list of defined error codes in brainstem.result.Result
- Return type:
unsigned byte
- setStopBits(stop_bits)[source]¶
Set the UART stop bit configuration
- Parameters:
stop_bits (unsigned char) –
- Stop Bits of UART Channel. Allowed options:
uartStopBits_1_Value
uartStopBits_1p5_Value
uartStopBits_2_Value
- Returns:
An error result from the list of defined error codes in brainstem.result.Result
- Return type:
unsigned byte