| Customize Help
| Save Settings

McomRead



Function Map
Synopsis
Read data from a device that uses the specified communication protocol.
Syntax
void McomRead(
MIL_ID ComId, //in
MIL_CONST_TEXT_PTR DataObjectEntryName, //in
MIL_INT Offset, //in
MIL_INT Size, //in
void *UserArrayPtr //out
)
Description

This function reads data from a device that uses the specified communication protocol. In most cases, this function actually reads the local computer's memory for data received from a controller (e.g. a PLC) during the controller's last write cycle. However, when communicating with the device using the Modbus protocol in master configuration, or reading configuration data from an EtherNet/IP device explicitly, this function can read the data directly from the device's memory. This function can also read the data last written to local memory using McomWrite().

A controller that uses the PROFINET protocol writes data to the local computer in modules in local memory. As such, you must specify the module's index from which to read the received data.

A controller that uses the Modbus protocol writes data to the local computer in data tables in local memory, when the local computer is in a slave configuration. To read from a Modbus device (either in a slave or master configuration), you must specify the data table from which to read.

A controller that uses the EtherNet/IP protocol writes data to the local computer, typically, in the consumer assembly in local memory. As such, to read data received from an EtherNet/IP controller, specify to read from the consumer assembly in local memory. You can also read from the producer or configuration assembly in local memory. When reading from a producer assembly, you are reading your own published data in local memory. When reading from a configuration assembly, you are reading EtherNet/IP configuration data in local memory about the local computer. Note that you can also specify another device on the network from which to read data explicitly, although this should only be used to read configuration data.

A controller that uses the CC-Link IE Field Basic protocol writes data to the local computer, in register and flag data tables in local memory. As such, to read data received from a CC-Link controller, you must specify whether to read the data in the flags or registers data table. The local computer can only be configured as a slave device.

For PROFINET and EtherNet/IP, use McomInquire() with M_COM_PROFINET_GET_MODULE_OUTSIZE or M_COM_ETHERNETIP_CONSUMER_SIZE to establish the size of the output module, or assembly, respectively, to which the controller has written. You must know how the module/assembly is divided into fields.

For CC-Link IE Field Basic, use McomInquire() with M_COM_CCLINK_TOTAL_OCCUPIED_STATION to learn the number of stations used by the industrial protocol instance. To establish the number of registers (RWw) or flags (RY) to which the controller can write, multiply the number of stations by 32 or 64 respectively.

If the time to execute this function is greater than the value set using McomControl() with M_COM_TIMEOUT, an error occurs.

This function is only available if you have the MIL Industrial Communication package, or another relevant update installed.

Note that this function reference has not been updated for a MIL system added during a MIL update. Refer to the MIL system's release note to see which MIL system’s documentation you should use in its place and any possible differences.
Parameters
This function is not supported on the selected boards.
This function reference has not been updated for the selected MIL system. To show the content of this page, choose a second MIL system; refer to the MIL system's release note to see which MIL system’s documentation to choose and any possible differences.
Parameters
ComId

Specifies the identifier of the Industrial Communication context that specifies the protocol of the device with which to communicate.

DataObjectEntryName

Specifies the location from which to read the data. This location is protocol specific. This parameter must be set to one of the following.

When reading from a device (controller) that uses the PROFINET protocol (McomAlloc() with M_COM_PROTOCOL_PROFINET), use the following format to specify the location.

function map For specifying the path of the data to read in PROFINET
Click to summarizeValue Description MIL system-specific
tooltip (‡)
Click to summarize MIL_TEXT("mcom://ModuleIndex") 1

Specifies the location in local memory from which to read the data received from a controller. Replace ModuleIndex with the index of the module in local memory from which to read the data. ModuleIndex can be from 0 to 255.

(summarize)
a t
U28
w
U53
MIL system specific

Note that the Host system is only supported on the Matrox 4Sight GPm and EV6 platforms. Support for the Matrox 4Sight EV6 platform requires driver update 93.

a

