libnodave test program

A

Thread Starter

Andres

Hello,

I am using one of the test programs from the libnodave (testISO_TCP) files to connect, read, and write to a PLC. I am trying to find a way to keep the code from ever crashing while I am running it. This is to keep any interruption from happening as the computer and PLC communicate. Any help regarding how to do this is greatly appreciated. Thank you,

Andres
 
Check the return values:

See: nodave.c
int DECL2 daveReadBytes(daveConnection * dc,int area, int DBnum, int start,int len, void * buffer)
 
>Check the return values:
>
>See: nodave.c
>int DECL2 daveReadBytes(daveConnection
>* dc,int area, int DBnum, int start,int
>len, void * buffer)

Okay. Can I just wrap that code around a while loop to keep it re-connecting all the time?
 
>>Okay. Can I just wrap that code around
>a while loop to keep it re-connecting
>all the time?

Check the sourcecode.
The connect() call to the socket library is only within the file openSocket.c
If you grep for "openSocket(" you find out that it is only used within the test programs.

Thus you would have to do something like that:<pre>
while(1)
{
fds.rfd=openSocket(102, argv[adrPos]);
if(fds.rfd > 0)
{
// do the communication
// until an error is returned
}
else
{
sleep(some_time);
}
}</pre>
PS: I say the above after looking to the sourcecode of libnodave
 
Top