VEX EDR Python API
|
Public Member Functions | |
def | __init__ (self, port=SerialParam.PORT_HOST, baud_rate=19200, word_length=SerialParam.WORDLEN_8B, stop_bits=SerialParam.STOPBITS_1, parity=SerialParam.PARITY_NO, flow_control=SerialParam.FLOWCONTROL_NONE) |
def | write (self, data, null_terminate_string=True) |
Write the data to the serial port. More... | |
def | bytes_to_read (self) |
Get the number of bytes available for reading. More... | |
def | read_bytes (self, length=None, stop_byte=None) |
Read the given number of bytes from the port. More... | |
def | read_bytes_list (self, length=None, stop_byte=None) |
Read the given number of bytes from the port. More... | |
def | read_byte (self) |
Read a single byte from the port. More... | |
def | read_string (self) |
Read a null-terminated string from the port. More... | |
def | flush_read (self) |
Flush serial input buffer discarding all bytes. More... | |
def | log (self, item) |
Log an item to the host using the RM protocol. More... | |
**Config** Serial port device (host port, UART1, UART2). @param port 0 or for host port, 1 for UART1, 2 for UART2. Default 0 (host port). Parameters for UART1/UART2 are @param baud_rate baud rate, pass a standard value, e.g. 9600, 19200, 56000. @param word_length word length: SerialParam.WORDLEN_[8B|9B]. Default 8B. @param stop_bits stop bits: SerialParam.STOPBITS_[1|0_5|2|1_5]. Default 1. @param parity parity: SerialParam.PARITY_[NO|ODD|EVEN]. Default NO. @param flow_control hardware flow control: SerialParam.FLOWCONTROL_[NONE|RTS|CTS|RTS_CTS]. Default NONE.
def vex.Serial.__init__ | ( | self, | |
port = SerialParam.PORT_HOST , |
|||
baud_rate = 19200 , |
|||
word_length = SerialParam.WORDLEN_8B , |
|||
stop_bits = SerialParam.STOPBITS_1 , |
|||
parity = SerialParam.PARITY_NO , |
|||
flow_control = SerialParam.FLOWCONTROL_NONE |
|||
) |
def vex.Serial.write | ( | self, | |
data, | |||
null_terminate_string = True |
|||
) |
Write the data to the serial port.
data | bytes to send. Type can be:
|
null_terminate_string | send '\0' at the end if data type is string. Default True. |
def vex.Serial.bytes_to_read | ( | self | ) |
Get the number of bytes available for reading.
def vex.Serial.read_bytes | ( | self, | |
length = None , |
|||
stop_byte = None |
|||
) |
Read the given number of bytes from the port.
Blocks until data is available, returns string of bytes.
length | number of bytes to read, None for all available. |
stop_byte | byte that halts the stream, usually \0 for strings. |
def vex.Serial.read_bytes_list | ( | self, | |
length = None , |
|||
stop_byte = None |
|||
) |
Read the given number of bytes from the port.
Blocks until data is available, returns list of bytes.
length | number of bytes to read, None for all available. |
stop_byte | byte that halts the stream, usually \0 for strings. |
def vex.Serial.read_byte | ( | self | ) |
Read a single byte from the port.
Blocks until the byte arrives.
def vex.Serial.read_string | ( | self | ) |
Read a null-terminated string from the port.
Blocks until one is available.
def vex.Serial.flush_read | ( | self | ) |
Flush serial input buffer discarding all bytes.
def vex.Serial.log | ( | self, | |
item | |||
) |
Log an item to the host using the RM protocol.
Only the default host port (0) is supported.
item | item to log (string, tuple or list) |