- 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 SKIPPED: psi/delcam.c psi/make_gen psi/psi.c psi/sinq.c psi/sinq.h psi/sinqhttpopt.c psi/slsvme.c psi/spss7.c
This commit is contained in:
85
hipadaba.c
85
hipadaba.c
@@ -448,7 +448,81 @@ void ReleaseHdbValue(hdbValue * v)
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
static unsigned short fletcher16( char *data, size_t len)
|
||||
{
|
||||
unsigned short sum1 = 0xff, sum2 = 0xff, result;
|
||||
unsigned char checkA, checkB;
|
||||
|
||||
if(data == NULL){
|
||||
return 0;
|
||||
}
|
||||
while (len) {
|
||||
size_t tlen = len > 21 ? 21 : len;
|
||||
len -= tlen;
|
||||
do {
|
||||
sum1 += *data++;
|
||||
sum2 += sum1;
|
||||
} while (--tlen);
|
||||
sum1 = (sum1 & 0xff) + (sum1 >> 8);
|
||||
sum2 = (sum2 & 0xff) + (sum2 >> 8);
|
||||
}
|
||||
/* Second reduction step to reduce sums to 8 bits */
|
||||
sum1 = (sum1 & 0xff) + (sum1 >> 8);
|
||||
sum2 = (sum2 & 0xff) + (sum2 >> 8);
|
||||
checkA = (unsigned char)sum1;
|
||||
checkB = (unsigned char)sum2;
|
||||
result = checkA;
|
||||
result = result << 8 | checkB;
|
||||
return result ;
|
||||
}
|
||||
/*------------------------------------------------------------------------*/
|
||||
unsigned short getHdbCheckSum(hdbValue *val)
|
||||
{
|
||||
char *data;
|
||||
size_t len;
|
||||
|
||||
len = getHdbValueLength(*val);
|
||||
switch (val->dataType) {
|
||||
case HIPNONE:
|
||||
return 0;
|
||||
break;
|
||||
case HIPINT:
|
||||
data = (char *)&val->v.intValue;
|
||||
return fletcher16(data,len);
|
||||
break;
|
||||
case HIPFLOAT:
|
||||
data = (char *)&val->v.doubleValue;
|
||||
return fletcher16(data,len);
|
||||
break;
|
||||
case HIPTEXT:
|
||||
data = val->v.text;
|
||||
return fletcher16(data,len);
|
||||
break;
|
||||
case HIPINTAR:
|
||||
case HIPINTVARAR:
|
||||
data = (char *)val->v.intArray;
|
||||
return fletcher16(data,len);
|
||||
break;
|
||||
case HIPFLOATAR:
|
||||
case HIPFLOATVARAR:
|
||||
data = (char *)val->v.floatArray;
|
||||
return fletcher16(data,len);
|
||||
break;
|
||||
case HIPOBJ:
|
||||
data = (char *)val->v.obj;
|
||||
return fletcher16(data,len);
|
||||
break;
|
||||
case HIPFUNC:
|
||||
data = (char *)val->v.func;
|
||||
return fletcher16(data,len);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*------------------------------------------------------------------------*/
|
||||
int compareHdbValue(hdbValue v1, hdbValue v2)
|
||||
{
|
||||
@@ -457,6 +531,12 @@ int compareHdbValue(hdbValue v1, hdbValue v2)
|
||||
if (v1.dataType != v2.dataType) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if((v1.doNotFree == 1 && v1.v.obj == NULL)
|
||||
|| (v2.doNotFree == 1 && v2.v.obj == NULL)){
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (v1.dataType) {
|
||||
case HIPNONE:
|
||||
return 0;
|
||||
@@ -971,12 +1051,17 @@ int NotifyHipadabaPar(pHdb node, void *callData)
|
||||
int GetHipadabaPar(pHdb node, hdbValue *v, void *callData)
|
||||
{
|
||||
int status;
|
||||
unsigned short checksum;
|
||||
|
||||
memset(v,0,sizeof(hdbValue));
|
||||
v->dataType = node->value.dataType;
|
||||
|
||||
checksum = getHdbCheckSum(&node->value);
|
||||
status = SendDataMessage(node, get, v, callData);
|
||||
copyHdbValue(&node->value, v);
|
||||
if(getHdbCheckSum(&node->value) != checksum){
|
||||
NotifyHipadabaPar(node, callData);
|
||||
}
|
||||
if (status != 1) {
|
||||
return status;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user