IPC@CHIP Modbus library – API Documentation

Header image

Main page


Modbus RTU master - Functions


Detailed Description

This page lists all functions of the Modbus RTU master API.
The Modbus library allows to create/handle up to 16 Modbus RTU master connections specificable by a unique serial port number.
The implemented set of functions provides the initialization of the serial port device and the execution of Modbus master requests for the following function codes:
1h,2h,3h,5h,6h,10h,17h

The provided source code sample MBRTU_MASTER shall be used as a template for the creation of own Modbus RTU master applications.
For accessing the serial port devices the library uses the IPC@CHIP® RTOS Fossil API.

Enable debug mode: When setting the internal variables mb_rtu_rcv_dbg and mb_rtu_snd_dbg to value 1 all incoming and outgoing messages are written to stdout.

Functions

int mbRTU_mst_init (MbHandle *handle, int port, u32 baud, int parity, int rtuMode, u16 bcastAddress, u8 async)
 Initialize the Modbus RTU master connection.
int mbRTU_mst_deinit (MbHandle handle)
 DeInitialize/close Modbus RTU master.
u16 mbRTU_mst_get_silenttime (MbHandle handle)
 Get silent time for Modbus RTU master communication.
u16 mbRTU_mst_set_silenttime (MbHandle handle, u16 silentTime)
 Set silent time for Modbus RTU master communication.
int mbRTU_mst_wr_regs (MbHandle handle, u8 slaveAddr, u16 startAddress, u16 items, const u16 *registerData, u8 *exception, u32 timeoutMs)
 Write multiple registers (10h) Send a "write multiple registers" request 10h and receive reply from the slave.
int mbRTU_mst_wr_regs_packed (MbHandle handle, u8 slaveAddr, u16 startAddress, u16 quantity, const u8 *registerData, u8 *exception, u32 timeoutMs)
 Write multiple registers in a packed manner(10h) Same as mbRTU_mst_wr_regs_packed() but expects registerData in a packed manner.
int mbRTU_mst_wr_single_reg (MbHandle handle, u8 slaveAddr, u8 functionCode, u16 startAddress, u16 registerData, u8 *exception, u32 timeoutMs)
 Write single holding register (6h).
int mbRTU_mst_wr_single_coil (MbHandle handle, u8 slaveAddr, u16 startAddress, u16 coil, u8 *exception, u32 timeoutMs)
 Write single coil (5h).
int mbRTU_mst_rd_discr_inputs (MbHandle handle, u8 slaveAddr, u8 functionCode, u16 startAddress, u16 quantity, u8 *inputCoilBuf, u8 *exception, u32 timeoutMs)
 Read discrete inputs (02) , Read coil status (01).
int mbRTU_mst_wr_coils (MbHandle handle, u8 slaveAddr, u16 startAddress, u16 quantity, const u8 *coilBuf, u8 *exception, u32 timeoutMs)
 Write multiple coils (0x0F).
int mbRTU_mst_rd_regs (MbHandle handle, u8 slaveAddr, u8 functionCode, u16 startAddress, u16 quantity, u16 *registerData, u8 *exception, u32 timeoutMs)
 Read multiple registers (03h/04h).
int mbRTU_mst_rd_regs_packed (MbHandle handle, u8 slaveAddr, u8 functionCode, u16 startAddress, u16 quantity, u8 *registerData, u8 *exception, u32 timeoutMs)
 Read multiple registers in a packed manner (03h/04h).
int mbRTU_mst_rdwr_regs (MbHandle handle, u8 slaveAddr, u16 startAddressRd, u16 quantityRd, u16 *registerDataRd, u16 startAddressWr, u16 quantityWr, const u16 *registerDataWr, u8 *exception, u32 timeoutMs)
 Read/write multiple registers (17h).
int mbRTU_mst_rdwr_regs_packed (MbHandle handle, u8 slaveAddr, u16 startAddressRd, u16 quantityRd, u8 *registerDataRd, u16 startAddressWr, u16 quantityWr, const u8 *registerDataWr, u8 *exception, u32 timeoutMs)
 Read/write multiple registers in a packed manner(17h).
int mbRTU_mst_WrRd_ByteBlock (MbHandle handle, u8 slaveAddr, u16 startAddress, const u8 *sendBuf, u16 sendNumBytes, u8 *replyBuf, u16 *replyLength, u16 expectedReplyLength, u8 *exception, u32 timeoutMs)
 Write/Read byte block (Beck IPC specific).





Top of page | Main page

Copyright © 2017 Beck IPC GmbH
Generated on Thu Mar 9 18:00:33 2017 by Doxygen 1.6.1