int __stdcall SM_Open ( SM_HANDLE *  handle,
char *  connection 
)

Opens a connection to a Sealevel I/O module.

Parameters
[out]handleSeaMAX handle. This integer will be filled with a valid handle for future SeaMAX operations after a successful open.
[in]connectionString representing the connection to open. For Modbus TCP, the ":502" does not have to be specified.
Return values
0Success.
-1Parameter 'connection' is null.
-2Could not determine connection type.
-3Invalid connection string.
-10Serial: Invalid or unavailable serial connection.
-11Serial: Unable to acquire a valid mutex.
-12Serial: Unable to set serial timeouts.
-13Serial: Unable to set serial parameters (e.g. baudrate, parity, etc.).
-14Serial: Invalid serial name parameter.
-20Ethernet: Could not resolve host address.
-21Ethernet: Host refused or unavailable.
-22Ethernet: Could not acquire free socket.
-23Ethernet: Could not acquire a valid mutex.
-30SeaDAC Lite: Invalid or unavailable port
-31SeaDAC Lite: Unable to acquire a mutex handle
-32SeaDAC Lite: Invalid device number (should be zero or greater). Object invalid.
-33SeaDAC Lite: Could not read Vendor ID
-34SeaDAC Lite: Could not read Product ID
-40Could not read USB device product or vendor ID.
-41Non-Sealevel USB device.
-42SeaMAX does not support this Sealevel USB device.

The connection parameter can be in many different forms. For instance, a COM based product such as a SeaI/O module can be opened with a connection string of the form "COMx" or "\\.\COMx". For an Ethernet connection, such as the SeaI/O E or W series module, a connection string formatted as "x.x.x.x:y" for a dotted notation socket and port connection, or "x:y" for a host name and port will suffice. If the 'y' (TCP/IP port) part of the connection is not specified, the default Modbus TCP port of 502 will be selected as default.

For example, "COM3" or "\\.\COM47" is appropriate for a serial connection, while "10.0.0.1" is appropriate for a socket-based connection.

Note
For Modbus compliant devices (such as the SeaI/O modules), a default slave ID of 247 is used for all SeaMAX functions. To read, write, or configure a module at an address other than 247, please refer to the SM_SelectDevice() function for more details.
A default local COM port baudrate of 9600 bps is chosen for any serial connection. If your I/O device communicates at a rate other than this, please use the SM_ConfigureSerialConnection().

For a SeaDAC Lite model device, the connection string should be formatted as "SeaDAC Lite x" where x is a number. Care should be taken to check to ensure that the device could be opened. For instance, assuming a PC has a SeaDAC Lite device installed, "SeaDAC Lite 0" would open the first one available.

Note
The connection parameter string is case sensitive. Some attempt at parameter checking is made, but it is probable that a malformed string will be successfully added as a TCP/IP connection. Therefore, care should be taken to ensure proper string formatting when opening connections.
Warning
The handle returned by SM_Open is not compatible with any of the other SeaMAX modules such as the SME (Ethernet Configuration) module or the SeaDAC SDL module. Only functions beginning with SM_ should use the handle returned by SM_Open().

References SM_ConfigureSerialTimeouts().

Referenced by CSeaMaxW32::Open().

 
 
Generated on Mon Nov 26 2018.