Luiz Costa
|
Re-sent: Using open(), write() and read() to communicate w/ dev/ser* ...
|
Luiz Costa
01/22/2010 4:26 PM
post45811
|
Re-sent: Using open(), write() and read() to communicate w/ dev/ser* ...
I'm resubmitting this message in plain text for the reader's
convenience. The First posting came up too confusing with the html
mark-ups. Sorry for the inconvenience.
----------------------------------posting
start------------------------------
I was just admitted to the Community Project and I'm a novice, at best,
in QNX.
I am setting up a RTOS lab at Ferris State, using Momentics over
several different platforms to program companion Neutrino nodes.
The Neutrino (x86 w/ BIOS) nodes are connected to small lab robots
through an RS232. I've stablish basic communication with open()
function (fcntl.h). Accordinng to robot doc, I need to sent the string
with command syntax (cr at the end), and immediately after, read the
content buffer which should have <0cd>, indicating syntax error, <1cr>,
indicating successful reception of command, and <2cr> if a "stop"
button in a hand-held keypad is pressed during command
transmission/processing by the robot.
When I open the port (/dev/ser1) I do so with O_RDWR)
Problem is: I can never get out from read() O_NONBLOCKING is clear, or
I always get <-1> when O_NONBLOCKING is set.
This is the open() segment when O_NONBLOCKING is set:
if((fd = open ("/dev/ser1", O_RDWR | O_NONBLOCK)) == -1)
{
fprintf(stderr, "Error with open() on /dev/ser1. Make sure
exists.\n");
perror (NULL);
exit(EXIT_FAILURE);
}
Any clue on what I'm beating my head against here? Should I delve into
something different like readcond()?
Please, let me know whta direction I should take.
Thanks in advance,
--------------------------------------------------------------------
Luiz Costa
ELECTRICAL/ELECTRONICS ENGINEERING TECHNOLOGY - COMPUTER NETWORKS &
SYSTEMS
College of Engineering & Technology
915 Campus Drive SWN 405
Big Rapids, MI 49307
231.591.3086 Phone - 231.591.2271 Fax
|
|
|