hw interrupt or sw interrupt??

Hi.

If I am sure that external data from some sensor can be read at serial port
exactly priodically, then which interrupt method is a good way for reading
them, hardware interrupt? or software interrupt by timer ??

Thanks !

Pasus

“Pasus” <pasus@mail.nu> wrote in message news:9tf23b$2jv$1@inn.qnx.com

Hi.

If I am sure that external data from some sensor can be read at serial
port
exactly priodically, then which interrupt method is a good way for reading
them, hardware interrupt? or software interrupt by timer ??

I would use timer_create() set of function and trigger a pulse to initiate
the read.

Thanks !

Pasus

Do you intend to deal with serial port hardware directly? Or do you intend to read data through the
driver? IMHO software interrupt is not a best way to deal with hardware (even if you use hardware
stack or smth else). What happens if serial line will damaged? You will read last received byte
everytime, no alarm (timeout) signal.

Eduard.

Pasus <pasus@mail.nu> wrote in article <9tf23b$2jv$1@inn.qnx.com>…

Hi.

If I am sure that external data from some sensor can be read at serial port
exactly priodically, then which interrupt method is a good way for reading
them, hardware interrupt? or software interrupt by timer ??

Thanks !

Pasus

Hi.
Thanks for reply.
I am going to read data through driver (by the way, how can I deal with
serial port dirctly? please explain it more…I am a beginner of real-time os
and implementation :slight_smile: .
So, you mean it is better to use h/w interrupt…

Thanks.

Pasus

Do you intend to deal with serial port hardware directly? Or do you intend
to read data through the
driver? IMHO software interrupt is not a best way to deal with hardware
(even if you use hardware
stack or smth else). What happens if serial line will damaged? You will
read last received byte
everytime, no alarm (timeout) signal.

Eduard.

Pasus <> pasus@mail.nu> > wrote in article <9tf23b$2jv$> 1@inn.qnx.com> >…
Hi.

If I am sure that external data from some sensor can be read at serial
port
exactly priodically, then which interrupt method is a good way for
reading
them, hardware interrupt? or software interrupt by timer ??

Thanks !

Pasus

“Pasus” <pasus@mail.nu> wrote in message news:9tgqnr$1si$1@inn.qnx.com

Hi.
Thanks for reply.

I am going to read data through driver (by the way, how can I deal with
serial port dirctly?

Check in8() and out8() and mmap_device_io() if you want to deal
with the hardware directly.


You should provide more information about what you are trying to do.

If the data are comming in the serial port automaticaly, all you need
to do (i’m simplifying) is a read() on the serial port. You could
also setup a notification pulse when serial data are comming in,
but that’s a little more advanced.

There are LOTS of ways of doing that…

If you need to read data at a fix time interval and must send
data on the serial to get some data back, then I would setup
a timer that trigger a pulse and upon reception of the pulse
call write() to send the command and then call read().


So, you mean it is better to use h/w interrupt…

It always depends on what you want to acheive exactly.
To say it’s better or worse would required more information

Thanks Mario for reply.

What I trying to do is just simple. A digital accelerometer set which gives
output at a fixed interval (for example 100 Hz) is connected serial port. I
want to read data through serial port at a same fixed time interval, and
after some calculating with these data, I want to display the results to
laptop monitor with reduced rate (for example 10Hz)…
In this case, which method is good?
Btw, what is notification pulse??

Thanks.

Pasus

“Pasus” <> pasus@mail.nu> > wrote in message news:9tgqnr$1si$> 1@inn.qnx.com> …
Hi.
Thanks for reply.

I am going to read data through driver (by the way, how can I deal with
serial port dirctly?

Check in8() and out8() and mmap_device_io() if you want to deal
with the hardware directly.


You should provide more information about what you are trying to do.

If the data are comming in the serial port automaticaly, all you need
to do (i’m simplifying) is a read() on the serial port. You could
also setup a notification pulse when serial data are comming in,
but that’s a little more advanced.

There are LOTS of ways of doing that…

If you need to read data at a fix time interval and must send
data on the serial to get some data back, then I would setup
a timer that trigger a pulse and upon reception of the pulse
call write() to send the command and then call read().


So, you mean it is better to use h/w interrupt…

It always depends on what you want to acheive exactly.
To say it’s better or worse would required more information
\

Pasus <pasus@mail.nu> wrote:

Thanks Mario for reply.

What I trying to do is just simple. A digital accelerometer set which gives
output at a fixed interval (for example 100 Hz) is connected serial port. I
want to read data through serial port at a same fixed time interval, and
after some calculating with these data, I want to display the results to
laptop monitor with reduced rate (for example 10Hz)…
In this case, which method is good?

Let the serial driver (devc-ser) read the data at 100 hz & buffer the
data. You read the data (in bigger chunks) when you want to at 10Hz.

Look at using readcond() or io_notify() to get dynamic notification from
the driver as to when there is “enough” data at the driver for it to
be worth your while to read it.

Or, you could use a timer (timer_create(), timer_settime()) to get a
notification using a pulse.

If you don’t know what a pulse is, I would strongly suggest that you
read through the (online) System Architecture guide. Understanding
pulses & message passing is fundamental to being able to write a
good system using QNX.

The “normal” and simple way you access a serial port under QNX is:

fd = open( “/dev/ser1”, …) /* get access /
bytes_read = read(fd, &buf, sizeof(buf) ); /
receive bytes /
bytes_sent = write(fd, &buf, sizeof(buf) ); /
transmit bytes */

-David

QNX Training Services
I do not answer technical questions by email.

Thanks David.

How about if I want to read the data at 100hz, finish calculation fastly and
show the results to monitor at 100hz…

0 0.01
0.02 sec
|--------------------------------|------------------------------------|-----
---------> time

read data read data

calculation calculation

show results show results

Thanks.

What I trying to do is just simple. A digital accelerometer set which
gives
output at a fixed interval (for example 100 Hz) is connected serial
port. I
want to read data through serial port at a same fixed time interval, and
after some calculating with these data, I want to display the results to
laptop monitor with reduced rate (for example 10Hz)…
In this case, which method is good?

Let the serial driver (devc-ser) read the data at 100 hz & buffer the
data. You read the data (in bigger chunks) when you want to at 10Hz.

Look at using readcond() or io_notify() to get dynamic notification from
the driver as to when there is “enough” data at the driver for it to
be worth your while to read it.

Or, you could use a timer (timer_create(), timer_settime()) to get a
notification using a pulse.

If you don’t know what a pulse is, I would strongly suggest that you
read through the (online) System Architecture guide. Understanding
pulses & message passing is fundamental to being able to write a
good system using QNX.

The “normal” and simple way you access a serial port under QNX is:

fd = open( “/dev/ser1”, …) /* get access /
bytes_read = read(fd, &buf, sizeof(buf) ); /
receive bytes /
bytes_sent = write(fd, &buf, sizeof(buf) ); /
transmit bytes */

-David

QNX Training Services
I do not answer technical questions by email.

“Pasus” <pasus@mail.nu> wrote in message news:9thi6o$oub$1@inn.qnx.com

Thanks David.

How about if I want to read the data at 100hz, finish calculation fastly
and
show the results to monitor at 100hz…

Because the device outputs data at 100hz, it can serve as a time base,

main() {

int cnt;

for( ;; ) {

wait_and_queue_data();

calculatrion();
show_result();

}

}

The wait_for_data() could use readcond to sit and wait for the expected
number of byte. If the devices send 10 bytes every 100hz, then you’d wait
for 1000 bytes, then process the data. If you don’t know the number of
bytes
you’d set readcond to wait a maximum of 100ms (10hz).

Since readcond supports timeout, you will be able to detect if the device
is not sending data in a timely fashion and handle the problem accordingly.

Each byte received by the serial port is buffered and handle by the serial
device. Even if your program takes more then 10ms to perform the
calculation and showing the result, no data will be lost. On the next
call to readcond, byte waiting in the serial driver buffer will be return.


0 0.01
0.02 sec

|--------------------------------|------------------------------------|-----
---------> time

read data read data

calculation calculation

show results show results

Thanks.

What I trying to do is just simple. A digital accelerometer set which
gives
output at a fixed interval (for example 100 Hz) is connected serial
port. I
want to read data through serial port at a same fixed time interval,
and
after some calculating with these data, I want to display the results
to
laptop monitor with reduced rate (for example 10Hz)…
In this case, which method is good?

Let the serial driver (devc-ser) read the data at 100 hz & buffer the
data. You read the data (in bigger chunks) when you want to at 10Hz.

Look at using readcond() or io_notify() to get dynamic notification from
the driver as to when there is “enough” data at the driver for it to
be worth your while to read it.

Or, you could use a timer (timer_create(), timer_settime()) to get a
notification using a pulse.

If you don’t know what a pulse is, I would strongly suggest that you
read through the (online) System Architecture guide. Understanding
pulses & message passing is fundamental to being able to write a
good system using QNX.

The “normal” and simple way you access a serial port under QNX is:

fd = open( “/dev/ser1”, …) /* get access /
bytes_read = read(fd, &buf, sizeof(buf) ); /
receive bytes /
bytes_sent = write(fd, &buf, sizeof(buf) ); /
transmit bytes */

-David

QNX Training Services
I do not answer technical questions by email.

Hi Pasus,
Sorry for delayed response, I was away :slight_smile:

Pasus <pasus@mail.nu> wrote in article <9tgqnr$1si$1@inn.qnx.com>…

Hi.
Thanks for reply.
I am going to read data through driver (by the way, how can I deal with
serial port dirctly? please explain it more…I am a beginner of real-time os
and implementation > :slight_smile: > .
So, you mean it is better to use h/w interrupt…

No. I meant it is better to use h/w interrupt if you are going to deal with hardware directly
(without driver). So, as far as you are going to use the driver, you have got the good suggestions
here. You could work directly with hardware regardless of OS which you are using (real-time or
not), but many of OS have some rules for it.

Eduard.

“ed1k” <ed1k@yahoo.com> wrote in message
news:01c173f8$6a57b0e0$106fa8c0@ED1K…

Hi Pasus,
Sorry for delayed response, I was away > :slight_smile:

Pasus <> pasus@mail.nu> > wrote in article <9tgqnr$1si$> 1@inn.qnx.com> >…
Hi.
Thanks for reply.
I am going to read data through driver (by the way, how can I deal with
serial port dirctly? please explain it more…I am a beginner of
real-time os
and implementation > :slight_smile: > .
So, you mean it is better to use h/w interrupt…

No. I meant it is better to use h/w interrupt if you are going to deal
with hardware directly
(without driver). So, as far as you are going to use the driver, you have
got the good suggestions
here. You could work directly with hardware regardless of OS which you are
using (real-time or
not), but many of OS have some rules for it.

Eduard.