RS232 opearation on QNX neutrino.....

Hello Gurus,

 greeetings.....!


 Can you please tell me how do i send/receive data through RS232 communication. What are the drivers do i have to run?

Thank you in advance.

-Suren.

Writing is a lot easier than reading:

const char[] PORT_NAME = "/dev/ser1"; int port; ... port = open(PORT_NAME, O_WRONLY); if (port < 0){ return FAILURE; } write(port, data, data_len); close(port);
“data” in this case is arbitrary binary data. Frequently it is desirable to send ASCII text instead of binary, in which case the code becomes:

const char[] PORT_NAME = "/dev/ser1"; FILE *port; ... port = fopen(PORT_NAME, "w"); if (port == NULL){ return FAILURE; } fprintf(port, "Hello, %s! Important number is: %d", PORT_NAME, some_int); fflush(port); fclose(port);

The problem with reading is that reading blocks. There are numerous ways around this problem, but the most obvious is to have your reads in a seperate program. You could also use select(), or set read to return immediately if there is nothing to read. In this example, I just block.

const char[] PORT_NAME = "/dev/ser1"; int port; int size char [100] data; ... port = open(PORT_NAME, O_RDONLY); if (port < 0){ return FAILURE; } ... while(some_condition){ size = read(port, data, 99); ...// do whatever } close(port);

Incidentally, this isn’t copy-pasted out of a working program, so I can’t swear everything compiles.

Last point; to set up the serial port use stty from a command line:
stty baud=9600 bits=8 par=none stopb=1 -ihflow -ohflow < /dev/ser1

The first 4 are fairly obvious; the -ihflow and -ohflow turn off hardware flow control, and of course the < redirects so the correct port is set.

-James Ingraham
Sage Automation, Inc.

Thats very nice of James Ingraham.

  Even iam working on RS232 serial comm with QNX. Is there any sample code for transfering Files  from Qnx(source)  to Windows(destination) using (ZMODEM).

Thank you in advance…

I don’t think you need sample code for this. I haven’t check whether zmodem is compiled for QNX 6, but the source is fairly available. I also think that qtalk had an option to transfer using zmodem.

For read better use “readcond”, which provides time-out functionality.
Regards,
-vari

Yes zmodem is compiled for Qnx and you can transfer file using zmodem in QNX. But the question is how do i transfer file using c++ programme?

for eg:

int fd = open ("/dev/ser1",…);

using fd i can send data to remote system on RS232. for eg

write(fd,“Hello”,5);

This will just output the data to the stream. How do i transfer/send FILE from Qnx system to windows system?

-Thank you in advance.

Me too same problem as HideAndSeek.

 Please tell me how do i transfer file over RS232.

 Qnx is my source.

 Windows is my destination.

 HideAndSeek pls let me know if you have the logic.....

thanks.

You can get the source to zmodem and incorporate it in your program, or simply save the data you want to transfer in a file and use system(“sz filename”);

I have the same problem about qtalk.
I can’t tranfer file from QNX to Windows Xp with zmodem. I get the problem :

Retry 0: Timeout on pathname.

Please help me… Thanks!