Edit on GitHub

API Reference

C

C PortHandler

Members Description
DEFAULT_BAUDRATE :=1000000 Default Baudrate
g_used_port_num Shows how much ports are in-use
g_is_using Shows whether the port is in-use
Methods Description
portHandler Initializes members of port data pointer struct
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 (Linux only)
readPort Reads bytes from port buffer
writePort Writes bytes to port buffer
setPacketTimeout Sets timeout
setPacketTimeoutMSec Sets timeout using micro second value
isPacketTimeout Checks whether communication has been succeeded in timeout

Method References

C PortHandlerWindows

Methods Description
portHandlerWindows Initializes parameters for serial port control
openPortWindows Opens a serial port
closePortWindows Closes a serial port
clearPortWindows Refreshes a serial port
setPortNameWindows Sets a device name
getPortNameWindows Gets a device name
setBaudrateWindows Sets a baudrate
getBaudrateWindows Gets a baudrate
readPortWindows Reads bytes from port buffer
writePortWindows Writes bytes to port buffer
setPacketTimeoutWindows Sets timeout
isPacketTimeoutWindows Checks whether communication has been succeeded in timeout

Method References

portHandlerWindows
Parameters Description
port_name Port name
openPortWindows
Parameters Description
port_num Port number
closePortWindows
Parameters Description
port_num Port number
clearPortWindows
Parameters Description
port_num Port number
setPortNameWindows
Parameters Description
port_num Port number
port_name Port name
getPortNameWindows
Parameters Description
port_num Port number
setBaudrateWindows
uint8_t setBaudrateWindows(int port_num, const int baudrate)
Parameters Description
port_num Port number
baudrate Target baudrate
getBaudrateWindows
int getBaudrateWindows(int port_num)
Parameters Description
port_num Port number
readPortWindows
int readPortWindows(int port_num, uint8_t *packet, int length)
Parameters Description
port_num Port number
packet The number of data bytes read previously
length Byte length for read
writePortWindows
int writePortWindows(int port_num, uint8_t *packet, int length)
Parameters Description
port_num Port number
packet The number of data bytes to write
length Byte length for write
setPacketTimeoutWindows
void setPacketTimeoutWindows (int port_num, uint16_t packet_length)
Parameters Description
port_num Port number
packet_length Target byte length for write
SetPacketTimeoutMSecWindows
void SetPacketTimeoutMSecWindows (int port_num, double msec)
Parameters Description
port_num Port number
msec Miliseconds
isPacketTimeoutWindows
uint8_t isPacketTimeoutWindows (int port_num)

C PortHandlerLinux

Methods Description
portHandleLinux Initializes parameters for serial port control
openPortLinux Opens a serial port
closePortLinux Closes a serial port
clearPortLinux Refreshes a serial port
setPortNameLinux Sets a device name
getPortNameLinux Gets a device name
setBaudrateLinux Sets a baudrate
getBaudrateLinux Gets a baudrate
getBytesAvailableLinux Checks how many bytes can be read in port buffer
readPortLinux Reads bytes from port buffer
writePortLinux Writes bytes to port buffer
setPacketTimeoutLinux Sets timeout
isPacketTimeoutLinux Checks whether communication has been succeeded in timeout

Method References

portHandlerLinux
Parameters Description
port_name Port name
openPortLinux
Parameters Description
port_num Port number
closePortLinux
Parameters Description
port_num Port number
clearPortLinux
Parameters Description
port_num Port number
setPortNameLinux
Parameters Description
port_num Port number
port_name Port name
getPortNameLinux
Parameters Description
port_num Port number
setBaudrateLinux
uint8_t setBaudrateLinux(int port_num, const int baudrate)
Parameters Description
port_num Port number
baudrate Target baudrate
getBaudrateLinux
int getBaudrateLinux(int port_num)
Parameters Description
port_num Port number
getBytesAvailableLinux
int getBytesAvailableLinux(int port_num)
Parameters Description
port_num Port number
readPortLinux
int readPortLinux(int port_num, uint8_t *packet, int length)
Parameters Description
port_num Port number
packet The number of data bytes read previously
length Byte length for read
writePortLinux
int writePortLinux(int port_num, uint8_t *packet, int length)
Parameters Description
port_num Port number
packet The number of data bytes to write
length Byte length for write
setPacketTimeoutLinux
void setPacketTimeoutLinux (int port_num, uint16_t packet_length)
Parameters Description
port_num Port number
Packet_length Target byte length for write
setPacketTimeoutMSecLinux
void setPacketTimeoutMSecLinux (int port_num, double msec)
Parameters Description
port_num Port number
msec Miliseconds
isPacketTimeoutLinux
uint8_t isPacketTimeoutLinux(int port_num)
Parameters Description
port_num Port number

C PortHandlerMac

Methods Description
portHandleMac Initializes parameters for serial port control
openPortMac Opens a serial port
closePortMac Closes a serial port
clearPortMac Refreshes a serial port
setPortNameMac Sets a device name
getPortNameMac Gets a device name
setBaudrateMac Sets a baudrate
getBaudrateMac Gets a baudrate
getBytesAvailableMac Checks how many bytes can be read in port buffer
readPortMac Reads bytes from port buffer
writePortMac Writes bytes to port buffer
setPacketTimeoutMac Sets timeout
isPacketTimeoutMac Checks whether communication has been succeeded in timeout

Method References

portHandlerMac
Parameters Description
port_name Port name
openPortMac
Parameters Description
port_num Port number
closePortMac
Parameters Description
port_num Port number
clearPortMac
Parameters Description
port_num Port number
setPortNameMac
Parameters Description
port_num Port number
port_name Port name
getPortNameMac
Parameters Description
port_num Port number
setBaudrateMac
uint8_t setBaudrateMac(int port_num, const int baudrate)
Parameters Description
port_num Port number
baudrate Target baudrate
getBaudrateMac
int getBaudrateMac(int port_num)
Parameters Description
port_num Port number
getBytesAvailableMac
int getBytesAvailableMac(int port_num)
Parameters Description
port_num Port number
readPortMac
int readPortMac(int port_num, uint8_t *packet, int length)
Parameters Description
port_num Port number
packet The number of data bytes read previously
length Byte length for read
writePortMac
int writePortMac(int port_num, uint8_t *packet, int length)
Parameters Description
port_num Port number
packet The number of data bytes to write
length Byte length for write
setPacketTimeoutMac
void setPacketTimeoutMac (int port_num, uint16_t packet_length)
Parameters Description
port_num Port number
Packet_length Target byte length for write
setPacketTimeoutMSecMac
void setPacketTimeoutMSecMac (int port_num, double msec)
Parameters Description
port_num Port number
msec Miliseconds
isPacketTimeoutMac
uint8_t isPacketTimeoutMac(int port_num)
Parameters Description
port_num Port number