1 If you are passing the value in a variable, don't enclose it in MIL_TEXT().

When reading from a device (controller or slave automation device) that uses the Modbus protocol (McomAlloc() with M_COM_PROTOCOL_MODBUS), use the following format to specify the location.

function map For specifying the path of the data to read in Modbus
Click to summarizeValue Description MIL system-specific
tooltip (‡)
Click to summarize M_COILS

Specifies to read the coil data table in local memory for data received from a Modbus controller, or written by the last call to McomWrite() with M_COILS.

a t
U28
w
U53
Click to summarize M_DISCRETE_INPUT

Specifies to read the discrete input table in local memory for data written by the last call to McomWrite() with M_DISCRETE_INPUT.

a t
U28
w
U53
Click to summarize M_HOLDING_REGISTER

Specifies to read the holding register table in local memory for data received from a Modbus controller, or written by the last call to McomWrite() with M_HOLDING_REGISTER.

a t
U28
w
U53
Click to summarize M_INPUT_REGISTER

Specifies to read the input register table in local memory for data written by the last call to McomWrite() with M_INPUT_REGISTER.

a t
U28
w
U53
Click to summarize MIL_TEXT("mcom://SlaveId[@SlaveIP]/M_COILS") 1

Specifies to read the coil data table of a slave device, when the local computer is communicating using the Modbus protocol in master configuration.

Replace SlaveId with the slave device's identifier number.

If connecting to a slave device over the Modbus TCP protocol, also enter @ and replace [SlaveIP] with the slave device's IP address; the MIL Industrial Communication module supports IPv4 addresses. A typical IPv4 string has the format n.n.n.n, where n is a number between 0 and 255.

(summarize)
a t
U28
w
U53
Click to summarize MIL_TEXT("mcom://SlaveId[@SlaveIP]/M_DISCRETE_INPUT") 1

Specifies to read the discrete input data table of a slave device, when the local computer is communicating using the Modbus protocol in master configuration.

Replace SlaveId with the slave device's identifier number.

If connecting to a slave device over the Modbus TCP protocol, also enter @ and replace [SlaveIP] with the slave device's IP address; the MIL Industrial Communication module supports IPv4 addresses. A typical IPv4 string has the format n.n.n.n, where n is a number between 0 and 255.

(summarize)
a t
U28
w
U53
Click to summarize MIL_TEXT("mcom://SlaveId[@SlaveIP]/M_HOLDING_REGISTER") 1

Specifies to read the holding register data table of a slave device, when the local computer is communicating using the Modbus protocol in master configuration.

Replace SlaveId with the slave device's identifier number.

If connecting to a slave device over the Modbus TCP protocol, also enter @ and replace [SlaveIP] with the slave device's IP address; the MIL Industrial Communication module supports IPv4 addresses. A typical IPv4 string has the format n.n.n.n, where n is a number between 0 and 255.

(summarize)
a t
U28
w
U53
Click to summarize MIL_TEXT("mcom://SlaveId[@SlaveIP]/M_INPUT_REGISTER") 1

Specifies to read the input register data table of a slave device, when the local computer is communicating using the Modbus protocol in master configuration.

Replace SlaveId with the slave device's identifier number.

If connecting to a slave device over the Modbus TCP protocol, also enter @ and replace [SlaveIP] with the slave device's IP address; the MIL Industrial Communication module supports IPv4 addresses. A typical IPv4 string has the format n.n.n.n, where n is a number between 0 and 255.

(summarize)
a t
U28
w
U53

1 If you are passing the value in a variable, don't enclose it in MIL_TEXT().

When reading from a device (typically a controller) that uses the EtherNet/IP protocol (McomAlloc() with M_COM_PROTOCOL_ETHERNETIP), or when reading local memory for data written by the last call to McomWrite(), use one of the following to specify the location.

function map For specifying the path of the data to read in EthernetIP
Click to summarizeValue Description MIL system-specific
tooltip (‡)
Click to summarize M_COM_ETHERNETIP_CONFIG

