IEC 61131-3 C Tools User Manual


Add to my manuals
501 Pages

advertisement

IEC 61131-3 C Tools User Manual | Manualzz

IEC 61131-3 C Tools Function Specifications

ioBusReadMessage

Read Message from I

2

C Slave Device

Syntax

#include <ctools.h>

READSTATUS ioBusReadMessage(unsigned address, unsigned

numberBytes, unsigned char *message);

Description

The ioBusReadMessage function reads a specified number of bytes from an I

2

C slave device.

The function issues a START condition, selects the device for reading, reads the specified number of bytes, and issues a STOP condition. It detects if the device cannot be selected and, if so, aborts the read.

The function has three parameters: the address of the device; the number of bytes to read, numberBytes; and a pointer to a buffer, message, capable of holding the data read.

The function returns the status of the read:

Value

RS_success

RS_selectFailed

Description

read was successful slave device could not be selected

Notes

The IO_SYSTEM resource needs to be requested before calling this function.

See Also

ioBusWriteMessage, ioBusStart, ioBusStop, ioBusReadByte

ioBusReadLastByte, ioBusSelectForRead ioBusSelectForWrite,

ioBusWriteByte, ioBusWriteMessage

Example

#include <ctools.h> void main(void)

{ unsigned char message[10]; unsigned char ioBusAddress = 114;

READSTATUS status; request_resource(IO_SYSTEM);

/* Read a 10 byte message from I2C device */ status = ioBusReadMessage(ioBusAddress, 10, message); release_resource(IO_SYSTEM);

Document (Version 2.50) 5/12/2011 262 262

}

IEC 61131-3 C Tools Function Specifications if (status != RS_success)

{ fprintf(com1, "I/O error = %d\n\r", status);

}

Document (Version 2.50) 5/12/2011 263 263

advertisement

Was this manual useful for you? Yes No
Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Related manuals

advertisement

Table of contents