dnsDeviceAdd

dnsDeviceAdd — adds a device configuration to the dnscan device list.

Synopsis

(dnsDeviceAdd card_id DeviceMacId [OutputSize InputSize
              [OutputOfs InputOfs [MsgSize [ConnectionType]]]])
	

Parameters

card_id
The target card ID (0..3).
DeviceMacId
The device MAC ID.
OutputSize
The size of the output data block.
[Note]

If OutputSize is not specified or is negative, the driver will automatically probe the specified device and determine the size required for a polled connection type.

InputSize
The size of the input data block.
OutputOfs
The offset of the output data block for the device relative to the beginning of the overall output data block (for all devices). If not specified or 0, then the offset is automatically calculated to follow the device data blocks assigned so far.
[Note]

Since the device data blocks must be aligned on 16-bit word boundaries, both the output and input offsets (OutputOfs and InputOfs) must be even-valued numbers, and will be incremented to the next word boundary if they are not. If either one of the offsets are not specified, both of them will be automatically calculated (see Description), based on the offsets and sizes of the data blocks of the previously allocated device (if any). And if, in that case, the resulting offsets are not even-valued, then they are incremented to the next word boundary.

InputOfs
The offset of the input data block for the device relative to the beginning of the overall input data block (for all devices). If not specified or 0, then the offset is automatically calculated to follow the device data blocks assigned so far.
MsgSize
The size of the explicit message buffer to be used, if the CONN_FLAG_EX connection flag is specified. The message data size available will be this value minus 8. If not specified or 0, then the default value of 64 is used. The buffer size can also be pre-specified through the bufferInit command.
ConnectionType
(Optional) The type of connection(s) to this device. If not specified, then only a polled I/O connection is established. The connection type is a combination of the flags (below). Only one of the 4 I/O connection flags should be specified. The type can be specified as a number or as a simple Lisp expression, such as for example, (bor CONN_FLAG_P CONN_FLAG_EX) to configure for simultaneous polled I/O connection and explicit messaging. The default connection type is CONN_FLAG_P.

Table 2. ConnectionType flags

ValueNameDescription
0x01CONN_FLAG_EXExplicit messaging connection(s)
0x02CONN_FLAG_PPolled I/O connection
0x04CONN_FLAG_STBit-strobed I/O connection
0x10CONN_FLAG_COSChange-of-state I/O connection
0x20CONN_FLAG_CYCCyclic I/O connection
0x40CONN_FLAG_AKSAcknowledge suppress

Returns

If the device is successfully added to the device list, then:

(dnsDeviceAdd card_id DeviceMacId)

or, if an error is detected, then one of:

(error "dnsDeviceAdd DR_ERR_CARD_INVALID (time) invalid card: card_id")
(error "dnsDeviceAdd DR_ERR_NO_CARD (time) card not available")
(error "dnsDeviceAdd DVN_ERR_CMD_ERR_DUPMAC (time) Cmd: Duplicate MAC ID")
(error "dnsDeviceAdd DVN_ERR_CMD_ERR_CONNECTION_FLAG (time) Cmd: Invalid connection flags")
(error "dnsDeviceAdd DVN_ERR_CMD_TIMEOUT (time) Cmd failed (timeout)")

Description

This command adds a device configuration to the device list. If scanning is active, or when it becomes active, connections to the client are created and the device is scanned. The input and output data (connection) sizes must correspond to that defined by the device. The connection type must also be supported by the device.

The card transfers the device data to/from internal card buffers. The driver transfers data between the card and its own internal buffers, specifically the DEV_BUF_INPUT and DEV_BUF_OUTPUT buffers.

The optional parameters OutputOfs and InputOfs define the starting offset of the corresponding block of device data within these buffers. If not specified or 0, the driver will automatically calculate offsets, sequentially locating the blocks of device data (of size OutputSize or InputSize, respectively). This automatic allocation has the drawback that the offsets will change whenever the size of field devices are changed, making it necessary to change accordingly the address of the field data points. The OutputOfs and InputOfs parameters can be used to eliminate this problem, allowing you to specify the location of blocks of device data within the input or output data buffers, effectively 'reserving' space between devices. Note that the offsets are relative to the driver's data buffer, and are not the internal card memory offsets actually used. The assigned offsets can be determined with the dnsDeviceGet command.

Examples

  1. This example queries the device with MAC ID 2 to determine the connection sizes and establish a polled connection. The I/O data blocks are automatically mapped to follow previously added device blocks.
    (dnsDeviceAdd 0 2)
  2. This example queries the device with MAC ID 2 to determine the I/O connection sizes, map the output and input data to offset 0x100 of their respective buffers, and establish a polled I/O connection.
    (dnsDeviceAdd 0 2 -1 0 0x100 0x100)
  3. This example queries the device with MAC ID 2 to determine the I/O connection sizes, map the output and input data to follow previously allocated device blocks, and establish both polled I/O and explicit messaging connections.
    (dnsDeviceAdd 0 2 -1 0 0 0 0 (bor CONN_FLAG_EX CONN_FLAG_P))