Edit on GitHub

CPP PortHandler

Base class for serial communication.

Members Description
DEFAULT_BAUDRATE_ :=1000000 Default Baudrate
is_using_ Shows whether the port is in-use
Methods Description
getPortHandler Gets a child class (PortHandlerLinux or PortHandlerWindows) instance
~PortHandler None
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

Windows

Linux

Mac

CPP PortHandlerWindows

Methods Description
PortHandlerWindows Initializes PortHandlerWindows instance
~PortHandlerWindows Closes a serial port
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

openPort
closePort
clearPort
setPortName
Parameters Description
port_name Port name
getPortName
setBaudrate
bool setBaudRate(const int baudrate)
Parameters Description
baudrate Target baudrate
getBaudrate
int getBaudRate()
getBytesAvailable
int getBytesAvailable()
readPort
int readPort(UINT8_T* packet, int length)
Parameters Description
packet The number of data bytes read previously
length Byte length for read
writePort
int writePort(UINT8_T* packet, int length)
Parameters Description
packet The number of data bytes to write
length Byte length for write
setPacketTimeout
void setPacketTimeout (UINT16_T packet_length)
void setPacketTimeout (double msec)
Parameters Description
Packet_length Target byte length for write
msec Miliseconds
isPacketTimeout
bool isPacketTimeout ()

CPP PortHandlerLinux

Methods Description
PortHandlerLinux Initializes PortHandlerLinux instance
~PortHandlerLinux Closes a serial port
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

openPort
closePort
clearPort
setPortName
Parameters Description
port_name Port name
getPortName
setBaudrate
bool setBaudRate(const int baudrate)
Parameters Description
baudrate Target baudrate
getBaudrate
int getBaudRate()
getBytesAvailable
int getBytesAvailable()
readPort
int readPort(UINT8_T* packet, int length)
Parameters Description
packet The number of data bytes read previously
length Byte length for read
writePort
int writePort(UINT8_T* packet, int length)
Parameters Description
packet The number of data bytes to write
length Byte length for write
setPacketTimeout
void setPacketTimeout (UINT16_T packet_length)
void setPacketTimeout (double msec)
Parameters Description
Packet_length Target byte length for write
msec Miliseconds
isPacketTimeout
bool isPacketTimeout ()

CPP PortHandlerMac

openPort
closePort
clearPort
setPortName
Parameters Description
port_name Port name
getPortName
setBaudrate
bool setBaudRate(const int baudrate)
Parameters Description
baudrate Target baudrate
getBaudrate
int getBaudRate()
getBytesAvailable
int getBytesAvailable()
readPort
int readPort(UINT8_T* packet, int length)
Parameters Description
packet The number of data bytes read previously
length Byte length for read
writePort
int writePort(UINT8_T* packet, int length)
Parameters Description
packet The number of data bytes to write
length Byte length for write
setPacketTimeout
void setPacketTimeout (UINT16_T packet_length)
void setPacketTimeout (double msec)
Parameters Description
Packet_length Target byte length for write
msec Miliseconds
isPacketTimeout
bool isPacketTimeout ()