[PLUG] Serial Port Programming

Terry Griffin griffint at pobox.com
Fri Oct 29 04:05:13 UTC 2004


On Thursday 28 October 2004 8:14 pm, Richard C. Steffens wrote:
> I'm playing with a device called an X-10 Powerhouse model CP290. It's a
> computer interface for the X-10 home control system* that connects to a
> computer via a serial port. I used to have it connected to my old DOS
> laptop running software that came with it many years ago (1980's, I think).
> For some reason, this software will not work with Pentium class processors,
> and although I've never found an explanation, in my experience, it is true.
> This little device has worked well for years, only needing to be reloaded
> after a power failure.
>
> A few weeks ago, the hard drive on the laptop died. I decided that it was
> time to find a Linux solution to communicating with the thing and went
> looking on the web. I found a program**, downloaded and compiled it, and
> tried to get it to work. I've gotten it to the point where I've confirmed
> that I'm trying to talk to the right serial port, ttyS0, made the correct
> owner:group assignments, and made the error message change from not being
> able to open the serial port to Input/output error.
>
> The first time I compiled it, I didn't notice a warning:
>
> tty.c: In function `setup_tty':
> tty.c:96: warning: passing arg 2 of `connect' from incompatible pointer
> type
>
> Lines 95-98 read:
>
>   /* connect to serial port daemon */
>   r = connect (tty, &inaddr, size of (inaddr));
>   if (r==0)
>  return;
>
> As this message is already getting long, I'll start by asking: is chasing
> this warning  likely to be productive in getting communication working
> between the computer and the CP290? If not, do you have any suggestions as
> to where to look. (I realize that I haven't provided much of the code from
> the file tty.c, and will do so for anyone who'd like to look deeper.)
>
> A couple of other details: The CP290 has a simple RS-232 hardware
> interface, three wires: Transmit, Receive, Ground. There is no hardware
> handshake.
>
> With a little light box just attached to the CP290 the green LED for RD
> lights up. With it just attached to my laptop, TD, RTS, and DTR are lit***.
>
> Alternatively, can anyone recommend an example of a working program that
> can communicate with a serial port and let me set the baud rate, parity,
> stop bits, etc, without that program needing to hear back from the device
> on the other end of the port right away? (I've tried cu, but it appears to
> want more in the way of handshaking from a terminal, or modem, or
> something.)
>
> Thanks for any advice.

The CP290 is an odd beast. It communicates at 600 baud but it requires
a one millisecond delay between each transmitted byte. It's that delay, if 
poorly implemented, that breaks when you move CP290 control software
up to a faster PC. I think your best bet is to find that delay mechanism
in the code and either tune it for your PC or fix it properly for all PCs.
I don't think the compiler warning is the source of your problem.

I'm in the middle of a from-scratch implementation of X10 control software
using Python and pyserial. The CP290 portion is working more or less
though there's still a lot of clean-up to do before I'm ready to thrust it on
to the world. The one millisecond delay is implemented using Python's
time.sleep() function. This works fine on my development box. It will be
interesting to see what happens when it's exposed to other computers.

I'm also planning for the CM11A and CM17A controllers. I have nothing at
all for those yet.

Terry




More information about the PLUG mailing list