Serial Communication using Interrupt Handler

Hi all,

How to write the interrupt handler for serial communication in QNX 4.25?
Please tell me the compiler options to compiler such kind of programs.

I tried some programs but my system was halting everytime when I executed
it.
I used qnx_hint_attach/detach, qnx_proxy_attach/detach, but still the
problem exist.

Please if anyone can explain me.

Thanks in advance
Sunil Warke.

Sunil Warke <sunil@bnftech.com> wrote:

Hi all,

How to write the interrupt handler for serial communication in QNX 4.25?

If you are dealing with a simple/standard serial port, you usually don’t
write an interrupt handler at all. You run Dev.ser, and then you
fd = open("/dev/ser1", O_RDWR);
write(fd, buf, nbytes);
read(fd, buf, nbytes);

Plus all of the tcsetattr(), qnx_ioctl(), dev_read(), dev_arm() and
additional functions depending on how much control you want.

Please tell me the compiler options to compiler such kind of programs.

I tried some programs but my system was halting everytime when I executed
it.
I used qnx_hint_attach/detach, qnx_proxy_attach/detach, but still the
problem exist.

For general interrupt handler issues:

– put the interrupt handler in a different .c file from the rest of
your program
– compile your interrupt function .c file with -Wc,-S -zu
(these disable stack checking and say that DS != SS )
– don’t call anything that makes a kernel call while in your
interrupt handler

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

Thank you very much for replying.

I used write and read commands.
while writting it writes the complete “nbytes” to the serial port, but while
reading it reads only one byte at a time even though the “nbytes” (number of
bytes) is greater than one (1).
If i read the data from the file then it works properly but while reading
from serial port, it reads only one byte.

Also sometimes the comm port gets blocked and i could not select it using
Select command. It opens but can not be selected, the time out occurs. then
i have to restart the system to make it work again.
I do not know how to reset these ports instead of reseting the PC. Please
let me know it.

Actually I am not that much clear about the serial communication in QNX. My
understanding is, when the data comes it will be stored in the comm port
buffer and then we can read it using the read command. am I right?
I did the same.
In my project i can not wait for the serial data in the infinite loop. I
have to read it on the schedule only. I have programmed my scheduler. So
after each second i want to check the data in the buffer. if the data is
there then only i will read it.

I have to send 100 bytes and receive the same using serial communication on
QNX systems.
Please tell me how can i process it.

Thanks
Sunil


“David Gibbs” <dagibbs@qnx.com> wrote in message
news:adqv38$ma1$2@nntp.qnx.com

Sunil Warke <> sunil@bnftech.com> > wrote:
Hi all,

How to write the interrupt handler for serial communication in QNX 4.25?

If you are dealing with a simple/standard serial port, you usually don’t
write an interrupt handler at all. You run Dev.ser, and then you
fd = open("/dev/ser1", O_RDWR);
write(fd, buf, nbytes);
read(fd, buf, nbytes);

Plus all of the tcsetattr(), qnx_ioctl(), dev_read(), dev_arm() and
additional functions depending on how much control you want.

Please tell me the compiler options to compiler such kind of programs.

I tried some programs but my system was halting everytime when I
executed
it.
I used qnx_hint_attach/detach, qnx_proxy_attach/detach, but still the
problem exist.

For general interrupt handler issues:

– put the interrupt handler in a different .c file from the rest of
your program
– compile your interrupt function .c file with -Wc,-S -zu
(these disable stack checking and say that DS != SS )
– don’t call anything that makes a kernel call while in your
interrupt handler

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

A much simpler way than using interrupts is using proxies. Create a
proxy associate it. This will be received by your application when data
is available on the serial port. see the dev_…() functions. We use this
to by pass waiting for data. To implement timeouts generate a timer
proxy that is reset whenever data is received on the serial port

see the example in dev_arm()

Padraig Furlong

Sunil Warke wrote:

Thank you very much for replying.

I used write and read commands.
while writting it writes the complete “nbytes” to the serial port, but while
reading it reads only one byte at a time even though the “nbytes” (number of
bytes) is greater than one (1).
If i read the data from the file then it works properly but while reading
from serial port, it reads only one byte.

Also sometimes the comm port gets blocked and i could not select it using
Select command. It opens but can not be selected, the time out occurs. then
i have to restart the system to make it work again.
I do not know how to reset these ports instead of reseting the PC. Please
let me know it.

Actually I am not that much clear about the serial communication in QNX. My
understanding is, when the data comes it will be stored in the comm port
buffer and then we can read it using the read command. am I right?
I did the same.
In my project i can not wait for the serial data in the infinite loop. I
have to read it on the schedule only. I have programmed my scheduler. So
after each second i want to check the data in the buffer. if the data is
there then only i will read it.

I have to send 100 bytes and receive the same using serial communication on
QNX systems.
Please tell me how can i process it.

Thanks
Sunil


“David Gibbs” <> dagibbs@qnx.com> > wrote in message
news:adqv38$ma1$> 2@nntp.qnx.com> …

Sunil Warke <> sunil@bnftech.com> > wrote:

Hi all,

How to write the interrupt handler for serial communication in QNX 4.25?

If you are dealing with a simple/standard serial port, you usually don’t
write an interrupt handler at all. You run Dev.ser, and then you
fd = open("/dev/ser1", O_RDWR);
write(fd, buf, nbytes);
read(fd, buf, nbytes);

Plus all of the tcsetattr(), qnx_ioctl(), dev_read(), dev_arm() and
additional functions depending on how much control you want.

Please tell me the compiler options to compiler such kind of programs.

I tried some programs but my system was halting everytime when I

executed

it.
I used qnx_hint_attach/detach, qnx_proxy_attach/detach, but still the
problem exist.

For general interrupt handler issues:

– put the interrupt handler in a different .c file from the rest of
your program
– compile your interrupt function .c file with -Wc,-S -zu
(these disable stack checking and say that DS != SS )
– don’t call anything that makes a kernel call while in your
interrupt handler

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.