[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Reading data from /dev/ttyS0



> I'm trying to get a program that reads serial data working.  I'm looking
> for some debugging tips.
> 
> I've got an X10 mouse-remote (JR20 RF remote,and JR21A receiver).  I was
> using it on a Windows machine to run winamp.  Now I'm trying to get it
> to work with linux.  It's a remote control for controlling the mouse,
> but also has a number of other buttons.  It looks like a universal
> remote control.
> 
> The receiver can plug into a PS2 or serial port.  On my windows machine
> I plugged it into a serial port.  I've now plugged it into my serial
> port on the Debian machine.
> 
> It seems like the serial port is receiving data:
> 
> $ cat /proc/tty/driver/serial
> serinfo:1.0 driver:5.05c revision:2001-07-08
> 0: uart:16550A port:3F8 irq:4 baud:9600 tx:3332 rx:1951 brk:1381
> RTS|CTS|DTR
> 
> Click a few buttons on the remote and the counts change:
> 
> $ cat /proc/tty/driver/serial
> serinfo:1.0 driver:5.05c revision:2001-07-08
> 0: uart:16550A port:3F8 irq:4 baud:9600 tx:3359 rx:1969 brk:1390
> RTS|CTS|DTR
> 
> So that tells me that the hardware is working.  
> 
> My understanding of devices in linux is quite fuzzy.  I'm using a
> program by Kevin Boone called mouse_remoted that reads from the device,
> looks at the character codes and then writes the mouse specific data to
> /dev/mouse_remote, and the other data to /dev/pc_remote.  The idea is
> you have a program that reads from /dev/pc_remote that controls things
> (like volume and start/stop/pause for xmms).
> 
> By default, the program reads from /dev/mouse.  On my machine that is:
> 
>   wxrwxrwx    1 root root   7 Feb 24 12:05 /dev/mouse -> gpmdata
> 
>   prw-r--r--   1 root root    0 Apr 10 11:58 /dev/gpmdata
> 
> 
> But, I'm connected to the serial port, so I changed the program to read
> from /dev/ttyS0 and recompiled.
> 
>     crw-rw-r--    1 root dialout 4,  64 Jan 24 08:26 /dev/ttyS0
> 
> The program starts, and claims it's reading, but then nothing happens. 
> The program is not complicated, but it does use threads, which I'm not
> familiar with.  
> 
> First it opens /dev/ttyS0:
>     fi = open (MOUSE, O_RDONLY | O_NOCTTY);
> 
> then later.
> 
> BYTE readByte(int fi)
>         {
>         char buf[2];
> printf("About to read a byte\n");
>         read (fi, buf, 1);
> printf("Read %02x\n", buf[0]);
>         return buf[0];
>         }
> 
> It hangs after saying "About to read a byte" in this function.  So the
> read() is blocking.
> 
> So, ah, well, any suggestions??
> 
> Is there an easy way to dump the chars from /dev/ttyS0? 
> 
> Thanks,
> 
> -- 
> Bill Moseley
> 


$ grep-available snooper
Package: snooper
Priority: optional
Section: comm
Installed-Size: 40
Maintainer: David Coe <davidc@debian.org>
Architecture: i386
Version: 19991202-2
Depends: libc6 (>= 2.2.4-4), liblockdev1, libncurses5 (>= 
5.2.20010310-1)
Filename: pool/main/s/snooper/snooper_19991202-2_i386.deb
Size: 13430
MD5sum: c8d903ea4a5e399a19eb1439e8eb01d7
Description: TTY Snoop - allows you to spy on telnet+serial connections
 TTYSnoop allows you to snoop on login tty's through another tty-device 
or
 pseudo-tty. The snoop-tty becomes a 'clone' of the original tty,
 redirecting both input and output from/to it.

shaul@rakefet:/tmp$ grep-available snoop |less
shaul@rakefet:/tmp$ grep-available snooper    
Package: snooper
Priority: optional
Section: comm
Installed-Size: 40
Maintainer: David Coe <davidc@debian.org>
Architecture: i386
Version: 19991202-2
Depends: libc6 (>= 2.2.4-4), liblockdev1, libncurses5 (>= 
5.2.20010310-1)
Filename: pool/main/s/snooper/snooper_19991202-2_i386.deb
Size: 15062
MD5sum: 86ecef0d8e5493b6d291a293aa171e34
Description: Captures communication between two external serial devices
 Snooper passes data transparently between two serial (RS232C)
 devices, capturing and logging the data and occasional comments you
 want to insert into the logs.
 .
 It is useful for debugging or analyzing the communications protocol
 between two devices that would normally be connected directly to each
 other, e.g. a digital camera and a personal computer.  By sitting
 "in the middle" (after you connect the two devices to serial ports
 on your Linux machine) snooper is able to capture data traveling in
 either direction while also passing it unmodified to the other device.
 .
 It is also possible to operate with a single serial device, using
 your console and keyboard as the second device.

$

You might also find the /usr/share/doc/HOWTO/en-txt/Serial-Programming-H
OWTO.gz relevant as well as the references is has for `Other Sources of 
Information'.

Can you reports your conclusions back to the list?

-- 

    Shaul Karl
    email: shaulka(replace with the at - @ - character)bezeqint.net 



-- 
To UNSUBSCRIBE, email to debian-user-request@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org



Reply to: