Now uses ASCII instead of unicode to reflect changes in Astrium code.

This commit is contained in:
hauser_n
2006-10-02 22:57:49 +00:00
parent 88fa7449af
commit ff7896ca53

View File

@ -101,7 +101,6 @@ static int unicodeToAscii(char *input, int len, char **output){
static int tcpDoChoSend(pTcpDoCho self, char *command, int choNum,
char *value){
char buffer[1024];
char *converted;
int sendlen, status;
/*
@ -116,13 +115,12 @@ static int tcpDoChoSend(pTcpDoCho self, char *command, int choNum,
} else {
snprintf(buffer,1023,"#SOS#%s%1.1d:\r\n",command, choNum);
}
sendlen = asciiToUnicode(buffer,&converted);
sendlen = strlen(buffer);
if(sendlen == 0){
self->lastError = BADCONVERSION;
return 0;
}
status = send(self->controller->pSock->sockid,converted,sendlen,0);
free(converted);
status = send(self->controller->pSock->sockid,buffer,sendlen,0);
if(status < 0){
self->lastError = BADWRITE;
return 0;
@ -208,8 +206,7 @@ static int parseStatus(pTcpDoCho self, char *statusMessage){
/*-----------------------------------------------------------------*/
static int tcpDoChoReceive(pTcpDoCho self){
char buffer[1024];
int len, bytesRead, bytesConverted, bufferStart, status;
char *converted = NULL;
int len, bytesRead, bufferStart, status;
time_t endTime;
endTime = time(NULL) + self->timeout;
@ -224,25 +221,17 @@ static int tcpDoChoReceive(pTcpDoCho self){
self->lastError = BADREAD;
return 0;
}
bytesConverted = unicodeToAscii(buffer,bytesRead,&converted);
if(bytesConverted == 0){
self->lastError = BADCONVERSION;
return 0;
}
if(strstr(converted,"State") != NULL){
if(statusComplete(converted) == 0) {
if(strstr(buffer,"State") != NULL){
if(statusComplete(buffer) == 0) {
continue;
} else {
status = parseStatus(self,converted);
free(converted);
status = parseStatus(self,buffer);
return status;
}
}
if(strstr(converted,"ACCEPT") != NULL){
free(converted);
if(strstr(buffer,"ACCEPT") != NULL){
return 1;
} else if(strstr(converted,"NCCEPT") != NULL){
free(converted);
} else if(strstr(buffer,"NCCEPT") != NULL){
self->lastError = FAILEDCOMMAND;
return 0;
} else {
@ -270,7 +259,6 @@ static int tcpDoChoCommand(pTcpDoCho self, char *command, int choNum,
/*---------------------------------------------------------------*/
static int TcpDoChoConnect(pTcpDoCho self){
int status, sendLen, readLen;
char *converted = NULL;
char buffer[256];
status = initRS232(self->controller);
@ -282,48 +270,40 @@ static int TcpDoChoConnect(pTcpDoCho self){
readLen = 255;
readRS232(self->controller,(void *)buffer,&readLen);
unicodeToAscii(buffer,readLen,&converted);
free(converted);
/*
user name
*/
snprintf(buffer,255,"user:%s\r\n",self->user);
sendLen = asciiToUnicode(buffer,&converted);
sendLen = strlen(buffer);
if(sendLen == 0){
self->lastError = BADCONVERSION;
return 0;
}
status = send(self->controller->pSock->sockid,converted,sendLen,0);
free(converted);
status = send(self->controller->pSock->sockid,buffer,sendLen,0);
if(status < 0){
self->lastError = BADSEND;
return 0;
}
readLen = 255;
readRS232(self->controller,(void *)buffer,&readLen);
unicodeToAscii(buffer,readLen,&converted);
free(converted);
/*
password
*/
snprintf(buffer,255,"password:%s\r\n",self->pword);
sendLen = asciiToUnicode(buffer,&converted);
sendLen = strlen(buffer);
if(sendLen == 0){
self->lastError = BADCONVERSION;
return 0;
}
status = send(self->controller->pSock->sockid,converted,sendLen,0);
free(converted);
status = send(self->controller->pSock->sockid,buffer,sendLen,0);
if(status < 0){
self->lastError = BADSEND;
return 0;
}
readLen = 255;
readRS232(self->controller,(void *)buffer,&readLen);
unicodeToAscii(buffer,readLen,&converted);
free(converted);
/*
TODO: responses should be checked to test for a valid login.