Re: 8ms Timer for serial port access

From: Grant Edwards (grante_at_visi.com)
Date: 10/29/03


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            


Relevant Pages

  • Re: DVD to WMV -- Success...
    ... direct stream copy is selected, should be since that is the default. ... The higher the frame rate the better. ... maintain the quality, it will create them. ... > My source DVD have only the Video and Audio: ...
    (microsoft.public.windowsmedia.encoder)
  • Re: Reading sections of MP3/WMA files
    ... is the boundary of an audio frame. ... type will tell you the block align of the stream and a block ... You may want to take a look at my sample MP3 parser to know ... a decode to memory takes. ...
    (microsoft.public.windowsmedia.sdk)
  • Re: Display of annotation data as overlay (problem: synch)
    ... filter that generated video output based on the ... want to be able to do is to get the VMR to draw the ... between feeding a stream of pictures to the VMR via bitmap ... need to feed one frame to the secondary pin for each frame ...
    (microsoft.public.win32.programmer.directx.video)
  • Re: VMR7/9 mixing logic
    ... Maybe I mixed between the two, I assume stream 0 to be ... The VMR requires valid data for all connected, ... It will remember the last reference frame it sent to the renderer and when there is a GUI frame it will resend the last reference frame to the rednderer even if there is a waiting reference frame. ...
    (microsoft.public.win32.programmer.directx.video)
  • Re: Looking for an Efficient Thread Synchronization?
    ... In some parts, such as reading the video stream, I need to process every ... A queue sounds suitable for this task. ... offered by the stream and should then just have the last frame. ...
    (microsoft.public.dotnet.languages.csharp)