int GSM_ReadDevice (GSM_StateMachine *s, gboolean waitforreply) { GSM_DateTime Date; unsigned char buff[65536]={'\0'}; int res=0,count=0,i=0; if (!GSM_IsConnected(s)) { return -1; } GSM_GetCurrentDateTime (&Date); i=Date.Second; while (i==Date.Second && !s->Abort) { res = s->Device.Functions->ReadDevice(s, buff, sizeof(buff)); if (!waitforreply) { break; } if (res > 0) { break; } usleep(5000); GSM_GetCurrentDateTime(&Date); } for (count = 0; count < res; count++) { s->Protocol.Functions->StateMachine(s,buff[count]); } return res; }
/* Function to handle errors */ void error_handler(void) { if (error != ERR_NONE) { printf("ERROR: %s\n", GSM_ErrorString(error)); if (GSM_IsConnected(s)) GSM_TerminateConnection(s); exit(error); } }