X-Git-Url: https://git.jankratochvil.net/?p=gnokii.git;a=blobdiff_plain;f=common%2Fdata%2Fvirtmodem.c;h=c421fd1ac1e888d762203a29779715b5c4fc31e6;hp=664127f920f06bbe0994d0a235cc0e6b06243cb1;hb=5fe84d523d76fc6fb98eab34d0db5501bdc982e5;hpb=c7dcdfd34d2bed9cc64c5c9603e51ef8c8271951 diff --git a/common/data/virtmodem.c b/common/data/virtmodem.c index 664127f..c421fd1 100644 --- a/common/data/virtmodem.c +++ b/common/data/virtmodem.c @@ -51,6 +51,9 @@ /* Global variables */ + +#define GNOKII_DEV "/var/gnokii-dev" + //extern bool TerminateThread; /* Local variables */ @@ -61,7 +64,6 @@ int PtyWRFD; /* pty interface - only different in debug mode. */ static bool UseSTDIO; /* Use STDIO for debugging purposes instead of pty */ bool CommandMode; -static bool VM_ThreadLoop(void); static GSM_Error VM_GSMInitialise(char *model, char *port, char *initlength, GSM_ConnectionType connection, char *synchronizetime); static int VM_PtySetup(char *bindir); @@ -105,13 +107,18 @@ 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); -static bool VM_ThreadLoop(void) +bool VM_ThreadLoop(void) { int res; fd_set readfds; @@ -129,16 +136,21 @@ static bool VM_ThreadLoop(void) FD_ZERO(&readfds); FD_SET(PtyRDFD,&readfds); - timeout.tv_sec=0; - timeout.tv_usec=500*1000; + timeout.tv_sec=2; + timeout.tv_usec=0;/*500*1000;*/ res = select(PtyRDFD+1,&readfds,NULL/*writefds*/,NULL/*exceptfds*/,&timeout); switch (res) { case 0: /* Timeout */ +#if 0 + N6110_SendStatusRequest(); +#endif break; case -1: + if (errno==EINTR) + continue; perror("VM_ThreadLoop - select"); return (false); @@ -210,13 +222,13 @@ static int VM_PtySetup(char *bindir) #endif #ifdef DEBUG - fprintf (stderr, _("Slave pty is %s, calling %s to create /dev/gnokii.\n"), slave_name, + fprintf (stderr, _("Slave pty is %s, calling %s to create \"%s\".\n"), slave_name, #ifndef UCLINUX mgnokiidev #else /* UCLINUX */ "" #endif /* UCLINUX */ - ); + ,GNOKII_DEV); #endif /* DEBUG */ #ifndef UCLINUX @@ -228,10 +240,10 @@ static int VM_PtySetup(char *bindir) #else /* UCLINUX */ /* Remove symlink in case it already exists. Don't care if it fails. */ - unlink ("/dev/gnokii"); + unlink (GNOKII_DEV); /* Create symlink */ - err = symlink(slave_name, "/dev/gnokii"); + err = symlink(slave_name, GNOKII_DEV); #endif /* UCLINUX */