git://git.jankratochvil.net
/
gnokii.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Untested attempt to get rid of SIGIO pain
[gnokii.git]
/
common
/
data
/
virtmodem.c
diff --git
a/common/data/virtmodem.c
b/common/data/virtmodem.c
index
664127f
..
169b117
100644
(file)
--- a/
common/data/virtmodem.c
+++ b/
common/data/virtmodem.c
@@
-51,6
+51,9
@@
/* Global variables */
/* Global variables */
+
+#define GNOKII_DEV "/var/gnokii-dev"
+
//extern bool TerminateThread;
/* Local variables */
//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 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);
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);
}
return (false);
}
+#ifndef UCLINUX
/* Create and start thread, */
return VM_ThreadLoop();
/* Create and start thread, */
return VM_ThreadLoop();
+#else
+ return true;
+#endif
}
static void VM_CharHandler(void);
}
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;
{
int res;
fd_set readfds;
@@
-129,23
+136,33
@@
static bool VM_ThreadLoop(void)
FD_ZERO(&readfds);
FD_SET(PtyRDFD,&readfds);
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 */
switch (res) {
case 0: /* Timeout */
+#if 0
+ N6110_SendStatusRequest();
+#endif
break;
case -1:
break;
case -1:
+ if (errno==EINTR)
+ continue;
perror("VM_ThreadLoop - select");
return (false);
default:
perror("VM_ThreadLoop - select");
return (false);
default:
- if (FD_ISSET(PtyRDFD,&readfds))
{
+ if (FD_ISSET(PtyRDFD,&readfds))
VM_CharHandler();
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;
}
}
break;
}
}
@@
-210,13
+227,13
@@
static int VM_PtySetup(char *bindir)
#endif
#ifdef DEBUG
#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 */
"<uClinux>"
#endif /* UCLINUX */
#ifndef UCLINUX
mgnokiidev
#else /* UCLINUX */
"<uClinux>"
#endif /* UCLINUX */
- );
+
,GNOKII_DEV
);
#endif /* DEBUG */
#ifndef UCLINUX
#endif /* DEBUG */
#ifndef UCLINUX
@@
-228,10
+245,10
@@
static int VM_PtySetup(char *bindir)
#else /* UCLINUX */
/* Remove symlink in case it already exists. Don't care if it fails. */
#else /* UCLINUX */
/* Remove symlink in case it already exists. Don't care if it fails. */
- unlink (
"/dev/gnokii"
);
+ unlink (
GNOKII_DEV
);
/* Create symlink */
/* Create symlink */
- err = symlink(slave_name,
"/dev/gnokii"
);
+ err = symlink(slave_name,
GNOKII_DEV
);
#endif /* UCLINUX */
#endif /* UCLINUX */
@@
-331,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++) {
/* 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) {
/* open the master pty */
if ((master = open(*name, O_RDWR | O_NOCTTY | O_NONBLOCK )) < 0) {
if (errno == ENOENT) {