- fixed some problems in server side file directory service

pull/6/head
Michael Zillgith 10 years ago
parent 987f8decbb
commit b0e8a6331b

@ -376,11 +376,6 @@ GoosePublisher_publish(GoosePublisher self, LinkedList dataSet)
if (DEBUG_GOOSE_PUBLISHER) if (DEBUG_GOOSE_PUBLISHER)
printf("GOOSE_PUBLISHER: send GOOSE message\n"); printf("GOOSE_PUBLISHER: send GOOSE message\n");
struct timeval tv;
gettimeofday(&tv,NULL/*&tz*/);
printf("GOOSE SEND: %ld %ld\n",tv.tv_sec, tv.tv_usec);
Ethernet_sendPacket(self->ethernetSocket, self->buffer, self->payloadStart + payloadLength); Ethernet_sendPacket(self->ethernetSocket, self->buffer, self->payloadStart + payloadLength);
return 0; return 0;

@ -612,13 +612,6 @@ exit_with_fault:
static void static void
parseGooseMessage(GooseReceiver self, int numbytes) parseGooseMessage(GooseReceiver self, int numbytes)
{ {
struct timeval tv;
gettimeofday(&tv,NULL/*&tz*/);
printf("RCVD GOOSE: %ld %ld\n",tv.tv_sec, tv.tv_usec);
int bufPos; int bufPos;
bool subscriberFound = false; bool subscriberFound = false;
uint8_t* buffer = self->buffer; uint8_t* buffer = self->buffer;

@ -88,6 +88,9 @@ iedConnection_mapMmsErrorToIedError(MmsError mmsError)
case MMS_ERROR_CONNECTION_REJECTED: case MMS_ERROR_CONNECTION_REJECTED:
return IED_ERROR_CONNECTION_REJECTED; return IED_ERROR_CONNECTION_REJECTED;
case MMS_ERROR_ACCESS_OBJECT_VALUE_INVALID:
return IED_ERROR_OBJECT_VALUE_INVALID;
default: default:
return IED_ERROR_UNKNOWN; return IED_ERROR_UNKNOWN;
} }

@ -106,8 +106,6 @@ connectionHandlingThread(IsoClientConnection self)
TpktState packetState; TpktState packetState;
printf("P1\n");
while ((packetState = CotpConnection_readToTpktBuffer(self->cotpConnection)) == TPKT_WAITING) while ((packetState = CotpConnection_readToTpktBuffer(self->cotpConnection)) == TPKT_WAITING)
{ {
Thread_sleep(1); Thread_sleep(1);
@ -118,9 +116,6 @@ connectionHandlingThread(IsoClientConnection self)
} }
} }
printf("P2\n");
if (packetState == TPKT_ERROR) if (packetState == TPKT_ERROR)
break; break;
@ -151,44 +146,27 @@ connectionHandlingThread(IsoClientConnection self)
break; break;
} }
printf("P3\n");
self->callback(ISO_IND_DATA, self->callbackParameter, self->callback(ISO_IND_DATA, self->callbackParameter,
&(self->presentation->nextPayload)); &(self->presentation->nextPayload));
printf("P4\n");
/* wait for user to release the buffer */ /* wait for user to release the buffer */
Semaphore_wait(self->receiveBufferMutex); Semaphore_wait(self->receiveBufferMutex);
printf("P5\n");
CotpConnection_resetPayload(self->cotpConnection); CotpConnection_resetPayload(self->cotpConnection);
} }
printf("I1\n"); self->callback(ISO_IND_CLOSED, self->callbackParameter, NULL);;
self->callback(ISO_IND_CLOSED, self->callbackParameter, NULL);
printf("I2\n");
self->state = STATE_IDLE; self->state = STATE_IDLE;
Socket_destroy(self->socket); Socket_destroy(self->socket);
printf("I3\n");
if (DEBUG_ISO_CLIENT) if (DEBUG_ISO_CLIENT)
printf("ISO_CLIENT_CONNECTION: exit connection %p\n", self); printf("ISO_CLIENT_CONNECTION: exit connection %p\n", self);
/* release buffer to enable reuse of client connection */ /* release buffer to enable reuse of client connection */
Semaphore_post(self->receiveBufferMutex); Semaphore_post(self->receiveBufferMutex);
printf("I4\n");
self->handlingThreadRunning = false; self->handlingThreadRunning = false;
} }
@ -449,16 +427,12 @@ IsoClientConnection_close(IsoClientConnection self)
if (DEBUG_ISO_CLIENT) if (DEBUG_ISO_CLIENT)
printf("ISO_CLIENT: IsoClientConnection_close\n"); printf("ISO_CLIENT: IsoClientConnection_close\n");
printf("B1\n");
if (self->handlingThreadRunning) { if (self->handlingThreadRunning) {
self->stopHandlingThread = true; self->stopHandlingThread = true;
while (self->handlingThreadRunning) while (self->handlingThreadRunning)
Thread_sleep(1); Thread_sleep(1);
} }
printf("B2\n");
self->state = STATE_IDLE; self->state = STATE_IDLE;
} }

@ -98,6 +98,9 @@ mmsClient_parseIdentifyResponse(MmsConnection self)
case 0x83: /* list of abstract syntaxes */ case 0x83: /* list of abstract syntaxes */
bufPos += length; bufPos += length;
break; break;
default: /* ignore unknown tags */
bufPos += length;
break;
} }
} }

@ -221,6 +221,9 @@ parseInitiateRequestPdu(MmsServerConnection self, uint8_t* buffer, int bufPos, i
case 0xa4: /* mms-init-request-detail */ case 0xa4: /* mms-init-request-detail */
/* we ignore this */ /* we ignore this */
break; break;
default:
break; /* Ignore unknown tags */
} }
bufPos += length; bufPos += length;

@ -450,8 +450,10 @@ addFileEntriesToResponse(uint8_t* buffer, int bufPos, int maxBufSize, char* dire
while (fileName != NULL) { while (fileName != NULL) {
directoryName[directoryNameLength] = 0; directoryName[directoryNameLength] = 0;
if (directoryNameLength > 0) if (directoryNameLength > 0) {
strcat(directoryName, "/"); if (directoryName[directoryNameLength - 1] != '/')
strcat(directoryName, "/");
}
strcat(directoryName, fileName); strcat(directoryName, fileName);
@ -506,6 +508,8 @@ addFileEntriesToResponse(uint8_t* buffer, int bufPos, int maxBufSize, char* dire
FileSystem_closeDirectory(directory); FileSystem_closeDirectory(directory);
} }
else
bufPos = -1;
directoryName[directoryNameLength] = 0; directoryName[directoryNameLength] = 0;

Loading…
Cancel
Save