linux + va_args + float/double problem - using int now as workaround
This commit is contained in:
34
drvS7plcFW.c
34
drvS7plcFW.c
@ -1,7 +1,7 @@
|
|||||||
/* $Date: 2012/03/06 10:53:08 $ */
|
/* $Date: 2012/06/18 12:25:19 $ */
|
||||||
/* $Id: drvS7plcFW.c,v 1.2 2012/03/06 10:53:08 anicic Exp $ */
|
/* $Id: drvS7plcFW.c,v 1.3 2012/06/18 12:25:19 anicic Exp $ */
|
||||||
/* $Name: $ */
|
/* $Name: $ */
|
||||||
/* $Revision: 1.2 $ */
|
/* $Revision: 1.3 $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NOTE: s7plcFWwriteThread -is not used for writting (we write direct),
|
* NOTE: s7plcFWwriteThread -is not used for writting (we write direct),
|
||||||
@ -68,7 +68,7 @@
|
|||||||
#define RECONNECT_DELAY 10.0 /* delay before reconnect [s] */
|
#define RECONNECT_DELAY 10.0 /* delay before reconnect [s] */
|
||||||
|
|
||||||
static char cvsid[] __attribute__((unused)) =
|
static char cvsid[] __attribute__((unused)) =
|
||||||
"$Id: drvS7plcFW.c,v 1.2 2012/03/06 10:53:08 anicic Exp $";
|
"$Id: drvS7plcFW.c,v 1.3 2012/06/18 12:25:19 anicic Exp $";
|
||||||
|
|
||||||
STATIC long s7plcFWIoReport(int level);
|
STATIC long s7plcFWIoReport(int level);
|
||||||
STATIC long s7plcFWInit();
|
STATIC long s7plcFWInit();
|
||||||
@ -186,9 +186,9 @@ STATIC long s7plcFWIoReport(int level)
|
|||||||
"ioc:motorola <-> plc:intel" : "no (both motorola)"
|
"ioc:motorola <-> plc:intel" : "no (both motorola)"
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
printf(" receive timeout %g sec\n", station->recvTimeout);
|
printf(" receive timeout %d ms\n", (int)(station->recvTimeout * 1000.0));
|
||||||
printf(" receive delay %g sec\n", station->recvDelay);
|
printf(" receive delay %d ms\n", (int)(station->recvDelay * 1000.0));
|
||||||
printf(" outIOint delay %g sec\n", station->outIOintDelay);
|
printf(" outIOint delay %d ms\n", (int)(station->outIOintDelay * 1000.0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -452,8 +452,8 @@ STATIC void s7plcFWMain ()
|
|||||||
}
|
}
|
||||||
s7plcFWDebugLog(1, "s7plcFWMain %s: Connect to %s:%d on fetch socket %d\n", station->name, station->serverIP, station->fetchPort, station->fetchSocket);
|
s7plcFWDebugLog(1, "s7plcFWMain %s: Connect to %s:%d on fetch socket %d\n", station->name, station->serverIP, station->fetchPort, station->fetchSocket);
|
||||||
if (s7plcFWEstablishConnection(station, FOR_FETCH) < 0) {
|
if (s7plcFWEstablishConnection(station, FOR_FETCH) < 0) {
|
||||||
s7plcFWDebugLog(1, "s7plcFWMain %s: connect(%d, %s:%d) failed for fetch: %s. Retry in %g seconds\n",
|
s7plcFWDebugLog(1, "s7plcFWMain %s: connect(%d, %s:%d) failed for fetch: %s. Retry in %d ms\n",
|
||||||
station->name, station->fetchSocket, station->serverIP, station->fetchPort, strerror(errno), (double)RECONNECT_DELAY);
|
station->name, station->fetchSocket, station->serverIP, station->fetchPort, strerror(errno), (int)(RECONNECT_DELAY * 1000.0));
|
||||||
if (close(station->fetchSocket) && errno != ENOTCONN) {
|
if (close(station->fetchSocket) && errno != ENOTCONN) {
|
||||||
s7plcFWDebugLog(1, "s7plcFWMain %s: close(%d) failed for fetch (ignored): %s\n", station->name, station->fetchSocket, strerror(errno));
|
s7plcFWDebugLog(1, "s7plcFWMain %s: close(%d) failed for fetch (ignored): %s\n", station->name, station->fetchSocket, strerror(errno));
|
||||||
}
|
}
|
||||||
@ -476,8 +476,8 @@ STATIC void s7plcFWMain ()
|
|||||||
}
|
}
|
||||||
s7plcFWDebugLog(1, "s7plcFWMain %s: Connect to %s:%d on write socket %d\n", station->name, station->serverIP, station->writePort, station->writeSocket);
|
s7plcFWDebugLog(1, "s7plcFWMain %s: Connect to %s:%d on write socket %d\n", station->name, station->serverIP, station->writePort, station->writeSocket);
|
||||||
if (s7plcFWEstablishConnection(station, FOR_WRITE) < 0) {
|
if (s7plcFWEstablishConnection(station, FOR_WRITE) < 0) {
|
||||||
s7plcFWDebugLog(1, "s7plcFWMain %s: connect(%d, %s:%d) failed for write: %s. Retry in %g seconds\n",
|
s7plcFWDebugLog(1, "s7plcFWMain %s: connect(%d, %s:%d) failed for write: %s. Retry in %d ms\n",
|
||||||
station->name, station->writeSocket, station->serverIP, station->writePort, strerror(errno), (double)RECONNECT_DELAY);
|
station->name, station->writeSocket, station->serverIP, station->writePort, strerror(errno), (int)(RECONNECT_DELAY * 1000.0));
|
||||||
if (close(station->writeSocket) && errno != ENOTCONN) {
|
if (close(station->writeSocket) && errno != ENOTCONN) {
|
||||||
s7plcFWDebugLog(1, "s7plcFWMain %s: close(%d) failed for write (ignored): %s\n", station->name, station->writeSocket, strerror(errno));
|
s7plcFWDebugLog(1, "s7plcFWMain %s: close(%d) failed for write (ignored): %s\n", station->name, station->writeSocket, strerror(errno));
|
||||||
}
|
}
|
||||||
@ -659,7 +659,7 @@ STATIC int s7plcFWdoFetch(s7plcFWStation *station, int org, int db, int offs, in
|
|||||||
input = 0;
|
input = 0;
|
||||||
while (input < size) {
|
while (input < size) {
|
||||||
|
|
||||||
s7plcFWDebugLog(3, "s7plcFWdoFetch: %s: waiting for input for %g seconds\n", station->name, station->recvTimeout);
|
s7plcFWDebugLog(3, "s7plcFWdoFetch: %s: waiting for input for %d ms\n", station->name, (int)(station->recvTimeout * 1000.0));
|
||||||
status = s7plcFWWaitForInput(station, FOR_FETCH, station->recvTimeout);
|
status = s7plcFWWaitForInput(station, FOR_FETCH, station->recvTimeout);
|
||||||
if (status <= 0) {
|
if (status <= 0) {
|
||||||
s7plcFWDebugLog(0, "s7plcFWdoFetch: %s: s7plcFWWaitForInput(%d, ..., %d, 0) failed\n", station->name, station->fetchSocket, size - input);
|
s7plcFWDebugLog(0, "s7plcFWdoFetch: %s: s7plcFWWaitForInput(%d, ..., %d, 0) failed\n", station->name, station->fetchSocket, size - input);
|
||||||
@ -911,12 +911,12 @@ STATIC int s7plcFWWaitForInput(s7plcFWStation* station, int which, double timeou
|
|||||||
errno = 0;
|
errno = 0;
|
||||||
while ((iSelect=select(socket+1, &socklist, 0, 0, &to)) < 0) {
|
while ((iSelect=select(socket+1, &socklist, 0, 0, &to)) < 0) {
|
||||||
if (errno != EINTR) {
|
if (errno != EINTR) {
|
||||||
s7plcFWDebugLog(0, "s7plcFWWaitForInput %s: select(%d, %f sec) failed: %s\n", station->name, socket, timeout, strerror(errno));
|
s7plcFWDebugLog(0, "s7plcFWWaitForInput %s: select(%d, %d ms) failed: %s\n", station->name, socket, (int)(timeout * 1000.0), strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (iSelect==0 && timeout > 0) { /* timed out */
|
if (iSelect==0 && timeout > 0) { /* timed out */
|
||||||
s7plcFWDebugLog(0, "s7plcFWWaitForInput %s: select(%d, %f sec) timed out\n", station->name, socket, timeout);
|
s7plcFWDebugLog(0, "s7plcFWWaitForInput %s: select(%d, %d ms) timed out\n", station->name, socket, (int)(timeout * 1000.0));
|
||||||
errno = ETIMEDOUT;
|
errno = ETIMEDOUT;
|
||||||
}
|
}
|
||||||
return iSelect;
|
return iSelect;
|
||||||
@ -955,7 +955,7 @@ STATIC int s7plcFWEstablishConnection(s7plcFWStation* station, int which)
|
|||||||
to.tv_usec=(int)(CONNECT_TIMEOUT-to.tv_sec)*1000000;
|
to.tv_usec=(int)(CONNECT_TIMEOUT-to.tv_sec)*1000000;
|
||||||
#ifdef __vxworks
|
#ifdef __vxworks
|
||||||
if (connectWithTimeout(socket, (struct sockaddr *) &serverAddr, sizeof (serverAddr), &to) < 0) {
|
if (connectWithTimeout(socket, (struct sockaddr *) &serverAddr, sizeof (serverAddr), &to) < 0) {
|
||||||
s7plcFWDebugLog(0, "s7plcFWEstablishConnection %s: connectWithTimeout(%d,...,%g sec) failed: %s\n", station->name, socket, CONNECT_TIMEOUT, strerror(errno));
|
s7plcFWDebugLog(0, "s7plcFWEstablishConnection %s: connectWithTimeout(%d,...,%d ms) failed: %s\n", station->name, socket, (int)(CONNECT_TIMEOUT * 1000.0), strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -981,12 +981,12 @@ STATIC int s7plcFWEstablishConnection(s7plcFWStation* station, int which)
|
|||||||
/* wait for connection */
|
/* wait for connection */
|
||||||
while ((status = select(socket+1, NULL, &fdset, NULL, &to)) < 0) {
|
while ((status = select(socket+1, NULL, &fdset, NULL, &to)) < 0) {
|
||||||
if (errno != EINTR) {
|
if (errno != EINTR) {
|
||||||
s7plcFWDebugLog(0, "s7plcFWEstablishConnection %s: select(%d, %f sec) failed: %s\n", station->name, socket, CONNECT_TIMEOUT, strerror(errno));
|
s7plcFWDebugLog(0, "s7plcFWEstablishConnection %s: select(%d, %d ms) failed: %s\n", station->name, socket, (int)(CONNECT_TIMEOUT * 1000.0), strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (status == 0) {
|
if (status == 0) {
|
||||||
s7plcFWDebugLog(0, "s7plcFWEstablishConnection %s: select(%d, %f sec) timed out\n", station->name, socket, CONNECT_TIMEOUT);
|
s7plcFWDebugLog(0, "s7plcFWEstablishConnection %s: select(%d, %d ms) timed out\n", station->name, socket, (int)(CONNECT_TIMEOUT * 1000.0));
|
||||||
errno = ETIMEDOUT;
|
errno = ETIMEDOUT;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user