#!/usr/bin/perl use warnings; use strict; my $testString; my @lines; my @parameters; my $currentLine; my $vendID; my $prodID; my $hexFile; my $command; my $pauseForRenum; my $userTest; print "This script will upload the firmware to any raw ACCES USB devices that are found on the system "; print "If any devices are programmed the script will pause for 5 seconds before attempting to make "; print "all ACCES USB devices on the system usable by users other than root. "; print "This script should be run with root privelages\n"; $pauseForRenum = 0; $testString = `lsusb -d 1605:`; @lines = split /\n/, $testString; foreach $currentLine (@lines) { @parameters = split ' ', $currentLine; chop($parameters[3]); #is in the form xxx: and we just want xxx ($vendID, $prodID) = split ':', $parameters[5], 2; #there isn't a built in switch statement for PERL so we will use in if elsif block if ($prodID eq '0001') {$hexFile = "USB-DIO-32.hex"} elsif ($prodID eq '4001') {$hexFile = "USB-DA128-ArevA.hex"} elsif ($prodID eq '4002') {$hexFile = "NONE YET!"} elsif ($prodID eq '0010') {$hexFile = "USB-IIRO-16.hex"} elsif ($prodID eq '0020') {$hexFile = "USB-CTR-15.hex"} elsif ($prodID eq '0030') {$hexFile = "USB-IIRO4-2SM.hex"} else {next} $pauseForRenum = 1; $command = 'fxload -t fx2 -D /proc/bus/usb/' . $parameters[1] . '/' . $parameters[3] . ' -I ' . $hexFile; print $command; print "\n"; system ($command); } #at this point we have programmed any raw devices that were attached to the system. Now we want to make the files #usable without being root. if ($pauseForRenum == 1) {sleep 5} #On the test system it actually took this long for renumeration to work. Scary $testString = `lsusb -d 1605:`; @lines = split /\n/, $testString; foreach $currentLine (@lines) { @parameters = split ' ', $currentLine; chop($parameters[3]); #is in the form xxx: and we just want xxx ($vendID, $prodID) = split ':', $parameters[5], 2; $command = 'chmod 0666 /proc/bus/usb/' . $parameters[1] . '/' . $parameters[3]; print $command; print "\n"; system($command); }