Edit on GitHub

Java PortHandler

Methods Description
portHandle 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
Parameters Description
port_num Port number
closePort
Parameters Description
port_num Port number
clearPort
Parameters Description
port_num Port number
setPortName
Parameters Description
port_num Port number
port_name Port name
getPortName
Parameters Description
port_num Port number
setBaudrate
Boolean setBaudrate(int port_num, const int baudrate)
Parameters Description
port_num Port number
baudrate Target baudrate
getBaudrate
int getBaudrate(int port_num)
Parameters Description
port_num Port number
getBytesAvailable
int getBytesAvailable(int port_num)
Parameters Description
port_num Port number
readPort
int readPort(int port_num, byte[] packet, int length)
Parameters Description
port_num Port number
packet The number of data bytes read previously
length Byte length for read
writePort
int writePort(int port_num, byte[] packet, int length)
Parameters Description
port_num Port number
packet The number of data bytes to write
length Byte length for write
setPacketTimeout
void setPacketTimeout (int port_num, uint16_t packet_length)
Parameters Description
port_num Port number
Packet_length Target byte length for write
setPacketTimeoutMSec
void setPacketTimeoutMSec (int port_num, double msec)
Parameters Description
port_num Port number
msec Miliseconds
isPacketTimeout
Boolean isPacketTimeout(int port_num)
Parameters Description
port_num Port number