Moxa IA3341-LX Инструкция по эксплуатации онлайн [72/72] 170917

Moxa IA3341-LX Инструкция по эксплуатации онлайн [72/72] 170917
IA3341 Linux User’s Manual Programmer’s Guide
6-17
Write register values via function code 6 or 16
int
mbtcp_write_regs(
void *hndl,
unsigned int tmout,
unsigned short start_addr,
unsigned short count,
unsigned short reg_val[]
);
Input:
<hndl> MODBUS TCP connection handler
<tmout> communication timeout in second
<start_addr> starting address
<count> quantity of registers
<reg_val> an array to hold register values
Output: none
Return:
0 for success, negative value for failure from API, and positive value for failure
from MODBUS TCP server
-1 argument error
-2 failed to send MODBUS TCP request to MODBUS TCP server
-3 failed to receive MODBUS TCP response from MODBUS TCP server
-4 disconnection with MODBUS TCP server
-5 illegal MODBUS TCP response message received
-6 unexpected MODBUS TCP response message received
1 bad function code
2 address out of range
3 bad write count or bad write value
4 internal gateway failure
6 unable to accept the MODBUS request
Programs that use the API functions must follow the proper usage. To begin with, call mbtcp_init()
once to initialize the MODBUS TCP connection environment. Next, call mbtcp_connect() to
create a MODBUS TCP connection handler and connect to the MODBUS TCP server. Then, call
mbtcp_read_regs() and mbtcp_write_regs() to read register values and write register values,
respectively. Before the program exits, call mbtcp_disconnect() to close its MODBUS TCP
connection and destroy the specified connection handler, and then call mbtcp_release() to release
the MODBUS TCP connection environment. The API functions cannot be used by multiple
threads at the same time.

Содержание

Похожие устройства

Скачать