Ethernet connection (tcp/ip)

Startup Ethernet connection

If you are going to use iqInterface over Ethernet/LAN connection you should once startup Ethernet communication beforehand using enet_Startup function declared in iqi_ethernet.h

enet_Startup(cpErrMsg);

At the end of Ethernet communication usage you can free OS resources bound to it calling enet_Cleanup function also declared in iqi_ethernet.h

enet_Cleanup(cpErrMsg);

comm_EthernetSearch (search iqInterface IP in LAN)

Function

int16 comm_EthernetSearch(enet_ConnectionT * pFoundConnections,  uchar08 ucMaxConnectionsNumber,  uchar08 * ucpFoundConnectionsNumber, uint16 uiSendRecvTimoutMs,  char08 *cpErrMsg);

Description

If you do not know the IP address you can try to search it using comm_EthernetSearch function declared in iqi_comm.h. Call it with a buffer to return found connections of type enet_ConnectionT, its size, a pointer to found connections number and send/receive timeout in milliseconds as arguments. The UDP protocol with port number 30718 is used to discover iqInterfaces in LAN. You can use the found connections further in mst_EthernetConnect or dev_EthernetConnect function to connect to found iqInterface.

Input Parameters

  • uchar08 ucMaxConnectionsNumber – size of connection buffer pFoundConnections

Output parameters:

  • enet_ConnectionT * pFoundConnections – pointer to buffer to return found connections of type “enet_ConnectionT”
  • uchar08 * ucpFoundConnectionsNumber – number of connections actually found and saved to buffer “pFoundConnections”
  • uint16 uiSendRecvTimoutMs – send/receive timeout used for UDP packets to discover iqInterfaces
  • char08 *cpErrMsg – pointer to buffer to return error message (minimum 256 bytes)

Return value

ERR_NONE or negative error number.

Example

enet_ConnectionT connections[5];
uchar08 ucFoundConnectionNumber = 0;
uint16 uiSendRecvTimoutMs = 500; // 0,5 sec
int16 iPortNo;
comm_EthernetSearch(connections, 5, &ucFoundConnectionNumber, uiSendRecvTimoutMs, cpErrMsg);
// inspect found connections: connections[0].cpIqInterfaceIpAddr …
uiSendRecvTimoutMs = 2000; // 2 sec
iPortNo = mst_EthernetConnect(&(connections[0]), uiSendRecvTimoutMs, cpErrMsg);
// or
iPortNo  = dev_EthernetConnect(&(connections[0]), uiSendRecvTimoutMs, cpErrMsg);

enet_ConnectionT (Ethernet connection type)

Fields

  • char08 cpIqInterfaceIpAddr[17] - ip address of iqInterface TCP connection over ethernet: “xxx.xxx.xxx.xxx” (string in dec format)
  • uint16 uiPort - port of iqInterface TCP connection over ethernet
  • char08 cpIqInterfaceMacAddr[19] - MAC address of iqInterface ethernet connection: “HH:HH:HH:HH:HH:HH” (string in hex format)
  • ulong64 ul64SerialNumber - serial number of iqInterface
  • char08 cpLocalIpAddr[17] - local (PC) ip address of network adapter in which subnet iqInterface is availiable