Sky motelist support for MacOS X
This commit is contained in:
parent
a4813d815f
commit
cc863e7bd4
@ -58,9 +58,29 @@ ifeq ($(HOST_OS),Windows)
|
||||
CMOTES = $(shell $(MOTELIST) | grep COM | \
|
||||
cut -f 4 -d \ | \
|
||||
perl -ne 'print $$1 . " " if(/COM(\d+)/);')
|
||||
else
|
||||
ifeq ($(HOST_OS),Darwin)
|
||||
ifndef MOTELIST
|
||||
USBDEVPREFIX=
|
||||
SERIALDUMP = $(CONTIKI)/tools/sky/serialdump-linux
|
||||
MOTELIST = $(CONTIKI)/tools/sky/motelist-macos
|
||||
TMOTE_BSL_FILE = tmote-bsl-linux
|
||||
TMOTE_BSL=$(if $(wildcard $(CONTIKI)/tools/sky/$(TMOTE_BSL_FILE)),1,0)
|
||||
ifeq ($(TMOTE_BSL), 1)
|
||||
PATH := $(PATH):$(CONTIKI)/tools/sky
|
||||
BSL = $(CONTIKI)/tools/sky/$(TMOTE_BSL_FILE)
|
||||
NUMPAR = 1
|
||||
else
|
||||
BSL = $(CONTIKI)/tools/sky/msp430-bsl-linux --telosb
|
||||
BSL_FILETYPE = -I
|
||||
endif
|
||||
|
||||
# If we are not running under Windows, we assume Linux
|
||||
MOTES = $(shell $(MOTELIST) 2>&- | grep usbserial | \
|
||||
cut -f 4 -d \ | \
|
||||
perl -ne 'print $$1 . " " if(m-(/dev/[\w+\.\-]+)-);')
|
||||
CMOTES=$(MOTES)
|
||||
endif
|
||||
else
|
||||
# Else we assume Linux
|
||||
ifndef MOTELIST
|
||||
USBDEVPREFIX=
|
||||
SERIALDUMP = $(CONTIKI)/tools/sky/serialdump-linux
|
||||
@ -77,9 +97,11 @@ ifndef MOTELIST
|
||||
endif
|
||||
MOTES = $(shell $(MOTELIST) 2>&- | grep USB | \
|
||||
cut -f 4 -d \ | \
|
||||
perl -ne 'print $$1 . " " if(m-(/dev/\w+)-);')
|
||||
perl -ne 'print $$1 . " " if(m-(/dev/[\w+\.\-]+)-);')
|
||||
CMOTES=$(MOTES)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
motelist: sky-motelist
|
||||
|
||||
@ -91,7 +113,7 @@ sky-motes:
|
||||
ifdef MOTE
|
||||
%.upload: %.ihex
|
||||
cp $< $(IHEXFILE)
|
||||
$(MAKE) sky-u.$(subst /,-,$(word $(MOTE), $(MOTES)))
|
||||
$(MAKE) sky-u.$(subst /,_,$(word $(MOTE), $(MOTES)))
|
||||
else # MOTE
|
||||
%.upload: %.ihex
|
||||
cp $< $(IHEXFILE)
|
||||
@ -103,7 +125,7 @@ ifdef FILE
|
||||
@echo Uploading $(FILE)
|
||||
cp $(FILE) $(IHEXFILE)
|
||||
ifdef MOTE
|
||||
$(MAKE) sky-u.$(subst /,-,$(word $(MOTE), $(MOTES)))
|
||||
$(MAKE) sky-u.$(subst /,_,$(word $(MOTE), $(MOTES)))
|
||||
else # MOTE
|
||||
$(MAKE) sky-reset sky-upload
|
||||
endif # MOTE
|
||||
@ -114,25 +136,25 @@ endif
|
||||
sky-upload: sky-reset
|
||||
$(MAKE) -j $(NUMPAR) sky-upload-sequence
|
||||
|
||||
sky-upload-sequence: $(foreach PORT, $(MOTES), sky-u.$(subst /,-,$(PORT)))
|
||||
sky-upload-sequence: $(foreach PORT, $(MOTES), sky-u.$(subst /,_,$(PORT)))
|
||||
@echo Done
|
||||
|
||||
sky-reset:
|
||||
$(MAKE) -k -j $(NUMPAR) sky-reset-sequence
|
||||
|
||||
sky-reset-sequence: $(foreach PORT, $(MOTES), sky-r.$(subst /,-,$(PORT)))
|
||||
sky-reset-sequence: $(foreach PORT, $(MOTES), sky-r.$(subst /,_,$(PORT)))
|
||||
@echo Done
|
||||
|
||||
sky-u.%:
|
||||
@echo +++++ Erasing $(subst -,/,$*); \
|
||||
$(BSL) -c $(subst -,/,$*) -e && sleep 2 ; \
|
||||
echo +++++ Programming $(subst -,/,$*) ; \
|
||||
$(BSL) -c $(subst -,/,$*) $(BSL_FILETYPE) -p $(IHEXFILE) && sleep 2 ; \
|
||||
echo +++++ Resetting $(subst -,/,$*) ; \
|
||||
$(BSL) -c $(subst -,/,$*) -r
|
||||
@echo +++++ Erasing $(subst _,/,$*); \
|
||||
$(BSL) -c $(subst _,/,$*) -e && sleep 2 ; \
|
||||
echo +++++ Programming $(subst _,/,$*) ; \
|
||||
$(BSL) -c $(subst _,/,$*) $(BSL_FILETYPE) -p $(IHEXFILE) && sleep 2 ; \
|
||||
echo +++++ Resetting $(subst _,/,$*) ; \
|
||||
$(BSL) -c $(subst _,/,$*) -r
|
||||
|
||||
sky-r.%:
|
||||
$(BSL) -c $(subst -,/,$*) -r
|
||||
$(BSL) -c $(subst _,/,$*) -r
|
||||
|
||||
sizeplot:
|
||||
msp430-size $(OBJECTDIR)/*.o | $(CONTIKI)/tools/sky/check-size > size-data
|
||||
|
75
tools/sky/motelist-macos
Executable file
75
tools/sky/motelist-macos
Executable file
@ -0,0 +1,75 @@
|
||||
#!/usr/bin/perl -w
|
||||
use strict;
|
||||
|
||||
my $help = <<'EOF';
|
||||
usage: motelist [options]
|
||||
|
||||
options:
|
||||
-h display this help
|
||||
-c compact format, not pretty but easier for parsing
|
||||
EOF
|
||||
|
||||
my %Opt = (
|
||||
compact => 0,
|
||||
dev_prefix => [ "/dev/tty.usbserial-" ],
|
||||
);
|
||||
|
||||
while (@ARGV) {
|
||||
last unless $ARGV[0] =~ /^-/;
|
||||
my $opt = shift @ARGV;
|
||||
if( $opt eq "-h" ) { print "$help\n"; exit 0; }
|
||||
elsif( $opt eq "-c" ) { $Opt{compact} = 1; }
|
||||
else { print STDERR "$help\nerror, unknown command line option $opt\n"; exit 1; }
|
||||
}
|
||||
|
||||
print_motelist( scan_dev() );
|
||||
|
||||
#
|
||||
# Scan /dev for tty.usbserial-*
|
||||
#
|
||||
sub scan_dev {
|
||||
my @devs;
|
||||
foreach (`ls /dev/tty.usbserial-* 2>&1`) {
|
||||
my($dev, $serial) = /(\/dev\/tty.usbserial-(\S+))/;
|
||||
if ($serial ne "*:") {
|
||||
my $d;
|
||||
$d->{"InfoSerial"} = $serial;
|
||||
$d->{"SerialDevName"} = $dev;
|
||||
push(@devs, $d);
|
||||
}
|
||||
}
|
||||
return @devs;
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Print motelist
|
||||
#
|
||||
sub print_motelist {
|
||||
my @devs = @_;
|
||||
|
||||
# If none were found, quit
|
||||
if( @devs == 0 ) {
|
||||
print "No devices found.\n";
|
||||
return;
|
||||
}
|
||||
|
||||
# Print a header
|
||||
if( !$Opt{compact} ) {
|
||||
print << "EOF" unless $Opt{compact};
|
||||
Reference Device Description
|
||||
---------- --------------------------- ---------------------------------------
|
||||
EOF
|
||||
}
|
||||
|
||||
# Print the usb information
|
||||
for my $dev (@devs) {
|
||||
my $desc = "(none)";
|
||||
my @output = ( $dev->{"InfoSerial"}, $dev->{"SerialDevName"}, $desc );
|
||||
if( $Opt{compact} ) {
|
||||
print join(",",@output) . "\n";
|
||||
} else {
|
||||
printf( "%-10s %-27s %s\n", @output );
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user