Opens a secure 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 successful open. |
[in] | connection | String representing the connection to open. For Modbus TCP, the ":502" does not have to be specified. |
[in] | securityMode | Type of encryption to use. |
[in] | securityKey | C String representing the encryption key in hexadecimal characters |
- Return values
-
0 | Success. |
-1 | Parameter 'connection' is null. |
-2 | Could not determine connection type. |
-3 | Invalid connection string. |
-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. |
-24 | Ethernet: Unknown error establishing connection. |
-25 | Ethernet: Invalid key. |
-26 | Ethernet: Unable to load cbx_enc_2_1.dll. |
This method establishes an Ethernet connection, such as the SeaI/O E or W series module, and 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 is required for the connection parameter. 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, the connection string "10.0.0.1" will establish a socket-based connection on port 502 with a device having the IP Address "10.0.0.1".
For securityMode values, see Security Type.
The securityKey parameter must include a C String (null terminated) containing two hexadecimal characters per byte of encryption. For example, an AES 256 key would be represented as 64 hexadecimal characters: "0102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20".
- 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.
- Warning
- The handle returned by SM_OpenSecure 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_OpenSecure().