- Currently disabled attempts at logging commands
- Added a warning for excessive data rates on monitors - Added statistics to devser and thus to scriptcontext - Added byte concatenation to dynstring - Added aborting for reflection generation to fourmess.c - Added data checksum testing to hipadaba, use for update tests - Fixed interrupt discovery in network.c, caused invalid interrupt codes which in turn confused sicscron which had to be fixed too. - Renamed ubcalc into ubcalcint in order to reclaim the ubcalc for Jurg - Added an a3offset to tasub in order to fix what I perceive an IS problem - Added support for the newer version of the Siemens SPS, the S7 - Added a not yet fully working sinqhttpopt driver which talks to http HM without libghttp
This commit is contained in:
96
sinq.c
96
sinq.c
@ -12,6 +12,12 @@
|
||||
* copyright: see file COPYRIGHT
|
||||
*
|
||||
* Mark Koennecke, July 2005
|
||||
*
|
||||
* Modified to also hold the code for a second version which
|
||||
* uses the redirector on lnsl15. This has to be used by instruments in
|
||||
* the private network as they cannot receive the ACS broadacst.
|
||||
*
|
||||
* Mark Koennecke, July 2010
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -26,6 +32,8 @@
|
||||
#include "dgrambroadcast.h"
|
||||
|
||||
#include "sinq.h"
|
||||
#include <asynnet.h>
|
||||
|
||||
#ifdef SEND_PORT
|
||||
#define RECEIVE_PORT SEND_PORT
|
||||
#else
|
||||
@ -83,9 +91,11 @@ static void KillSinq(void *data)
|
||||
if (self->pDes != NULL) {
|
||||
DeleteDescriptor(self->pDes);
|
||||
}
|
||||
if(self->anet){
|
||||
ANETclose(self->receiveSocket);
|
||||
}
|
||||
free(self);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
int SinqFactory(SConnection * pCon, SicsInterp * pSics,
|
||||
void *pData, int argc, char *argv[])
|
||||
@ -202,3 +212,87 @@ int SinqWrapper(SConnection * pCon, SicsInterp * pSics,
|
||||
SCWrite(pCon, pBueffel, eValue);
|
||||
return 1;
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
static char* searchMessage(char *pPtr, int length)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; i < length; i++){
|
||||
if(pPtr[i] == (char) 4 && pPtr[i+1] == (char)4){
|
||||
return pPtr + i-1;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
static int SINQRedirectCallback(int handle, void *userData){
|
||||
pSinq self = (pSinq)userData;
|
||||
char *pPtr = NULL, *pTerm = NULL,pID[5];
|
||||
int length, sinq;
|
||||
|
||||
pPtr = ANETreadPtr(handle, &length);
|
||||
pTerm = searchMessage(pPtr,length);
|
||||
while(pTerm != NULL){
|
||||
/*
|
||||
strlcpy(pID, pPtr, 5);
|
||||
printf("Received message with ID: %s\n", pID);
|
||||
*/
|
||||
if (memcmp(pPtr, "D110", 4) == 0) {
|
||||
strlcpy(self->d110, pPtr, pTerm - pPtr);
|
||||
sinq = getSinqBeam(self, SINQBEAM);
|
||||
self->lastSinq[self->lastCount] = sinq;
|
||||
self->lastCount++;
|
||||
if (self->lastCount >= MAXLOG) {
|
||||
self->lastCount = 0;
|
||||
}
|
||||
}
|
||||
if (memcmp(pPtr, "A110", 4) == 0) {
|
||||
strlcpy(self->a110, pPtr, pTerm - pPtr);
|
||||
}
|
||||
ANETreadConsume(handle, (pTerm - pPtr) + 3);
|
||||
pPtr = ANETreadPtr(handle, &length);
|
||||
pTerm = searchMessage(pPtr,length);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
int SinqRedirectFactory(SConnection * pCon, SicsInterp * pSics,
|
||||
void *pData, int argc, char *argv[])
|
||||
{
|
||||
pSinq pNew = NULL;
|
||||
int i;
|
||||
|
||||
if(argc < 3){
|
||||
SCWrite(pCon,"ERROR: need host port argument to SinqRedirectFactory", eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
pNew = (pSinq) malloc(sizeof(Sinq));
|
||||
if (pNew == NULL) {
|
||||
SCWrite(pCon, "ERROR: out of memory allocating Sinq", eError);
|
||||
return 0;
|
||||
}
|
||||
memset(pNew, 0, sizeof(Sinq));
|
||||
pNew->pDes = CreateDescriptor("Sinq");
|
||||
if (pNew->pDes == NULL) {
|
||||
SCWrite(pCon, "ERROR: out of memory allocating Sinq", eError);
|
||||
free(pNew);
|
||||
return 0;
|
||||
}
|
||||
pNew->receiveSocket = ANETconnect(argv[1],atoi(argv[2]));
|
||||
if (pNew->receiveSocket < 0) {
|
||||
SCWrite(pCon, "ERROR: failed to open Sinq Status port",
|
||||
eError);
|
||||
KillSinq(pNew);
|
||||
return 0;
|
||||
}
|
||||
ANETsetReadCallback(pNew->receiveSocket, SINQRedirectCallback, pNew, NULL);
|
||||
pNew->anet = 1;
|
||||
|
||||
for (i = 0; i < MAXLOG; i++) {
|
||||
pNew->lastSinq[i] = -200;
|
||||
}
|
||||
return AddCommand(pSics, "sinq", SinqWrapper, KillSinq, pNew);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user