This is the mail archive of the
cygwin@sourceware.cygnus.com
mailing list for the Cygwin project.
timeout-Problem
- To: cygwin at sourceware dot cygnus dot com
- Subject: timeout-Problem
- From: Michael Besl <michael dot besl at dwtgmbh dot de>
- Date: Tue, 22 Feb 2000 13:42:59 +0100
- Organization: DWT GmbH
- Reply-To: michael dot besl at dwtgmbh dot de
Hello there,
i have a problem with the structure termios. At my linux system i
used the termios.c_cc[VTIME] for timeout for receiving bytes over
/dev/ttyS1. At my linux system this functions great, but not at my
win98 maschine. Here the program waits till the end of the world
without breaking cause of timeout. What i´m doing wrong??
Also i have another problem with receiving bytes over com1 at the
same program on my win98 maschine. When the programm receives ca. a
10Byte-Block then there is no problem. But when a Byte-block > 10Bytes
then the bytes are not correctly received. But when i run linux at
this maschine, then it functions great. The pitty is that it must run
on win9x, but i don´t know what i doing wrong? I also didn´t find
anything about this in the mailarchives.
I´m using a Pentium III with onboard serial (16550A?!) and the
cygwin-b20. I add the problematic routine at this email. Perhaps
someone has experience in using serial connection with the cygnus-b20?
Thanks in advance
Mick
--
-----------------------
DWT GmbH
Bahnhofstr. 24
86663 Asbach-Bäumenheim
TEL +49 906/9230
FAX +49 906/9236
-----------------------
/* -------------------------- */
/* Diese Routine fragt die serielle Schnittstelle nach einem Byte ab
und beachtet dabei den übergebenen Timeout
IN:
int ser1 ----------------> Filedescriptor der seriellen Schnittstelle
char *buff --------------> Array mit mind. 1 Byte freiem Inhalt
int timeout -------------> Timeout in ms
FILE *logdateiname ------> Filedescriptor der Logdatei auf Platte
OUT:
Wert der Funktion <------- 0=alles OK, -1=konnte Byte nicht empfangen
char *buff <-------------- zeigt auf Byte, das empfangen wurde
*/
int char_von_ser_lesen (int ser1, char *buff, int timeout, FILE *logdateiname)
{
ssize_t dummy;
struct termios ser_attributes;
if (tcgetattr (ser1, &ser_attributes) < 0)
{
uhrzeit_schreiben (logdateiname);
fprintf (logdateiname, "Keine Daten von Schnittstelle bekommen!!\n");
}
ser_attributes.c_cc[VTIME] = timeout/100; /* timeout ist in ms angegeben! */
ser_attributes.c_cc[VMIN] = 0; /* auf ein Byte warten */
if (tcsetattr (ser1, TCSANOW, &ser_attributes) < 0)
{
uhrzeit_schreiben (logdateiname);
fprintf (logdateiname, "Keine Daten an Schnittstelle möglich!!\n");
}
if ((dummy = read (ser1, buff, 1)) != 1)
{
uhrzeit_schreiben (logdateiname);
fprintf (logdateiname, "Länge bei READ war: %d\n",dummy);
fprintf (logdateiname, "Timeout bei Byte-Empfang!!\n");
return -1;
}
else
{
/* uhrzeit_schreiben (logdateiname);
fprintf (logdateiname, "Es wurde erfolgreich %x empfangen\n",*buff);
fflush(logdateiname); */
}
return 0;
}
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com