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"
    Date: 28 Oct 2003 19:53:58 -0500
    
    

    In article <BBC472F9.1C9E%jens.schumache@gmx.net>,
    Jens Schumacher <jens.schumache@gmx.net> wrote:
    -Hello,
    -
    -> Since you are newbie, and I'm confused, would you mind if we started over?
    ->
    -> Here's what I got from above:
    ->
    -> 1) Device sends data via the serial port.
    -> 2) You need to collect the data.
    -> 3) You do not want to lose any data.
    -That's right

    Cool.

    -
    -> But there's a bunch missing:
    ->
    -> 1) What bit rate is the data transmitted?
    -The bit rate is 38400 bps

    Slow.

    -
    -> 2) Does the data need to be timestamped?
    -Not really necessarily

    Great.

    -
    -> 3) Is the data bursty or does it come in a steady stream?
    -The data comes in a steady stream with 120 Hz

    Ultra Slow.

    -
    -> 4) What makes you think that the data will overrun the serial port and kernel
    -> driver?

    -The Code at the moment calls the read function with a timer. If this timer
    -is not triggered every 8ms, the next data comes to the buffer and the old
    -data is still there...if this happens very often the buffer overflows and I
    -loose data.

    But that's if you're handling the task in user space by hand, right? I mean
    you are making inpb calls to read directly from the serial port, correct?
    That's what I got from your original message when you said "user space and
    no module is loaded."

    No. That's not right. You state above "... calls the read function with a
    timer." So that means you are using the serial driver. OK. Question answered
    here so I'm moving on...

    -
    -> I'm still trying to figure out what you require from the OS. Care to explain
    -> the goals of the application?
    -
    -Here my application goals in detail.
    -
    -1) I use an Eye-tracking System which operates on the serial port with
    -38400bps.

    OK.

    -2) The Eyetracker sends a package of 24bytes at 120Hz to the serial port.

    No problem.

    -3) I have to read, proceed and display this data. And this as fast as
    -possible since I need to detect very fast eye movements.

    OK. So the application is serial port driven then right? Is there anything else
    that needs to happen between between these events? If not then the advise you
    have been getting in this thread is correct: loop on the read until you have
    24 bytes, update everything, then go back to the top of the event loop and
    wait for the next 24 bytes from the ET.

    This is classic event programming. No timer is required.

    -
    -Do you need more datail?

    Nope. It's clear now.

    -I could explain my current implementation, but not sure if it's helpful. But
    -if you need more details about this I can describe it.

    Unless something else is going on, you need not worry about having a timer.
    Your process will sleep on a read of the serial port if nothing is ready.
    A normal blocking read will only return when it has at least 1 byte of data.

    -
    -
    -Thank you all so much.

    No problem.

    BAJ


  • Next message: Jens Schumacher: "Re: 8ms Timer for serial port access"

    Relevant Pages

    • Re: Serial port monitoring
      ... There is no need for a timer; you want to get data when it is available, ... The main thing is that every 100ms or so you check the serial port and read ... I would then have a loop that checks for char in serial buffer. ...
      (microsoft.public.vc.mfc)
    • Re: Serial port monitoring
      ... There is no need for a timer; you want to get data when it is available, ... line in the serial port, then by the time of the next trigger the rest has ... I would then have a loop that checks for char in serial buffer. ...
      (microsoft.public.vc.mfc)
    • Re: Serial port monitoring
      ... There is no need for a timer; you want to get data when it is available, ... line in the serial port, then by the time of the next trigger the rest has ... I would then have a loop that checks for char in serial buffer. ...
      (microsoft.public.vc.mfc)
    • Re: Serial port monitoring
      ... It is inappropriate to use a static string for this purpose. ... There is no need for a timer; you want to get data when it is available, ... The main thing is that every 100ms or so you check the serial port and read ... I would then have a loop that checks for char in serial buffer. ...
      (microsoft.public.vc.mfc)
    • Re: Serial port monitoring
      ... The problem is that when the Timer is triggered you may only have part of a line in the serial port, then by the time of the next trigger the rest has arrived. ... I would then have a loop that checks for char in serial buffer. ... Then I would return to the loop which just sits there looking for chars in serial buffer. ...
      (microsoft.public.vc.mfc)