Luiz Costa
|
Using open(), write() and read() to communicate w/ dev/ser* ...
|
Luiz Costa
01/18/2010 10:55 PM
post45444
|
Using open(), write() and read() to communicate w/ dev/ser* ...
<p>I was just admitted to the Community Project and I'm a novice, at best, in QNX.</p><p>I am setting up a RTOS lab at
Ferris State, using Momentics over several different platforms to program companion Neutrino nodes.</p><p>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.</p><p>When I open the port (/dev/ser1) I do so with O_RDWR)</p><p>Problem is: I
can never get out from read() O_NONBLOCKING is clear, or I always get <-1> when O_NONBLOCKING is set.</p><p>This is
the open() segment when O_NONBLOCKING is set:</p><p> if((fd = open ("/dev/ser1", O_RDWR | O_NONBLOCK)) == -1)<br />
{<br /> fprintf(stderr, "Error with open() on /dev/ser1. Make sure exists.\n");<br /> perror (NULL);<br />
exit(EXIT_FAILURE);<br /> }</p><p>Any clue on what I'm beating my head against here? Should I delve into something
different like readcond()?</p><p>Please, let me know whta direction I should take.</p><p> </p><p>Thanks in advance,</p><
p> </p><br /><br />--------------------------------------------------------------------<br />
<br />Luiz Costa
<br />ELECTRICAL/ELECTRONICS ENGINEERING TECHNOLOGY - COMPUTER NETWORKS &
<br />SYSTEMS
<br />College of Engineering & Technology
<br />915 Campus Drive SWN 405
<br />Big Rapids, MI 49307
<br />231.591.3086 Phone - 231.591.2271 Fax
|
|
|