I have a problem using ethernet connection with a plc:
My software is working great but if I disconnect and reconnect ethernet cable, program crash.
How can I resolve this problem?
The code is something like this:
fds.rfd=openSocket(102, ip.ascii());
fds.wfd=fds.rfd;
di =daveNewInterface(fds,"IF1",0, daveProtoISOTCP, daveSpeed187k);
res =daveInitAdapter(di);
dc =daveNewConnection(di, 0, 0, 2);
res =daveConnectPLC(dc);
The TCP-connection can't be kept when the cable is disconnected, but with the return-code of daveReadBytes you can detect that there is a failure, and you can try to reconnect until the connection is up again.
Axel
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Luca_TGMX (luca_tgmx@jabber.org)
I have a problem using ethernet connection with a plc:
My software is working great but if I disconnect and reconnect ethernet cable, program crash.
How can I resolve this problem?
The code is something like this:
fds.rfd=openSocket(102, ip.ascii());
fds.wfd=fds.rfd;
di =daveNewInterface(fds,"IF1",0, daveProtoISOTCP, daveSpeed187k);
res =daveInitAdapter(di);
dc =daveNewConnection(di, 0, 0, 2);
res =daveConnectPLC(dc);
while(1)
{
if(daveReadBytes(dc, daveDB, NUM_DB, DE_FINE_DEPOSITO, 2, NULL)==0)
{
b=daveGetU8(dc);
c=daveGetU8(dc);
}
if(b==0 && c==0)
break;
usleep(100000);
}
THANKS.
Il problema riguarda la libreria LIBNODAVE...
dovresti fare un debug in c++
I have the same problem. I tried everything but I couldn't solve it
The TCP-connection can't be kept when the cable is disconnected, but with the return-code of daveReadBytes you can detect that there is a failure, and you can try to reconnect until the connection is up again.
Axel
Luca_TGMX (luca_tgmx@jabber.org)
I've done this but during reconnection I also must call "close(fds.rfd)" to free the socket because it's not enought to call:
daveDisconnectPLC(dc);
daveDisconnectAdapter(di);
Can u tell me why?