Specifies to read the configuration assembly in local memory for EtherNet/IP configuration data typically written by the last call to McomWrite().

a t
U28
w
U53
Click to summarize M_COM_ETHERNETIP_CONSUMER

Specifies to read the consumer assembly in local memory for data received from an EtherNet/IP controller.

a t
U28
w
U53
Click to summarize M_COM_ETHERNETIP_PRODUCER

Specifies to read the producer assembly in local memory for data written by the last call to McomWrite().

a t
U28
w
U53
Click to summarize MIL_TEXT("mcom://[RemoteIP/]AssemblyID") 1

Specifies another slave device on the network and the assembly from which to read the data when communicating using the Ethernet/IP protocol.

Replace [RemoteIP] with the slave device's IP address; the MIL Industrial Communication module supports IPv4 addresses. A typical IPv4 string has the format n.n.n.n, where n is a number between 0 and 255.

This method uses explicit messaging to read from a particular device's specified assembly. While this is supported in MIL, this method will be slower than using implicit messaging. This should, in theory, only be used to read a configuration setting on the specified device.

(summarize)
a t
U28
w
U53

1 If you are passing the value in a variable, don't enclose it in MIL_TEXT().

When reading from a device (controller) that uses the CC-Link IE Field Basic protocol (McomAlloc() with M_COM_PROTOCOL_CCLINK), or when reading local memory for data written by the last call to McomWrite(), use one of the following to specify the location.

function map For specifying the path of the data to read in CC-Link IE Field Basic
Click to summarizeValue Description MIL system-specific
tooltip (‡)
Click to summarize M_COM_CCLINK_INPUT_FLAG

Specifies to read the input flag (RX) data table in local memory for data written by the last call to McomWrite().

a t
U28
w
U53
Click to summarize M_COM_CCLINK_INPUT_REGISTER

Specifies to read the input flag (RWr) data table in local memory for data written by the last call to McomWrite().

a t
U28
w
U53
Click to summarize M_COM_CCLINK_OUTPUT_FLAG

Specifies to read the output flag (RY) data table in local memory for data received from a CC-Link IE Field Basic master controller.

a t
U28
w
U53
Click to summarize M_COM_CCLINK_OUTPUT_REGISTER

Specifies to read the output register (RWw) data table in local memory for data received from a CC-Link IE Field Basic master controller.

a t
U28
w
U53
Offset

Specifies the offset from which to start reading the data in the specified module/data table/assembly. Typically, the offset is specified in bytes. The following exceptions apply:

Size

Specifies the amount of the data to read. Typically, the size is specified in bytes. The following exceptions apply:

UserArrayPtr
Accepts the following address:
  • Data type: address of a MIL_UINT8
    Required array size:(Size)

Specifies the address of the array in which to write the data.

When reading 1-bit data, the array contains one byte for each bit that is read. The read values are stored in the least-significant bit of each byte.

When reading 16-bit data, the array contains two bytes for each 16-bit word that is read. The read values are stored as byte pairs. The first byte is the most-significant byte of the word, the second byte is the least-significant byte of the word.

Compilation information
Header Include mil.h.
Library Use mil.lib; milcom.lib.
DLL Requires mil.dll; milcom.dll.
COM PROTOCOL PROFINET COM PROTOCOL ETHERNETIP COM PROTOCOL MODBUS COM PROTOCOL CCLINK COILS DISCRETE INPUT HOLDING REGISTER INPUT REGISTER COILS" DISCRETE INPUT" HOLDING REGISTER" INPUT REGISTER" COM ETHERNETIP CONFIG COM ETHERNETIP CONSUMER COM ETHERNETIP PRODUCER COM CCLINK INPUT FLAG COM CCLINK INPUT REGISTER COM CCLINK OUTPUT FLAG COM CCLINK OUTPUT REGISTER COM PROTOCOL PROFINET COM PROTOCOL MODBUS COM PROTOCOL ETHERNETIP COM PROTOCOL CCLINK