The functions used in this sample and the frequently used functions are shown below.
Libmodbus has other functions besides these functions, but we have not confirmed the operation.
Please refer to the libmodbus official homepage for the functions not listed in this reference.
Communication Settings |
|
Specifies the IP address and port of the slave device to communicate with, and initializes it as Modbus/TCP. |
|
Specifies the COM port to connect to the slave device to communicate with, sets the baudrate, parity, etc., and initializes it as Modbus/RTU. |
|
Sets the slave ID. |
|
Retrieves the slave ID. |
|
Sets the timeout period between bytes in Modbus communication. |
|
Retrieves the timeout period between bytes in Modbus communication. |
|
Sets the response timeout period in Modbus communication. |
|
Retrieves the response timeout period in Modbus communication. |
|
Communication Processing |
|
Connects to a Modbus slave device. |
|
Disconnects from the Modbus slave device. |
|
Releases the libmodbus structure. |
|
Flushes unsent data. The flushed data will be discarded. |
|
Function Code |
|
Uses the function code Read Coils (code 01) to acquire multiple bits information of the Coil area. |
|
Uses the function code Read Discrete Inputs (code 02) to acquire multiple bits information of the Input Status area. |
|
Uses the function code Read Holding Registers (code 03) to acquire multiple registers information of the holding register area. |
|
Uses the function code Read Input Registers (code 04) to acquire multiple registers information of the input register area. |
|
Uses the function code Write Coil (code 05) to write 1 bit to the Coil area. |
|
Uses the function code Write Register (code 06) to write 1 register to the holding register area. |
|
Uses the function code Write Multiple Coils (code 15) to write multiple bits to the Coil area. |
|
Uses the function code Write Multiple Registers (code 16) to write multiple registers to the holding register area. |
|
Data Conversion |
|
Retrieves the error message. |
|
Retrieves the errono. |
|
Retrieves bit information from byte information. |
|
Retrieves bit information from multiple byte information. |
|
Converts bit information to byte information. |
|
Converts the specified float value to 4-byte data. The byte order is in ABCD order. |
|
Converts the specified 4-byte data to a float value. The byte order is in ABCD order. |
|
Converts the specified float value to 4-byte data. The byte order is in BADC order. |
|
Converts the specified 4-byte data to a float value. The byte order is in BADC order. |
|
Converts the specified float value to 4-byte data. The byte order is in CDAB order. |
|
Converts the specified 4-byte data to a float value. The byte order is in CDAB order. |
|
Converts the specified float value to 4-byte data. The byte order is in DCBA order. |
|
Converts the specified 4-byte data to a float value. The byte order is in DCBA order. |