ts-7000
[Top] [All Lists]

[ts-7000] Re: ts7200 2.4.26-ts11 second serial port problem - hangs in r

To:
Subject: [ts-7000] Re: ts7200 2.4.26-ts11 second serial port problem - hangs in read
From: "melloannapolis" <>
Date: Thu, 10 Feb 2011 07:23:03 -0000
New info -- the open is returning 0. No wonder it doesn't work. I'm a SYSV guy, 
wtf is going on here? The next available file descriptor should be 3 since 
0=stdin, 1=stdout and 2=stderr (i know those are file pointers but they map 
back to file descriptors -- or do they...)

thanks
pfm


--- In  "melloannapolis" <> wrote:
>
> I am booting vmlinux-7200-ts11.bin off CF and building native. I tested com2 
> and got a login prompt, declared it working and shut off the getty in inittab 
> so I could connect a GPS to it.
> 
> My prog is simple single character IO, it opens ttyAM1 and sets it to raw 
> mode and then hangs in read - the invoking terminal (on ttyAM0) can no longer 
> ^c out and the prog has to be killed from another window. There's plenty of 
> data arriving - I'd blame the settings except it seems the termio settings 
> are hitting the console on ttyAM0 or at least that would explain ^C not 
> working when the prog is running.
> 
> I have printfs at important points and the ones after the tcsetattr never 
> show up, but gdb says the prog has progressed and is sitting in read()...
> 
> Am I missing something about the second serial port on the 7200? Or possibly 
> I'm using the wrong device node... Any help is greatly appreciated. I'm stuck.
> 
> btw: I have a 4 line LCD connected to the LCD header and it's working good 
> but if I try to mount a flash filesystem on USB the LCD gets trashed and the 
> mount fails. The mount always fails regardless of what I'm doing with the 
> LCD. I've written this off as a missing USB module but I mention it here as 
> another datapoint.
> 
> thanks
> pfm
> 
> ---------------------------------------
> prog output:
> :tty# ./it
> opening
> getattrs
> flushing
> setting
> Killed   (from when I killed the process)
> ---------------------------------------
> Here's the gdb backtrace:
> :tty# gdb process 698
> GNU gdb 6.3-debian
> Copyright 2004 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and you are
> welcome to change it and/or distribute copies of it under certain conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB.  Type "show warranty" for details.
> This GDB was configured as "arm-linux"...process: No such file or directory.
> 
> Attaching to process 698
> Using host libthread_db library "/lib/libthread_db.so.1".
> Reading symbols from /home/pfm/tty/it...done.
> Reading symbols from /lib/libc.so.6...done.
> Loaded symbols for /lib/libc.so.6
> Reading symbols from /lib/ld-linux.so.2...done.
> Loaded symbols for /lib/ld-linux.so.2
> 0x2ab895c0 in read () from /lib/libc.so.6
> (gdb) bt
> #0  0x2ab895c0 in read () from /lib/libc.so.6
> #1  0x000087bc in main (argc=1, argv=0x7ffffe34) at it.c:77
> (gdb) q
> The program is running.  Quit anyway (and detach it)? (y or n) y
> Detaching from program: /home/pfm/tty/it, process 698
> :tty# kill -9 698
> 
> 
> ---------------------------------------
> Heres the code:
> #include <sys/types.h>
> #include <sys/stat.h>
> #include <errno.h>
> #include <fcntl.h>
> #include <termios.h>
> #include <stdio.h>
> 
> #define COM2 "/dev/ttyAM1"
> #define _POSIX_SOURCE 1
> 
> main(int argc, char ** argv)
> {
>     int fd, tty;
> 
>     struct termios oldtio, newtio;
> 
> fprintf(stderr,"opening\n");
>     if (fd = open(COM2, O_RDWR | O_NOCTTY | O_NDELAY) < 0) {
>         fprintf(stderr, "open failed: 0x%x\n", errno);
>         exit(errno);
>     }
> 
> fprintf(stderr,"getattrs\n");
>     if (tcgetattr(fd, &oldtio) < 0) {
>         fprintf(stderr, "tcgetattr failed: 0x%x\n", errno);
>         exit(errno);
>     }
> 
>     bzero(&newtio, sizeof(newtio)); // clear struct for new port settings
> 
> /* { */
> 
>     newtio.c_cflag = B4800 | CS8 | CLOCAL | CREAD;
>     newtio.c_iflag = IGNPAR | ICRNL;
>     newtio.c_oflag = 0;
>     newtio.c_lflag = 0; // wuz ICANON; but we don't want echo going on
> 
>     newtio.c_cc[VINTR]    = 0;     // cntrl-c
>     newtio.c_cc[VQUIT]    = 0;     // cntrl-\
>     newtio.c_cc[VERASE]   = 0;     // cntrl-H or del
>     newtio.c_cc[VKILL]    = 0;     // @
>     newtio.c_cc[VEOF]     = 4;     // cntrl-d
>     newtio.c_cc[VTIME]    = 0;     // interchar timer unused, 0 delay
>     newtio.c_cc[VMIN]     = 1;     // wait for up to 1 character
>     newtio.c_cc[VSWTC]    = 0;     //  '\0'
>     newtio.c_cc[VSTART]   = 0;     // Ctrl-q
>     newtio.c_cc[VSTOP]    = 0;     // Ctrl-s
>     newtio.c_cc[VSUSP]    = 0;     // Ctrl-z
>     newtio.c_cc[VEOL]     = 0;     // '\0'
>     newtio.c_cc[VREPRINT] = 0;     // Ctrl-r
>     newtio.c_cc[VDISCARD] = 0;     // Ctrl-u
>     newtio.c_cc[VWERASE]  = 0;     // Ctrl-w
>     newtio.c_cc[VLNEXT]   = 0;     // Ctrl-v
>     newtio.c_cc[VEOL2]    = 0;     // '\0'
> 
> fprintf(stderr, "flushing\n");
>     tcflush (fd, TCIFLUSH);
> 
> /* } */
> 
> /* this doesn't help, same symptom
>     cfmakeraw(&newtio);
>     cfsetispeed(&newtio, B4800);
>     cfsetospeed(&newtio, B4800);
> */
> 
> fprintf(stderr, "setting\n"); // we always see this
> 
>     if (tcsetattr(fd, TCSANOW, &newtio) < 0) {
>         fprintf(stderr,"tcsetattr failure: 0x%x\n", errno);
>     }
> 
> fprintf(stderr, "io control done, start reading\n"); // we never see this
> 
>     int i, stop = 0;
>     char buf[256];
>     while (stop == 0) {
>         i = read (fd, buf, 255); // line 77 - blocks forever here
>         buf[i] = '\0';
>         fprintf(stderr,":%s:%d\n", buf, i);
>         if (buf[0] == 'z') stop=1;
>     }
>     tcsetattr(fd, TCSANOW, &oldtio);
> 
>     fprintf(stderr,"done\n");
> }
> ----------------------------
> termio settings while program is running:
> :tty# stty -a < /dev/ttyAM1
> speed 4800 baud; rows 0; columns 0; line = 0;
> intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
> eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;
> lnext = ^V; flush = ^O; min = 1; time = 0;
> -parenb -parodd cs8 hupcl -cstopb cread clocal -crtscts
> -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon
> -ixoff -iuclc -ixany -imaxbel
> -opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0
> ff0
> -isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase -tostop
> -echoprt -echoctl -echoke
>




------------------------------------

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/

<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU