Created
March 26, 2015 05:51
-
-
Save nvsofts/09b4c4b9b4ba52bcb608 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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