Hi -
--- In Jim Jackson <> wrote:
>
>
>
>
> On Fri, 4 Jan 2008, JD wrote:
>
> > I have a simple example, using non blocking read that works _most_ of
> > the time.
You mean it sometimes works OK, without any hangs? For how long?
> >
> > It will start reading ok and print out the number of characters read
> > when a stream of data is applied, but after maybe 10 seconds, it stops
> > reading anything (read returns 0) even though data is being sent.
> >
> > Any ideas on why it would stop?
>
> Unfortunately No. Have you checked the same program and device on a
> desktop linux box? Does it all work ok?
>
> >
> > Code:
> > #include <sys/types.h>
> > #include <sys/stat.h>
> > #include <fcntl.h>
> > #include <string.h>
> > #include <unistd.h>
> > #include <termios.h>
> > #include <sys/ioctl.h>
> > #include <stdio.h>
> > #include <stdlib.h>
> > #include <inttypes.h>
> >
> >
> > void termConfigRaw(int fd,struct termios *saved,int baud_Enum);
> >
> > /*------------------------------------------------------------*/
> > int UART_init(uint8_t port, uint32_t baudrate)
> > {
> > int hCom = -1;
> > struct termios oldtio;
> > char buffer[100];
> >
> > sprintf(buffer,"/dev/ttyS%d", (port));
> >
> > printf("try open %d : '%s'\r\n", (int)port, buffer);
> >
> > hCom = open(buffer, O_RDWR | O_NOCTTY | O_NDELAY);
> > if (hCom == -1)
> > {
> > fprintf(stderr,"OpenSerial: Couldnt open %s:", buffer);
> > fflush(stderr);
> > perror(NULL);
> > return -1;
> > }
> > termConfigRaw(hCom,&oldtio,baudrate);
> >
> > // fcntl(hCom, F_SETFL, FNDELAY);
> >
> > return hCom;
> > }
> >
> > /*------------------------------------------------------------*/
> > void termConfigRaw(int fd,struct termios *saved,int baud_Enum) {
> > struct termios newtio;
> > int err;
> >
> > err = tcgetattr(fd,saved); /* save current port settings */
> > printf("tcgetattr: %d\r\n", err);
> > perror("tcgetattr:");
> >
> > /* Start with old settings, then we'll modify */
> > newtio = *saved;
> >
> > /* Set baudrate */
> > cfsetispeed(&newtio,baud_Enum);
> > cfsetospeed(&newtio,baud_Enum);
> >
> > newtio.c_cflag |= CREAD;
> > newtio.c_cflag &= ~CLOCAL;
Shouldn't this be |= CLOCAL? You want to ignore modem control lines,
right? Here you are not ignoring them. If they are floating, maybe
they are charging up in 10 or so seconds.
> >
> > // 8N1
> > newtio.c_cflag &= ~PARENB;
> > newtio.c_cflag &= ~CSTOPB;
> > newtio.c_cflag &= ~CSIZE;
> > newtio.c_cflag |= CS8; /* Set for 8 bits. */
> >
> > /* disable hardware flow control. */
> > newtio.c_cflag &= ~CRTSCTS;
> >
> > /* When we read, we want completely raw access */
> > /* the last two get set by default on ARM but not CYGWIN */
> > newtio.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG | NOFLSH | TOSTOP);
> > newtio.c_lflag = 0; // We don't believe above signals are set
> > correctly...
Why do you brute-force c_lflag here? Maybe that changes something you
are unaware of.
And, just to be sure, have you stopped the getty from inittab?
Regards, ......... Charlie
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|