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