Skip to content

Instantly share code, notes, and snippets.

@illarionov
Created March 12, 2012 19:02
Show Gist options
  • Save illarionov/2023996 to your computer and use it in GitHub Desktop.
Save illarionov/2023996 to your computer and use it in GitHub Desktop.
Sirf payload to transport message converter
#!/usr/bin/perl
use strict;
#Encapsualtes hex payload into SiRF binary transport message
#Example: sirfmsg.pl a600020500000000
my $payload = pack("H*", $ARGV[0]);
my $csum = 0;
my $payload_length = map { $csum = ($csum + $_) & 0x7ff } unpack("C*", $payload);
print STDOUT
pack("nn", 0xa0a2, $payload_length),
$payload,
pack("nn", $csum, 0xb0b3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment