Back to Sealevel      

int SM_Open ( SM_HANDLE *  handle,
char *  connection 
)

Opens a connection to a Sealevel I/O module.

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

 
 
Generated on 18 Sep 2007.