Re: 8ms Timer for serial port access
From: Byron A Jeff (byron_at_cc.gatech.edu)
Date: 10/29/03
- Next message: Daniel Hofmann: "Re: 8ms Timer for serial port access"
- Previous message: Davide Guolo: "Re: sys_nerr vs strerror"
- In reply to: Jens Schumacher: "Re: 8ms Timer for serial port access"
- Next in thread: David Schwartz: "Re: 8ms Timer for serial port access"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 29 Oct 2003 11:40:41 -0500
In article <BBC47FB6.1CAA%jens.schumache@gmx.net>,
Jens Schumacher <jens.schumache@gmx.net> wrote:
-Am 28/10/03 19:27 Uhr schrieb "Byron A Jeff" unter <byron@cc.gatech.edu> in
-bnn1hl$lqc@cleon.cc.gatech.edu:
-
-> -I programmed in C++. So there is there is one Object which handles the
-> -serial port connection and puts the data in some variables. There is another
-> -Object with a graphical interface which displays the data and draws a graph
-> -etc. To get the data, I call a function in the "serial port object" which
-> -returns me the current values. And this is done with a timer. Maybe I should
-> -change the object hierarchy, but I thought it is nice to have a independent
-> -serial port object.
->
-> That organization is fine. You simply want to poll the serial object for
-> new data. Let the serial driver handle the receipt of the data.
-
-OK got this, but there is the problem. How can I poll the data with a
-frequency of 120Hz. When I use a timer, the best case I can get is a
-temporal resolution of 100Hz, right?
You don't poll using a timer. You simply sleep waiting for data from the
serial port. The receipt of the data will trigger the continuation of the
application. No timer is necessary.
-
-> -The read function returns the number of bytes it managed to read from the
-> -buffer, doesn't matter how many bytes you want to read. So, as far is I
-> -know, there is nothing like a sleep until 24 bytes are received, or is
-> -there? Don't know any other nice solution without keeping the cpu busy.
-> -One way would be to ask in a while if 24 bytes are in the buffer and then
-> -call the read function. But I'm not sure if this is a nice solution.
->
-> 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. If I insert a sleep I'm limited again to
-the 100Hz Kernel frequency. And as described the delay should be as minimal
-as possible. Can I use this timestamp without running into this 100Hz limit?
You can do this by not sleeping, or by sleeping on something that isn't
subject to the timer resolution, like the serial port.
-> But there certainly isn't a need for you to attempt real time management of
-> the serial port. The kernel driver will handle the port. All you need to do
-> is talk to the driver.
-
-This is all I want. Would be nice if I could do this that easily. Maybe I
-just think to complicated at the moment. But I'm really confused.
Keep it simple: just read the serial port and run the rest of your program
after you read 24 bytes of data. Everything else will follow fine from there.
BAJ
- Next message: Daniel Hofmann: "Re: 8ms Timer for serial port access"
- Previous message: Davide Guolo: "Re: sys_nerr vs strerror"
- In reply to: Jens Schumacher: "Re: 8ms Timer for serial port access"
- Next in thread: David Schwartz: "Re: 8ms Timer for serial port access"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|