Reading data from COM ports
Dar Scott
dsc at swcp.com
Tue Mar 19 10:40:00 EST 2002
On Tuesday, March 19, 2002, at 12:43 PM, Olaf Schmidtmann wrote:
> I am looking for a way to read data from a COM port continuously.
> The device
> measures electrical resistance and delivers values. Sadly I dont
> have any
> interface specs so I want to find a way to interpret what I find
> myself.
Since you mention COM, I assume you are on Windows. Use a terminal
program such as Hyperterminal to talk to the device. Fiddle with
the port parameters such as the bit rate until you see something
that might make sense. Note the bit rate and use it to set the
serialControlString property just before your open.
If you can't make any sense at any bit rate, the data might be in
binary. That is, most bytes sent are not meaningful as an ASCII
code. This can be painful to analyze and you might want to harass
the manufacturer for details. Or you can try using your Revolution
stack to read in uint (or convert later) and looking for patterns.
You might need to borrow a 'scope if experiments don't get you a
reasonable guess on the bit rate.
You can also use the terminal program to test your COM script.
Connect a null modem cable between COM1 and COM2. Open one with
the terminal program and open the other with your script. (You can
also use two computers.)
From your description, I have assumed the device repeatedly sends
data without stimulus from the computer. However, it may be it
needs a "command" from the computer. You might be able to get this
by the same loop-back method as above. Run the terminal program
first and then the current software.
(One of my mid-term goals in using Revolution is to make some
portable tools that can be used in analyzing situations like this.
LabView might be better for that, but it is expensive.)
I'm working on a simple card for some serial tests, but I have to
put that off for a couple days. Let us know how this works out for
you.
Dar Scott
More information about the use-livecode
mailing list