VEX V5 Python API
Public Member Functions | List of all members
vex.Serial Class Reference

Public Member Functions

def __init__ (self, parent)
 Serial port (wireless or USB connection) More...
 
def write (self, data, null_terminate_string=True)
 Write the data to the serial port. More...
 
def read (self, buffer)
 Read data present on the serial port. More...
 
def has_data (self)
 Check if there is data to be read. More...
 

Constructor & Destructor Documentation

◆ __init__()

def vex.Serial.__init__ (   self,
  parent 
)

Serial port (wireless or USB connection)

Member Function Documentation

◆ write()

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

Write the data to the serial port.

Parameters
databytes to send. Type can be:
  • list or tuple 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.
Returns
number of bytes written

◆ read()

def vex.Serial.read (   self,
  buffer 
)

Read data present on the serial port.

Parameters
bufferpre-allocated bytearray of a fixed length that will be filled with file data.
Returns
number of bytes actually read, <= length, -1 on error

◆ has_data()

def vex.Serial.has_data (   self)

Check if there is data to be read.

Call read to get the data.

Returns
True if any data has arrived, False if there is no data