- Added some hipadab array math

- Added missing cnvrt files, stolen from Markus
- Debugged the new sinqhttpopt driver for SINQ HTTP HM
- Debugged the driver for the new S7 Siemens SPS
- Added handling of hexadecimal terminators to ascon.c
- Increased the write buffer size in asynnet again
- Fixed  a core dump in lld.c
- Added writing of second gen HM to nxscript.c
- Added doubletime command to SICS
- Fixed a core dump issue in sicshdbadapter.c on dimension changes
- Modified sicsobj to look for lower case keys too
This commit is contained in:
koennecke
2011-04-08 14:18:43 +00:00
parent 1384d9034a
commit 3eed3432cb
8 changed files with 210 additions and 21 deletions

View File

@ -92,6 +92,7 @@ typedef struct {
int sockHandle;
int bytesExpected;
char *contentType;
int headerReceived;
} HttpProt, *pHttpProt;
/*---------------------------------------------------------------------*/
static int HTTPcallback(int handle, void *userData)
@ -168,6 +169,8 @@ static void sendRequest(pHttpProt pHttp, char *data)
dataCopy = strdup(data);
pHttp->node = NULL;
pHttp->headerReceived = 0;
pPtr = strchr(dataCopy,':');
if(pPtr == NULL){
path = dataCopy;
@ -190,6 +193,11 @@ static void sendRequest(pHttpProt pHttp, char *data)
*pPtr = '\0';
sendPost(pHttp,path, pPtr+1);
free(dataCopy);
} else if(strstr(dataCopy,"processhmdata.egi") != NULL){
path = dataCopy;
sendGet(pHttp,path);
free(dataCopy);
return;
}
}
}
@ -212,6 +220,11 @@ static void handleReply(Ascon * a)
if (strstr(pType, "sinqhm") != NULL) {
hmData = (HistInt *) pPtr;
len = len / sizeof(HistInt);
/*
if(len == 0) {
printf("Blllllllllaaaaaaaaaaeeeeeeeeeerrrrrrrrrrrkkkk!\n");
}
*/
if(pHttp->node == NULL){
clearSICSData(pHttp->binData);
dataPtr = getSICSDataPointer(pHttp->binData, 0, len);
@ -221,6 +234,9 @@ static void handleReply(Ascon * a)
assignSICSType(pHttp->binData, 0, len, INTTYPE);
DynStringClear(a->rdBuffer);
DynStringCopy(a->rdBuffer, "SICSDATA");
/*
printf("SICSDATA received..........\n");
*/
} else {
if(pHttp->node->value.arrayLength != len){
if(pHttp->node->value.v.intArray != NULL){
@ -240,10 +256,10 @@ static void handleReply(Ascon * a)
/*
path = GetHipadabaPath(pHttp->node);
if(path != NULL){
printf("Sinqhttpprot has updated node: %s\n", path);
printf("Sinqhttpopt has updated node: %s, length = %d\n", path, len);
free(path);
}
*/
*/
}
}
}
@ -291,6 +307,7 @@ static int processHeader(Ascon *a)
}
}
}
pHttp->headerReceived = 1;
/**
* Hack off the header
*/
@ -366,36 +383,59 @@ static int HttpHandler(Ascon * a)
DynStringClear(a->rdBuffer);
return 1;
break;
case AsconReadStart:
a->state= AsconReading;
return 1;
break;
case AsconReading:
ANETprocess();
/**
* Here we have basically three conditions to check:
* Here we have basically four conditions to check:
* - <cr><ld><cr><lf> detected means that we received
* the complete header.
* - enough bytes read: termination
* - socket closed means all data has been read
* - timeout waiting for a response
*/
if(strstr(GetCharArray(a->rdBuffer), "\r\n\r\n") != NULL){
status = processHeader(a);
if(status != 1){
a->state = AsconReadDone;
return 1;
break;
}
}
if(!ANETvalidHandle(pHttp->sockHandle)){
handleReply(a);
a->state = AsconReadDone;
return 1;
if(pHttp->headerReceived) {
handleReply(a);
a->state = AsconReadDone;
} else {
/*
* We only noticed when attempting to read that the WWW-server has closed
* the connection. ANETclose will have killed the read and write buffers.
* So redo everything......
*/
a->state = AsconWriteStart;
return 1;
}
break;
}
if(pHttp->bytesExpected > 0 && GetDynStringLength(a->rdBuffer) >= pHttp->bytesExpected ){
handleReply(a);
a->state = AsconReadDone;
return 1;
break;
}
if (a->timeout > 0) {
if (DoubleTime() - a->start > a->timeout) {
AsconError(a, "no response", 0);
printf("Timeout on httpopt\n");
ANETclose(pHttp->sockHandle);
a->state = AsconTimeout;
}
}
return 0;
break;
default:
return AsconStdHandler(a);
return AsconBaseHandler(a);
}
return 1;
}