61 lines
1.3 KiB
Plaintext
61 lines
1.3 KiB
Plaintext
/*@!Encoding:1252*/
|
|
|
|
includes
|
|
{
|
|
#include "EilDllCommon.cin"
|
|
#include "ModbusClientCommon.cin"
|
|
}
|
|
|
|
void ModbusConnectTo(char Remote_IP[], word Remote_Port)
|
|
{
|
|
EilConnectTo(Remote_IP, Remote_Port);
|
|
}
|
|
|
|
void ModbusConnectTo(dword Remote_IP, word Remote_Port)
|
|
{
|
|
EilConnectTo(Remote_IP, Remote_Port);
|
|
}
|
|
|
|
byte ModbusSnd(byte buffer[], word length)
|
|
{
|
|
return EilSnd(buffer, length);
|
|
}
|
|
|
|
void ModbusRecv()
|
|
{
|
|
EilRecv();
|
|
}
|
|
|
|
void ModbusDisconnect()
|
|
{
|
|
EilDisconnect();
|
|
}
|
|
|
|
long ModbusGetLastConnectionError(char string[])
|
|
{
|
|
return EilGetLastConnectionError(string);
|
|
}
|
|
|
|
void OnEthReceivePacket(long channel, long dir, long packet)
|
|
{
|
|
|
|
if (dir == TX)
|
|
return;
|
|
|
|
if (EthGetTokenInt(packet, "arp", "protSourceAddr") == gRemoteIP) // this was our ARP package
|
|
{
|
|
if (EthGetTokenData(packet, "arp", "hwSourceAddr", elCount(gRemoteMac), gRemoteMac) == 6)
|
|
{
|
|
gtArp.Cancel();
|
|
writeDbg(ConnDebug, "Remote Mac: %02X:%02X:%02X:%02X:%02X:%02X", gRemoteMac[0], gRemoteMac[1], gRemoteMac[2], gRemoteMac[3], gRemoteMac[4], gRemoteMac[5]);
|
|
EilConnectTo2(); // create the UDP package
|
|
ModbusStartQueue();
|
|
}
|
|
return;
|
|
}
|
|
|
|
if (EthGetTokenInt(packet, "ipv4", "protocol") == 0x11 && EthGetTokenInt(packet, "ipv4", "source") == gRemoteIP) // if this is a UDP package from our server
|
|
{
|
|
OnModbusReceive2(packet);
|
|
}
|
|
} |