Skip to content

Instantly share code, notes, and snippets.

@cowens
Created February 10, 2020 22:28
Show Gist options
  • Save cowens/d9bedf87918b3fc04d10d61f6905e23e to your computer and use it in GitHub Desktop.
Save cowens/d9bedf87918b3fc04d10d61f6905e23e to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
open my $co2, "+>", "/dev/io8log" or die "$!";
my $message = pack "C*", 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80;
my $ret = ioctl $co2, 0xC0094806, $message;
while (1) {
my $bytes = read $co2, my $buf, 8;
die "$bytes is not enough" unless $bytes == 8;
my @values = unpack "C*", $buf;
print join(" ", map { sprintf "%02x", $_ } @values), "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment