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
setPacketTimeoutMSecWindows Sets timeout using micro second
isPacketTimeoutWindows Checks whether communication has been succeeded in timeout
getCurrentTimeWindows Gets a current time
getTimeSinceStartWindows Gets a time since start
setupPortWindows Sets a port

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)
Parameters Description
port_num Port number
getCurrentTimeWindows
double getCurrentTimeWindows(int port_num)
Parameters Description
port_num Port number
getTimeSinceStartWindows
double getTimeSinceStartWindows(int port_num)
Parameters Description
port_num Port number
setupPortWindows
uint8_t setupPortWindows (int port_num, const int baudrate)
Parameters Description
port_num Port number
baudrate Target baudrate

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
setPacketTimeoutMSecLinux Sets timeout using micro second
isPacketTimeoutLinux Checks whether communication has been succeeded in timeout
getCurrentTimeLinux Gets a current time
getTimeSinceStartLinux Gets a time since start
setupPortLinux Sets a port
setCustomBaudrateLinux Sets a custom baudrate
getCFlagBaud Gets a baudrate

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
getCurrentTimeLinux
double getCurrentTimeLinux()
getTimeSinceStartLinux
double getTimeSinceStartLinux(int port_num)
Parameters Description
port_num Port number
setupPortLinux
uint8_t setupPortLinux(int port_num, int cflag_baud)
Parameters Description
port_num Port number
cflag_baud Target baudrate
setCustomBaudrateLinux
uint8_t setCustomBaudrateLinux(int port_num, int speed)
Parameters Description
port_num Port number
speed communication speed
getCFlagBaud
int getCFlagBaud(int baudrate)
Parameters Description
baudrate Target baudrate

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
setPacketTimeoutMSecMac Sets timeout using micro
isPacketTimeoutMac Checks whether communication has been succeeded in timeout
getCurrentTimeMac Gets a current time
getTimeSinceStartMac Gets a time since start
setupPortMac Sets a port
setCustomBaudrateMac Sets a custom baudrate
getCFlagBaud Gets a baudrate

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
getCurrentTimeMac
double getCurrentTimeMac()
getTimeSinceStartMac
double getTimeSinceStartMac(int port_num)
Parameters Description
port_num Port number
setupPortMac
uint8_t setupPortMac(int port_num, int cflag_baud)
Parameters Description
port_num Port number
cflag_baud Target baudrate
setCustomBaudrateMac
uint8_t setCustomBaudrateMac(int port_num, int speed)
Parameters Description
port_num Port number
speed communication speed
getCFlagBaud
int getCFlagBaud(int baudrate)
Parameters Description
baudrate Target baudrate