- $self->{logfh}->print(sprintf('% 10.3f', $now - $self->{starttime}),
- (map { sprintf(" %02x", $_) } @bytes),
- "\n");
-
- push @{ $self->{bytes} }, @bytes;
- @bytes = @{ $self->{bytes} };
-
- my @bad_bytes;
-
- while (@bytes >= $PACKET_SIZE) {
- if ($bytes[0] != 0x55 || $bytes[9] != 0x05
- || SCX::CRC::digest(@bytes[0..7]) != $bytes[8]) {
- push @bad_bytes, shift @bytes;
- next;
- }
-
- if (@bad_bytes) {
- $self->{logfh}->print("Cannot parse bytes",
- (map { sprintf(' %02x', $_) } @bad_bytes),
- "\n");
- @bad_bytes = ();
- }
-
- $self->{logfh}->print("Callback\n");
- &{ $self->{callback} }(@bytes[1..7]);
- splice @bytes, 0, 10;
- }
- if (@bad_bytes) {
- $self->{logfh}->print("Cannot parse bytes",
- (map { sprintf(' %02x', $_) } @bad_bytes),
- "\n");
- @bad_bytes = ();
- }
-
- @{ $self->{bytes} } = @bytes;