Skip to content

Instantly share code, notes, and snippets.

@nvsofts
Created March 26, 2015 05:51
Show Gist options
  • Save nvsofts/09b4c4b9b4ba52bcb608 to your computer and use it in GitHub Desktop.
Save nvsofts/09b4c4b9b4ba52bcb608 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
# LIRCデバイスを使った赤外線送信スクリプト
# スペース区切りのデータ(単位はus)を受け取る
$LIRC_SET_SEND_CARRIER = 0x80046913;
$LIRC_SET_SEND_DUTY_CYCLE = 0x80046915;
$line = <STDIN>;
@_ir = split(/ /, $line);
@ir = map { $_ + 0 } @_ir;
$data = pack("I*", @ir);
open(OUT, "> /dev/lirc0");
$carrier = 38000;
$carrier_pack = pack("I", $carrier);
ioctl(OUT, $LIRC_SET_SEND_CARRIER, $carrier_pack);
$duty = 50;
$duty_pack = pack("I", $carrier);
ioctl(OUT, $LIRC_SET_SEND_DUTY_CYCLE, $duty_pack);
syswrite(OUT, $data);
close(OUT);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment