[openbeos] Re: is system_time(); an expensive call?

Hi Bruno,

"Bruno van Dooren" <bruno_van_dooren@xxxxxxxxxxx> wrote:
> i am currently writing the new PS2 port kernel driver for the 
> keyboard and 
> mouse input server devices.

Very nice!

> the only problem is that there is no error handling or sequencing in 
> that protocol. 
> this means that if i get a sequence of bytes, i have to assume that 
> every 3d byte 
> is the first byte of a data packet.
> this is not a problem in itself, but if one byte would get lost 
> somehow, this would
> mess up all future mouse data packets.

It looks like you are desribing my favourite problem under Windows...

> the only thing i can do is to check the difference in time between 
> different bytes.
> it is logical that the time differences between bytes from the same 
> packet are 
> smaller then the difference in time between bytes from different 
> packets.

That would be a good possibility, I think. Perhaps you could also 
interprete each packet with the previous packets as context, so that 
you can filter out weird packets and reset the byte position correctly. 
For example, I have severe problems with this under Windows 2k and my 
laptop - I don't have those problems with Linux and BeOS on the same 
machine. So, obviously, there is a way to handle those cases 
gracefully.

> now i was wondering: is the system_time function an expensive 
> function to use?
> should i use another funtion or a timer interrupt to increase an 
> internal tick counter?

The system_time() function is designed to be as cheap as possible. It 
basically does 2 or three memory references and a multiplication.
Is it possible to reset the mouse so that it starts again sending the 
packets? That might be another option to clear out erroneous bytes.

Adios...
   Axel.


Other related posts: