| Customize Help
| Save Settings

McomWrite



Function Map
Synopsis
Write data to a device that uses the specified communication protocol.
Syntax
void McomWrite(
MIL_ID ComId, //in
MIL_CONST_TEXT_PTR DataObjectEntryName, //in
MIL_INT Offset, //in
MIL_INT Size, //in
const void *UserArrayPtr //in
)
Description

This function writes data to a device that uses the specified communication protocol. In most cases, this function actually writes to the local computer's memory, the data to send to a controller (e.g. a PLC) during the controller's next read cycle. However, when communicating with the device using the Modbus protocol in master configuration, or writing configuration data to an EtherNet/IP device explicitly, this function can write the data directly to the device's memory.

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

A controller that uses the Modbus protocol reads data from the local computer, from data tables in local memory, when the local computer is in a slave configuration. To write to a Modbus device (either in a slave or master configuration), you must specify the data table in which to write. Note that when the local computer is configured as a master, you can only write to the coil or holding register data tables of a slave device.

A controller that uses the EtherNet/IP protocol reads data from the local computer, from a producer assembly in local memory. As such, to send data to an EtherNet/IP controller, specify to write to the producer assembly in local memory. You can also write to a configuration assembly. When writing to a configuration assembly, you are writing EtherNet/IP configuration data in local memory about the local computer.

For EtherNet/IP, you can also specify to write explicitly to another device on the network. However, this method is slower than using implicit messaging. You should only use explicit messaging for data that is not time critical; typically, this means only writing data to the configuration assemblies of other devices.

A controller that uses the CC-Link IE Field Basic protocol reads data from the local computer, from register and flag data tables in local memory. As such, to send data to a CC-Link controller, you must specify whether to write 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_INSIZE, M_COM_ETHERNETIP_PRODUCER_SIZE to establish the size of the input module, or assembly, respectively, from which the controller can read. 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 (RWr) or flags (RX) from which the controller can read, multiply the number of stations by 32 or 64 respectively.

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 in which to write the data. This location is protocol specific. This parameter must be set to one of the following.

When writing to 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 write in PROFINET
Click to summarizeValue Description MIL system-specific
tooltip (‡)
Click to summarize MIL_TEXT("mcom://ModuleIndex") 1

Specifies the location in local memory in which to write the data to send to a controller. Replace ModuleIndex with the index of the input module in local memory in which to write 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 writing to a device (controller) 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 write in Modbus
Click to summarizeValue Description MIL system-specific
tooltip (‡)
Click to summarize M_COILS

Specifies to write to the coils data table in local memory the data to send to the Modbus controller.

a t
U28
w
U53
Click to summarize M_DISCRETE_INPUT

Specifies to write to the discrete input data table in local memory the data to send to the Modbus controller.

a t
U28
w
U53
Click to summarize M_HOLDING_REGISTER

Specifies to write to the holding register data table in local memory the data to send to the Modbus controller.

a t
U28
w
U53
Click to summarize M_INPUT_REGISTER

Specifies to write to the input register data table in local memory the data to send to the Modbus controller.

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

Specifies to write to the coils 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 write to 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

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

When writing to a device (typically a controller) that uses the EtherNet/IP protocol (McomAlloc() with M_COM_PROTOCOL_ETHERNETIP), use one of the following to specify the location.

function map For specifying the path of the data to write in EtherNet/IP
Click to summarizeValue Description MIL system-specific
tooltip (‡)
Click to summarize M_COM_ETHERNETIP_CONFIG

Specifies to write EtherNet/IP configuration data about the local computer to the configuration assembly in local memory.

a t
U28
w
U53
Click to summarize M_COM_ETHERNETIP_PRODUCER

Specifies to write data to the producer assembly in local memory to send the data to the Ethernet/IP controller.

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

Specifies the slave device on the network and the assembly in which to write 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 write to a particular device's specified assembly. While this is supported in MIL, this method will be slower than using implicit messaging. Therefore, in theory, this method should only be used to write configuration data to another slave device on the network.

(summarize)
a t
U28
w
U53

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

When writing to a device (controller) that uses the CC-Link IE Field Basic protocol (McomAlloc() with M_COM_PROTOCOL_CCLINK), use one of the following to specify the location.

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

Specifies to write the data to the input flag (RX) data table in local memory to send the data to the CC-Link IE field basic controller.

a t
U28
w
U53
Click to summarize M_COM_CCLINK_INPUT_REGISTER

Specifies to write the data to the input register (RWr) data table in local memory to send the data to the CC-Link IE field basic controller.

a t
U28
w
U53
Offset

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

Size

Specifies the size of the data to be written. 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 containing the data.

When writing 1-bit data, the array must contain one byte for each bit that is read. The values to write must be stored in the least-significant bit of each byte.

When writing 16-bit data, the array must contain two bytes for each 16-bit word that is written. The values to write must be 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" HOLDING REGISTER" COM ETHERNETIP CONFIG COM ETHERNETIP PRODUCER COM CCLINK INPUT FLAG COM CCLINK INPUT REGISTER COM PROTOCOL PROFINET COM PROTOCOL MODBUS COM PROTOCOL ETHERNETIP COM PROTOCOL CCLINK