Edit on GitHub

Python PortHandler

Base class for serial communication.

Members Description
DEFAULT_BAUDRATE_ :=1000000 Default Baudrate
is_using_ Shows whether the port is in-use
Methods Description
PortHandler Initializes parameters for serial port control
openPort Opens a serial port
closePort Closes a serial port
clearPort Refreshes a serial port
setPortName Sets a device name
getPortName Gets a device name
setBaudrate Sets a baudrate
getBaudrate Gets a baudrate
getBytesAvailable Checks how many bytes can be read in port buffer
readPort Reads bytes from port buffer
writePort Writes bytes to port buffer
setPacketTimeout Sets timeout
isPacketTimeout Checks whether communication has been succeeded in timeout

Method References

PortHandler
Parameters Description
port_name Port name
openPort

None

closePort

None

clearPort

None

setPortName
Parameters Description
port_name Port name
getPortName

None

setBaudrate
setBaudrate(baudrate)
Parameters Description
baudrate Target baudrate
getBaudrate
getBaudrate()

None

getBytesAvailable
getBytesAvailable()

None

readPort
readPort(length)
Parameters Description
length Byte length for read
writePort
 writePort(packet)
Parameters Description
packet The number of data bytes to write
length Byte length for write
setPacketTimeout
setPacketTimeout(packet_length)
Parameters Description
Packet_length Target byte length for write
setPacketTimeoutMillis
setPacketTimeoutMillis(msec)
Parameters Description
msec Miliseconds
isPacketTimeout
isPacketTimeout()

None