reading data from serial/parallel port(s)
David Doll
davidd at june.cs.washington.edu
Wed May 15 01:34:50 AEST 1991
Hello,
I was wondering if any of you would mind sharing some of your
experience with low level codeing dealing with reading data from a serial (or
parallel port - does it matter?) port. I haven't done anything like this before
and appreciate any help you could offer.
The objective is:
I'll have some C-code being the master program. It'll be reading
data from a serial( or maybe parallel, but probility serial?) port which is
just five buttons (like joy stick or mouse buttons) that can be pushed. the
other component (of the overall incoming data picture) is data coming from an
RS232, which is data that will be polled at some small time unit.
I would like to be able to read the button(s) push as just an on/off and if
the button is held on then a steady stream of on's. If two buttons are
pushed at the same time, I don't want any thing to happen. The data coming from
the RS232 will be just a change in six different parameters.
I looked around and it seems like I'll need something like ioctl. Now is where
the confusion comes in! So I found some structures:
struct sgttyb {
char sg_ispeed; /* input speed */
char sg_ospeed; /* output speed */
char sg_erase; /* erase char */
char sg_kill; /* kill char */
char sg_flags; /* mode flag */
};
struct tchars {
char t_intrc; /* interrupt */
char t_quitrc; /* quit */
char t_startc; /* start ouput */
char t_stopc; /* stop output */
char t_eofc; /* end of file */
char t_brkc; /* input delimiter */
};
Ok, so I (assume) need to set up some event loop which is going to act on some
change in data from both data sets. Now I'm not sure how to handle using the
above (or something else which I don't know about) to read the data. I'm
confused, how do I know what to set the baud rate to be? I saw something that
had ioctl(fd, TIOGETD, &ldisc) in it's code; fd is supposed to be the file
descripter refering to a serial line: what exactly is the name you're supposed
to use? I couldn't find any examples to help illustrate the enlightened path!
and my brain is acting like tofo right now...I assume there are other issues
to consider here; timing of everything, A friend also mumbled something about
non-blocking I/O needed,what's the value of using serial verus parallel ports-
isn't serial a little more verstal than parallel?, etc. Perhaps this is more
on the harware side(?); the determination of which button is pushed, i.e.
button A pushed means something different (a different parameter will be
changed, i.e.some graphic object gets smaller or larger, etc) than if button B
is pushed.
If you could e-mail me that would be great. Thanks for your time and help.
--
David Doll
Human Interface Technology Laboratory
University of Washington
Seattle, WA 98195
MS: FJ-15
(206) 685-3061
davidd at hitl.vrnet.washington.edu
More information about the Comp.lang.c
mailing list