Re: 8ms Timer for serial port access
From: Byron A Jeff (byron_at_cc.gatech.edu)
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: Jens Schumacher: "Re: 8ms Timer for serial port access"
- Reply: Jens Schumacher: "Re: 8ms Timer for serial port access"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 28 Oct 2003 19:27:33 -0500
In article <BBC465D9.1C95%jens.schumache@gmx.net>,
Jens Schumacher <jens.schumache@gmx.net> wrote:
-First of all, thank you very much...I appreciate you're help.
-
-
-
->> And I used it to synchronize the serial port with my application.
->
-> Don't know what that means.
->
-
-This means that right after I called the function to get the data, I call
-another function to handle the data. Seems not to be the best solution.
Of course it's the best solution.
-
->> Is there a big difference between running this driver in user space or as a
->> module?
->
-> Yes. There's a big difference. Writing a kernel module is a whole
-> different kettle of fish. Jdging by the questions you're asking you would
-> have a lot to learn if you wanted to write one. That's not to say that you
-> couldn't, but it would be a lot of work. If you _do_ want to do it, what
-> you probably want to do is write a "tty line discipline" module.
-
-Ok, so I should stay in userspace, since I have not a much time for the
-project.
Correct. Everything you need is accessible from user space.
->> I need a timer to load the data in the application and to process it.
->
-> I still don't understand why you need a timer. Why not just call read() and
-> process the data when it arrives.
->
-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.
-> Second: yes, changing it would be a lot of work. You would have to read
-> through all the kernel modules your system uses and make sure they don't
-> depend on the assumption that HZ==100.
-
-Yes thought so...but looks like a easy solution on the first sight.
Not worth the energy to accomplish this.
-
-> I hate to ask agian, but why not just call read() and tell it you want 24
-> bytes? Your program will sleep until 24 bytes have been received, then
-> read() will return.
-
-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 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.
BAJ
- 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: Jens Schumacher: "Re: 8ms Timer for serial port access"
- Reply: Jens Schumacher: "Re: 8ms Timer for serial port access"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|