X hits on this document

106 views

0 shares

0 downloads

0 comments

33 / 37

MODBUS Communications Driver - Functions

ReadOutputStatus: Read Output Status

SYNOPSIS

short status = MB_ReadOutputStatus(short Address, long Start, short Count, short Values[]);

status Address Start Count Values

Error Return Destination Device Address Starting Coil Number Number of Coils to Read Return Array

Integer Integer Long Integer Integer < 1950 Integer Array

DESCRIPTION

This function reads the status of Output Coils (address 0xxxx) on the MODBUS device. The coil status values are returned in a "packed" format, with each bit in the return array corresponding to one output coil. If the number of coils requested is not evenly divisible by 16, unused return array bits will be set to 0.

The MODBUS Driver allows you to read up to 1950 bits in one operation, but your MODBUS device may have a lower transaction length limit.

EXAMPLE

short bits[10];

// Return value array

short status = MB ReadOutputStatus(12, 20, 23, bits);

_

if (status != 0) MessageBox(NULL, MB ErrorString(status), MB_OK); _

"ReadOutputStatus Error",

This example reads a total of 23 bits starting at Output Coil Number 20 from the MODBUS device with address 12. In the return array bits, element 0 will contain the current values of coils 20 - 35, with Bit 0 (the LSb) corresponding to Coil 20 and Bit 15 (the MSb) corresponding to Coil 35. Element 1 of bits will contain Coils 36 - 42, with Bit 0 for Coil 36, Bit 7 for Coil 42, and Bits 8

  • -

    15 set to 0.

If the function fails, the code sample displays an error Message Box, getting a string equivalent for the error code using the MB_ErrorString function.

Revision 2.210

June 6, 1998

Page 25

Document info
Document views106
Page views108
Page last viewedSat Dec 10 11:00:18 UTC 2016
Pages37
Paragraphs781
Words6172

Comments