PSI sics-cvs-psi-2008-10-02
This commit is contained in:
@@ -434,6 +434,42 @@ void getRS232Error(int iCode, char *errorBuffer,
|
||||
}
|
||||
}
|
||||
/*--------------------------------------------------------------------*/
|
||||
int fixRS232Error(prs232 self, int iCode){
|
||||
int i, status, read;
|
||||
char buffer[8192];
|
||||
|
||||
switch(iCode){
|
||||
case BADMEMORY:
|
||||
case FAILEDCONNECT:
|
||||
return 0;
|
||||
break;
|
||||
case INCOMPLETE:
|
||||
case TIMEOUT:
|
||||
/*
|
||||
* try to clear possibly pending stuff
|
||||
*/
|
||||
for(i = 0; i < 3; i++){
|
||||
if(availableRS232(self)){
|
||||
read = 8192;
|
||||
readRS232(self,buffer,&read);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
break;
|
||||
case NOTCONNECTED:
|
||||
case BADSEND:
|
||||
closeRS232(self);
|
||||
status = initRS232(self);
|
||||
if(status > 0){
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*--------------------------------------------------------------------*/
|
||||
int getRS232Timeout(prs232 self){
|
||||
return self->timeout;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user