#!/usr/bin/perl use charger_lib; $cl = new charger_lib; $cl->set_delay(0.05); $cl->set_unit(shift || 255); $cl->set_baud(shift || 9600); $cl->set_debug(); while(1) { print "[R]aw, [C]ooked, c[H]arge parameters, [S]et unit, [L]ed on, [P]ing, r[E]boot, [Q]uit>"; $ch = <>; ($ch1) = split(//,$ch); $ch1 = lc $ch1; if($ch1 eq "r") { $cl->show_raw(); } elsif($ch1 eq "c") { $cl->show_cooked(); } elsif($ch1 eq "h") { $cl->show_charge_state(); } elsif($ch1 eq "s") { print "Enter a unit id>"; $unit = <>; chop($unit); $cl->set_unit($unit); } elsif($ch1 eq "e") { # reboot $cl->reboot(); } elsif($ch1 eq "p") { # ping $cl->ping(); } elsif($ch1 eq "l") { # turn on LED $cl->turn_on_led(); } elsif($ch1 eq "q") { exit(0); } else { print "Unknown cmd: $ch1\n"; } }