Re: 8ms Timer for serial port access
From: Grant Edwards (grante_at_visi.com)
Date: 10/29/03
- Next message: Jens Schumacher: "Re: 8ms Timer for serial port access"
- Previous message: Jens Schumacher: "Re: 8ms Timer for serial port access"
- In reply to: Jens Schumacher: "Re: 8ms Timer for serial port access"
- Next in thread: Byron A Jeff: "Re: 8ms Timer for serial port access"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 29 Oct 2003 01:41:19 GMT
In article <BBC47FB6.1CAA%jens.schumache@gmx.net>, Jens Schumacher wrote:
> OK got this, but there is the problem. How can I poll the data with a
> frequency of 120Hz.
You don't. Just call read() until you have enough data to
process. Then process it. Then start calling read() again.
Forget about the whole 120Hz business. That's completely
hidden from you by the OS and device driver. All you're going get is a
stream of bytes that you acquire by calling read().
> When I use a timer, the best case I can get is a
> temporal resolution of 100Hz, right?
Right. Forget about timing. Forget about 100Hz. Forget about
120Hz. Forget about timing.
>> You'll have to loop that yourself. But since you know data is going to show
>> every 8 ms, you can simply timestamp the last time you read the port, and
>> if more than 8ms has elapsed, read the new data.
>
> But how can I trigger the event.
What event??
1) Call read() in a loop until you've got enough data to do
something. If you're in-sync, that's 24 bytes. If you're
not in sync yet, it's 47 bytes (minimum number of bytes you
can read and be guaranteed that you have a complete frame).
2) Do something with the data.
3) Goto 1)
You'll need to be able to detect where frames are in the data
stream. Hopefully there's a start-of-record byte and/or an
end-of-record byte.
--
Grant Edwards grante Yow! Is this an out-take
at from the "BRADY BUNCH"?
visi.com
- Next message: Jens Schumacher: "Re: 8ms Timer for serial port access"
- Previous message: Jens Schumacher: "Re: 8ms Timer for serial port access"
- In reply to: Jens Schumacher: "Re: 8ms Timer for serial port access"
- Next in thread: Byron A Jeff: "Re: 8ms Timer for serial port access"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|