VEX IQ Python API
Public Member Functions | List of all members
vexiq.Serial Class Reference

Config Serial port to host. More...

Public Member Functions

def __init__ (self)
 
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 log (self, item)
 Log an item to the host using the RM protocol. More...
 

Detailed Description

Config Serial port to host.

Constructor & Destructor Documentation

◆ __init__()

def vexiq.Serial.__init__ (   self)

Member Function Documentation

◆ write()

def vexiq.Serial.write (   self,
  data,
  null_terminate_string = True 
)

Write the data to the serial port.

Parameters
databytes to send. Type can be:
  • single int (e.g. 0xFF)
  • list of ints (e.g. [0x01, 0x02, 0x03])
  • bytearray or bytes literal
  • string
null_terminate_stringsend '\0' at the end if data type is string. Default True.

◆ bytes_to_read()

def vexiq.Serial.bytes_to_read (   self)

Get the number of bytes available for reading.

Returns
number

◆ read_bytes()

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

Parameters
lengthnumber of bytes to read, zero for all.
stop_bytebyte that halts the stream, usually \0 for strings.
Returns
string containing the bytes

◆ read_bytes_list()

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

Parameters
lengthnumber of bytes to read, zero for all.
stop_bytebyte that halts the stream, usually \0 for strings.
Returns
list containing the bytes (as numbers)

◆ read_byte()

def vexiq.Serial.read_byte (   self)

Read a single byte from the port.

Blocks until the byte arrives.

Returns
string

◆ read_string()

def vexiq.Serial.read_string (   self)

Read a null-terminated string from the port.

Blocks until one is available.

◆ log()

def vexiq.Serial.log (   self,
  item 
)

Log an item to the host using the RM protocol.

Parameters
itemitem to log (string, tuple or list)