61 lines
1.8 KiB
Perl
Executable File
61 lines
1.8 KiB
Perl
Executable File
#!/usr/bin/perl
|
|
###################################################################################### stir controll (mwx'2019)
|
|
use Device::SerialPort;
|
|
use Time::HiRes qw( usleep );
|
|
|
|
$dev='/dev/ttyACM0';
|
|
|
|
my $port = Device::SerialPort->new($dev); ################################################### setup serial port
|
|
|
|
$port->baudrate(9600);
|
|
$port->databits(8);
|
|
$port->parity("none");
|
|
$port->stopbits(1);
|
|
|
|
$port->lookfor();
|
|
|
|
$cmd=join(':',@ARGV);$cmd='info' if ($cmd=~/^\s*$/);
|
|
|
|
@r=split(':',&scmd($cmd));
|
|
|
|
print " Left Right\n";
|
|
printf("Stirrer On: %6d %6d\n", $r[0],$r[14]);
|
|
printf("Speed: %6d %6d\n", $r[1],$r[15]);
|
|
printf("Boost Speed: %6d %6d\n", $r[2],$r[16]);
|
|
printf("RPM: %6d %6d\n", $r[3],$r[17]);
|
|
printf("Average RPM: %6d %6d\n", $r[4],$r[18]);
|
|
printf("Regulation: %6d %6d\n", $r[5],$r[19]);
|
|
printf("Boost On: %6d %6d\n", $r[6],$r[20]);
|
|
printf("Boost Time: %6d %6d\n", $r[7],$r[21]);
|
|
printf("Catch On: %6d %6d\n", $r[8],$r[22]);
|
|
printf("Catch Time: %6d %6d\n", $r[9],$r[23]);
|
|
printf("Rise Time: %6d %6d\n", $r[10],$r[24]);
|
|
printf("Off Time: %6d %6d\n", $r[11],$r[25]);
|
|
printf("Boost Remain: %6d %6d\n", $r[12],$r[26]);
|
|
printf("Off Remain: %6d %6d\n", $r[13],$r[27]);
|
|
printf("Error: %d\nVersion: %s\n", $r[29],$r[28]);
|
|
|
|
|
|
sub scmd() { ##################################################################################### send command
|
|
my($cmd,$quiet)=@_;
|
|
|
|
$port->write($cmd);
|
|
my $founddata=0;
|
|
$msg="";
|
|
for ($i=0;$i<1000;$i++) {
|
|
|
|
$in = $port->lookfor();
|
|
$founddata=1 if ($in ne "");
|
|
$msg.=$in;
|
|
|
|
last if ($in eq "" && $founddata);
|
|
|
|
&usleep(2500);
|
|
}
|
|
|
|
$msg=~s/[\r\n]+//g;
|
|
return $msg;
|
|
}
|
|
|
|
########################################################################################################### END
|