7 # sudo apt install libiio-utils mosquitto-clients
9 my $hostname = `hostname -s`;
14 my $t = Time::HiRes::time;
21 foreach ( split(/\n/, $iio) ) {
22 if ( m/iio:device\d+:\s+(\S+)/ ) {
24 } elsif ( m/(\S+):\s+\(input\)/ ) {
26 } elsif ( m/attr\s+0:\s+input\svalue: (\d+[\.\d]+)/ ) {
28 if ( $val !~ m/\d+\.\d+/ ) {
31 my $topic = "iio/$hostname/$device/$name";
32 #print "$topic $val\n";
33 system "mosquitto_pub -h rpi2 -t $topic -m $val";
39 sleep Time::HiRes::time + 1 - $t;