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
--
To UNSUBSCRIBE, email to debian-user-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Reply to: