Host Engineering Forum
General Category => Ethernet SDK => Topic started by: chris.zeman on July 02, 2007, 07:20:46 PM
-
I am trying to compile the Linux Ethernet SDK, but I'm having some trouble. I was able to do this about 18 months ago, and I remember having a little bit of trouble back then, too. I had some help from another gentleman from the forums at Automation Direct through direct e-mail, but figured I'd post this here so whatever the solution may be is available to anyone.
I was able to work around this issue by uploading the source to a directory to one of my web host's servers and compiling it there. I then copied the files to my server and ran make install.
root@automation:~/ad/library# make
gcc -fPIC -g -c -Wall -DHEIUNIX intrface.c
In file included from intrface.c:16:
../headers/defs.h:16:1: warning: "ULONG_MAX" redefined
In file included from /usr/include/bits/socket.h:31,
from /usr/include/sys/socket.h:35,
from /usr/include/netinet/in.h:24,
from intrface.c:9:
/usr/lib/gcc/i486-linux-gnu/4.1.2/include/limits.h:89:1: warning: this is the location of the previous definition
intrface.c: In function âHEIIOpenDeviceâ:
intrface.c:165: warning: unused variable âNonBlockingModeâ
intrface.c: In function âHEIIReceivePacketâ:
intrface.c:340: warning: pointer targets in passing argument 6 of ârecvfromâ differ in signedness
gcc -fPIC -g -c -Wall -DHEIUNIX hei_ext.c
hei_ext.c: In function âHEIReadIOExâ:
hei_ext.c:167: warning: statement with no effect
hei_ext.c: In function âHEIWriteIOExâ:
hei_ext.c:299: warning: statement with no effect
gcc -fPIC -g -c -Wall -DHEIUNIX hei.c
hei.c: In function âWPLCSetOSLoadâ:
hei.c:2800: warning: large integer implicitly truncated to unsigned type
hei.c: In function âWPLCRebootâ:
hei.c:2819: warning: large integer implicitly truncated to unsigned type
hei.c: In function âHEIRebootâ:
hei.c:2836: warning: large integer implicitly truncated to unsigned type
gcc -fPIC -g -c -Wall -DHEIUNIX iobase.cpp
In file included from ../headers/hei.h:11,
from ../headers/stdafx.h:18,
from iobase.cpp:1:
../headers/defs.h:32:1: warning: "NULL" redefined
In file included from /usr/include/stdlib.h:33,
from ../headers/stdafx.h:17,
from iobase.cpp:1:
/usr/lib/gcc/i486-linux-gnu/4.1.2/include/stddef.h:400:1: warning: this is the location of the previous definition
../headers/iobase.h:13: error: extra qualification âCModule::â on member âIsSupportedâ
iobase.cpp: In constructor âCEbcIO::CEbcIO(HEIDevice*, BOOL)â:
iobase.cpp:180: warning: unused variable âModuleCountâ
make: *** [iobase.o] Error 1
root@automation:~/ad/library#
root@automation:~/ad/library# gcc --version
gcc (GCC) 4.1.2 (Ubuntu 4.1.2-0ubuntu4)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
root@automation:~/ad/library#
The computer this program will be running on has two network cards. One is connected to a 5-port switch on a cable modem, and the other is connected to my LAN. There is a PLC on the "internet" side of the server, and my network has about 10 PLC's on it. I have a test program that was given to me that searches the network for ECOM's and lists them. The program is only searching for devices on the one interface. Is there something I can do to make it search the other?
#include <sys/time.h>
#include <netinet/in.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <memory.h>
#include <strings.h>
#include <string.h>
#include "defs.h"
#include "hei.h"
#define MAX_DEVICES 16
int main(int argc, char *argv[])
{
WORD Protocol = HEIP_IP;
BYTE Data[2000];
BYTE NumToSend[2];
BYTE NumToSend2[4];
HEITransport TP;
HEIDevice aDevices[MAX_DEVICES];
WORD DeviceCount=1;
memset(aDevices, 0, sizeof(aDevices));
memset(&TP, 0, sizeof(TP));
/*
** Step 1, initialize the driver
** Called once by app at startup
*/
HEIOpen(HEIAPIVERSION);
printf ("Initialized...\n");
/*
** Step 2, initialize the transport
*/
TP.Transport = HEIT_UNIX; // Under Unix this is the only valid transport
TP.Protocol = Protocol;
/* 2a get the devices */
HEIQueryDevices(&TP, aDevices, &DeviceCount, HEIAPIVERSION);
printf ("Device Count: %3d\n",DeviceCount);
if(!HEIOpenDevice(&TP, &aDevices[0], HEIAPIVERSION, 25, 3, FALSE)) {
printf ("device opened...\n");
printf("open device: %02X%02X%02X%02X%02X%02X\n",
aDevices[0].ENetAddress[0], aDevices[0].ENetAddress[1], aDevices[0].ENetAddress[2],
aDevices[0].ENetAddress[3], aDevices[0].ENetAddress[4], aDevices[0].ENetAddress[5]);
// set values to a default to see if they are changing
HEICCMRequest(&aDevices[0],FALSE,0x31,0x0802,2,Data);
//printf ("HEIRead return value %d\n",tmp);
printf ("value = %02X%02X\n",Data[1],Data[0]);
// if (argv[1] == "center")
// write data
NumToSend[0] = 68; NumToSend[1] = 00; // sends 68 (two bytes) 00 then 68 sends 17408
// to send to v4000 use x801
HEICCMRequest(&aDevices[0],TRUE,0x31,0x801,2,NumToSend); //printf ("X1 = %02X\n",argv[0]);
// for control relays each byte of data operates 8 relays (255 turns all 8 on, 0,1=c0,2=c1,3=c0andc1 etc)
NumToSend2[0] = 2; NumToSend2[1] = 0;
NumToSend2[2] = 0; NumToSend2[3] = 0;
HEICCMRequest(&aDevices[0],TRUE,0x033,0x199,1,NumToSend2); //printf ("X1 = %02X\n",argv[0]);
HEICCMRequest(&aDevices[0],FALSE,0x033,0x102,1,Data); printf ("%02X\n",Data[0]);
/* Data[0] = 0x07; */
} else {
printf ("device NOT opened...\n");
printf("Error! Unable to open device %02X%02X%02X%02X%02X%02X\n",
aDevices[0].ENetAddress[0], aDevices[0].ENetAddress[1], aDevices[0].ENetAddress[2],
aDevices[0].ENetAddress[3], aDevices[0].ENetAddress[4], aDevices[0].ENetAddress[5]);
}
HEICloseDevice(&aDevices[0]);
HEICloseTransport(&TP);
HEIClose();
return (Data[0]);
}
Thanks,
Chris
-
Hi Chris
Do not know if your still looking at this issue, but I have patched source code which compiles for current linux distros, along with the beginnings of a python wrapper.
If your still interested I could post this work.
Mike
-
..edit..
I addressed a similar problem by including the other interface(s) in the broadcasting with:
route add -host 255.255.255.255 dev <alt_iface>
Here is the three-packet transaction:
1. starting with the packet sent by _SendPacket in hei.c
21:59:26.402567 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 38) 192.168.1.5.32848 > 255.255.255.255.28784: [udp sum ok] UDP, length 10
0x0000: 4500 0026 0000 4000 4011 791a c0a8 0105 E..&..@.@.y.....
0x0010: ffff ffff 8050 7070 0012 646e 4841 5001 .....Ppp..dnHAP.
0x0020: 00a5 5001 0005 ..P...
2. then H2-ECOM100's response:
21:59:26.453397 IP (tos 0x0, ttl 255, id 0, offset 0, flags [DF], proto UDP (17), length 52) 192.168.1.40.28784 > 192.168.1.5.32848: [udp sum ok] UDP, length 24
0x0000: 4500 0034 0000 4000 ff11 f83a c0a8 0128 E..4..@....:...(
0x0010: c0a8 0105 7070 8050 0020 d0c1 4841 5001 ....pp.P....HAP.
0x0020: 0040 730f 0055 aa00 e062 20a1 3200 01c0 .@s..U...b..2...
0x0030: a801 2800 ..(.
3. and finally my returning a "port unreachable":
21:59:26.453456 IP (tos 0xc0, ttl 64, id 33546, offset 0, flags [none], proto ICMP (1), length 80) 192.168.1.5 > 192.168.1.40: ICMP 192.168.1.5 udp port 32848 unreachable, length 60
IP (tos 0x0, ttl 255, id 0, offset 0, flags [DF], proto UDP (17), length 52) 192.168.1.40.28784 > 192.168.1.5.32848: [udp sum ok] UDP, length 24
0x0000: 45c0 0050 830a 0000 4001 7365 c0a8 0105 E..P....@.se....
0x0010: c0a8 0128 0303 80ac 0000 0000 4500 0034 ...(........E..4
0x0020: 0000 4000 ff11 f83a c0a8 0128 c0a8 0105 ..@....:...(....
0x0030: 7070 8050 0020 d0c1 4841 5001 0040 730f pp.P....HAP..@s.
0x0040: 0055 aa00 e062 20a1 3200 01c0 a801 2800 .U...b..2.....(.
So the packets are getting out, but nothing seems to be listening for the responses. So EQ doesn't see any devices:
hal@gwen ~/ether_sdk/LinuxEtherSDK/apps $./eq
EtherQuery - Copyright(C) 1997, Host Engineering, Inc.
Queries for PLCDirect Ethernet products and displays configuration information
Sorry! No ethernet devices found
Has anyone else seen this?