8 Commits

Author SHA1 Message Date
644c824604 fix version tests for EPICS 7 2019-08-12 09:52:52 +02:00
a470205454 build for all EPICS version 2019-08-12 09:45:22 +02:00
59511616ae fix 64bit warnings 2016-02-12 15:35:30 +01:00
46bf87c99c no exit in ConfigFunc 2013-07-11 12:43:21 +00:00
9ea778a101 no exit in ConfigFunc 2013-07-11 11:52:44 +00:00
a5ed2fd234 stack size macro 2012-12-05 08:49:08 +00:00
f9b9b5192f corrected typo 2012-09-03 13:20:53 +00:00
4f4d43032d linux + va_args + float/double problem - using int now as workaround 2012-06-18 12:25:19 +00:00
4 changed files with 30 additions and 35 deletions

View File

@ -5,7 +5,3 @@ BUILDCLASSES+=Linux
DBDS += s7plcFWBase.dbd
DBDS_3.14 += s7plcFWCalcout.dbd
DBDS_3.14 += s7plcFWReg.dbd
EPICS_VERSIONS =
EPICS_VERSIONS += 3.14.8
EPICS_VERSIONS += 3.14.12

View File

@ -34,15 +34,14 @@
#include <stringoutRecord.h>
#include <waveformRecord.h>
#if ((EPICS_VERSION==3 && EPICS_REVISION>=14) || EPICS_VERSION>3)
/* R3.14 */
#ifdef BASE_VERSION
#define EPICS_3_13
#include "compat3_13.h"
#else
#include <postfix.h>
#include <calcoutRecord.h>
#include <cantProceed.h>
#include <epicsExport.h>
#else
/* R3.13 */
#include "compat3_13.h"
#endif
/* suppress compiler warning concerning long long with __extension__ */
@ -361,7 +360,7 @@ struct devsup s7plcFWWaveform =
epicsExportAddress(dset, s7plcFWWaveform);
/* calcout **********************************************************/
#if ((EPICS_VERSION==3 && EPICS_REVISION>=14) || EPICS_VERSION>3)
#ifndef EPICS_3_13
STATIC long s7plcFWInitRecordCalcout(calcoutRecord *);
STATIC long s7plcFWWriteCalcout(calcoutRecord *);
@ -1761,7 +1760,7 @@ STATIC long s7plcFWReadAi(aiRecord *record)
case epicsFloat64T:
status = s7plcFWRead(priv->station, priv->offs,
8, &val64);
__extension__ s7plcFWDebugLog(3, "ai %s: read 64bit %08Lx = %g\n",
__extension__ s7plcFWDebugLog(3, "ai %s: read 64bit " CONV64 " = %g\n",
record->name, val64.i, val64.f);
floatval = TRUE;
break;
@ -2025,7 +2024,7 @@ STATIC long s7plcFWInitRecordStringin(stringinRecord *record)
{
errlogSevPrintf(errlogMinor,
"%s: string size reduced from %d to %d\n",
record->name, priv->dlen, sizeof(record->val));
record->name, priv->dlen, (int)sizeof(record->val));
priv->dlen = sizeof(record->val);
}
record->dpvt = priv;
@ -2105,7 +2104,7 @@ STATIC long s7plcFWInitRecordStringout(stringoutRecord *record)
{
errlogSevPrintf(errlogMinor,
"%s: string size reduced from %d to %d\n",
record->name, priv->dlen, sizeof(record->val));
record->name, priv->dlen, (int)sizeof(record->val));
priv->dlen = sizeof(record->val);
}
record->dpvt = priv;
@ -2368,8 +2367,8 @@ STATIC long s7plcFWReadWaveform(waveformRecord *record)
return status;
}
#if (EPICS_REVISION>=14)
/* calcout **********************************************************/
#ifndef EPICS_3_13
STATIC long s7plcFWInitRecordCalcout(calcoutRecord *record)
{

View File

@ -1,7 +1,7 @@
/* $Date: 2012/03/06 10:53:08 $ */
/* $Id: drvS7plcFW.c,v 1.2 2012/03/06 10:53:08 anicic Exp $ */
/* $Date: 2013/07/11 12:43:21 $ */
/* $Id: drvS7plcFW.c,v 1.6 2013/07/11 12:43:21 anicic Exp $ */
/* $Name: $ */
/* $Revision: 1.2 $ */
/* $Revision: 1.6 $ */
/*
* NOTE: s7plcFWwriteThread -is not used for writting (we write direct),
@ -63,12 +63,13 @@
#include <endian.h>
#endif
#define STACK_SIZE 20000 /* io thread stack size */
/* #define STACK_SIZE 20000 */ /* io thread stack size */
#define STACK_SIZE epicsThreadGetStackSize(epicsThreadStackBig)
#define CONNECT_TIMEOUT 5.0 /* connect timeout [s] */
#define RECONNECT_DELAY 10.0 /* delay before reconnect [s] */
static char cvsid[] __attribute__((unused)) =
"$Id: drvS7plcFW.c,v 1.2 2012/03/06 10:53:08 anicic Exp $";
"$Id: drvS7plcFW.c,v 1.6 2013/07/11 12:43:21 anicic Exp $";
STATIC long s7plcFWIoReport(int level);
STATIC long s7plcFWInit();
@ -186,9 +187,9 @@ STATIC long s7plcFWIoReport(int level)
"ioc:motorola <-> plc:intel" : "no (both motorola)"
#endif
);
printf(" receive timeout %g sec\n", station->recvTimeout);
printf(" receive delay %g sec\n", station->recvDelay);
printf(" outIOint delay %g sec\n", station->outIOintDelay);
printf(" receive timeout %d ms\n", (int)(station->recvTimeout * 1000.0));
printf(" receive delay %d ms\n", (int)(station->recvDelay * 1000.0));
printf(" outIOint delay %d ms\n", (int)(station->outIOintDelay * 1000.0));
}
}
return 0;
@ -388,11 +389,9 @@ static const iocshArg * const s7plcFWConfigureArgs[] = {
static const iocshFuncDef s7plcFWConfigureDef = { "s7plcFWConfigure", 8, s7plcFWConfigureArgs };
static void s7plcFWConfigureFunc (const iocshArgBuf *args)
{
int status = s7plcFWConfigure(
(void) s7plcFWConfigure(
args[0].sval, args[1].sval, args[2].sval, args[3].sval,
args[4].ival, args[5].ival, args[6].ival, args[7].ival);
if (status) exit(1);
}
static void s7plcFWRegister ()
@ -452,8 +451,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);
if (s7plcFWEstablishConnection(station, FOR_FETCH) < 0) {
s7plcFWDebugLog(1, "s7plcFWMain %s: connect(%d, %s:%d) failed for fetch: %s. Retry in %g seconds\n",
station->name, station->fetchSocket, station->serverIP, station->fetchPort, strerror(errno), (double)RECONNECT_DELAY);
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), (int)(RECONNECT_DELAY * 1000.0));
if (close(station->fetchSocket) && errno != ENOTCONN) {
s7plcFWDebugLog(1, "s7plcFWMain %s: close(%d) failed for fetch (ignored): %s\n", station->name, station->fetchSocket, strerror(errno));
}
@ -476,8 +475,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);
if (s7plcFWEstablishConnection(station, FOR_WRITE) < 0) {
s7plcFWDebugLog(1, "s7plcFWMain %s: connect(%d, %s:%d) failed for write: %s. Retry in %g seconds\n",
station->name, station->writeSocket, station->serverIP, station->writePort, strerror(errno), (double)RECONNECT_DELAY);
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), (int)(RECONNECT_DELAY * 1000.0));
if (close(station->writeSocket) && errno != ENOTCONN) {
s7plcFWDebugLog(1, "s7plcFWMain %s: close(%d) failed for write (ignored): %s\n", station->name, station->writeSocket, strerror(errno));
}
@ -659,7 +658,7 @@ STATIC int s7plcFWdoFetch(s7plcFWStation *station, int org, int db, int offs, in
input = 0;
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);
if (status <= 0) {
s7plcFWDebugLog(0, "s7plcFWdoFetch: %s: s7plcFWWaitForInput(%d, ..., %d, 0) failed\n", station->name, station->fetchSocket, size - input);
@ -911,12 +910,12 @@ STATIC int s7plcFWWaitForInput(s7plcFWStation* station, int which, double timeou
errno = 0;
while ((iSelect=select(socket+1, &socklist, 0, 0, &to)) < 0) {
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;
}
}
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;
}
return iSelect;
@ -955,7 +954,7 @@ STATIC int s7plcFWEstablishConnection(s7plcFWStation* station, int which)
to.tv_usec=(int)(CONNECT_TIMEOUT-to.tv_sec)*1000000;
#ifdef __vxworks
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;
}
#else
@ -981,12 +980,12 @@ STATIC int s7plcFWEstablishConnection(s7plcFWStation* station, int which)
/* wait for connection */
while ((status = select(socket+1, NULL, &fdset, NULL, &to)) < 0) {
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;
}
}
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;
return -1;
}

View File

@ -54,6 +54,7 @@ Besides the
<li>new communication protocol (FETCH/WRITE)</li>
<li>the modified <code>s7plcFWConfigure</code> function</li>
<li>additional support for write-connection-status (see <a href="#stat"> <code>"s7plcFW&nbsp;stat2"</code> </a>)</li>
<li>when using bi and bo bits 0-7 and 8-15 are swapped (i.e. for bit 3 use 3+8=11, or for bit 13 use 13-8=5)</li>
</ol>
there should be no other differences.
<br><br>