X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=SCX%2FReader.pm;h=873ffa058a09a451b217df87ed47196bd1efc37a;hb=3a515aa5d4aeeedf2632ddfc25ba4834ee90493d;hp=e3431ad425ad40e66acd33832eb2e73ed097082a;hpb=dda2866e78b9648e501050bfeee2aed36958aa10;p=slotcarman.git diff --git a/SCX/Reader.pm b/SCX/Reader.pm index e3431ad..873ffa0 100644 --- a/SCX/Reader.pm +++ b/SCX/Reader.pm @@ -226,7 +226,19 @@ sub lap_time_packet { || $bytes[4] & 0x01 || $bytes[5] & 0x01; - return $msg; # FIXME - to be implemented + my $car = $bytes[0]; + my $round = 256*$bytes[1] + $bytes[2] + + ($bytes[3] & 2 ? 256 : 0) + + ($bytes[3] & 1 ? 1 : 0); + my $time = 256*$bytes[4] + $bytes[5] + + ($bytes[3] & 8 ? 256 : 0) + + ($bytes[3] & 4 ? 1 : 0); + $time *= 0.01024; + + $self->track->car($car)->set_lap($round); + $self->track->car($car)->set_laptime($time); + + return $msg; }