X-Git-Url: https://git.jankratochvil.net/?p=gnokii.git;a=blobdiff_plain;f=common%2Fdata%2Fvirtmodem.c;h=169b11760953e521afc617d87fdf862fa419cfc4;hp=bcedc7e38e0abf97add6c1f1532f08d86bc876d2;hb=35acc80f23f9f81f3145a686a9c7df4b622b25fe;hpb=e434e7467e6c831f5b00f166483764f6f7649828 diff --git a/common/data/virtmodem.c b/common/data/virtmodem.c index bcedc7e..169b117 100644 --- a/common/data/virtmodem.c +++ b/common/data/virtmodem.c @@ -107,11 +107,16 @@ bool VM_Initialise(char *model,char *port, char *initlength, GSM_ConnectionType return (false); } +#ifndef UCLINUX /* Create and start thread, */ return VM_ThreadLoop(); +#else + return true; +#endif } static void VM_CharHandler(void); +extern GSM_Error N6110_SendStatusRequest(void); bool VM_ThreadLoop(void) { @@ -131,13 +136,18 @@ bool VM_ThreadLoop(void) FD_ZERO(&readfds); FD_SET(PtyRDFD,&readfds); - timeout.tv_sec=0; - timeout.tv_usec=500*1000; + FD_SET(device_portfd,&readfds); + timeout.tv_sec=2; + timeout.tv_usec=0;/*500*1000;*/ - res = select(PtyRDFD+1,&readfds,NULL/*writefds*/,NULL/*exceptfds*/,&timeout); + res = select((device_portfd > PtyRDFD ? device_portfd : PtyRDFD)+1, + &readfds,NULL/*writefds*/,NULL/*exceptfds*/,&timeout); switch (res) { case 0: /* Timeout */ +#if 0 + N6110_SendStatusRequest(); +#endif break; case -1: @@ -147,9 +157,12 @@ bool VM_ThreadLoop(void) return (false); default: - if (FD_ISSET(PtyRDFD,&readfds)) { + if (FD_ISSET(PtyRDFD,&readfds)) VM_CharHandler(); - } else usleep(500); /* Probably the file has been closed */ + if (FD_ISSET(device_portfd,&readfds)) + SigHandler(0); + if (!FD_ISSET(PtyRDFD,&readfds) && !FD_ISSET(device_portfd,&readfds)) + usleep(500); /* Probably the file has been closed */ break; } } @@ -335,8 +348,11 @@ static int VM_GetMasterPty(char **name) { /* search for an unused pty */ for (i=0; i<16 && master <= 0; i++) { for (j=0; j<16 && master <= 0; j++) { - (*name)[8] = "pqrstuvwxyzPQRST"[i]; - (*name)[9] = "0123456789abcdef"[j]; +static const char *ptyp8="pqrstuvwxyzPQRST"; +static const char *ptyp9="0123456789abcdef"; + + (*name)[8] = ptyp8[i]; + (*name)[9] = ptyp9[j]; /* open the master pty */ if ((master = open(*name, O_RDWR | O_NOCTTY | O_NONBLOCK )) < 0) { if (errno == ENOENT) {