Added support for motelist and uploading to Z1 motes under Mac OSX

This commit is contained in:
Jelmer Tiete 2013-01-23 22:56:43 +01:00
parent 0a88373add
commit 7ce2688d84
2 changed files with 102 additions and 12 deletions

View file

@ -1,4 +1,4 @@
# $Id: Makefile.z1,v 1.5 2011/02/26 enricmcalvo Exp $ # $Id: Makefile.z1,v 1.6 2013/01/23 enricmcalvo,JelmerTiete Exp $
ifdef GCC ifdef GCC
CFLAGS+=-Os -g CFLAGS+=-Os -g
@ -53,7 +53,19 @@ contiki-$(TARGET).a: ${addprefix $(OBJECTDIR)/,symbols.o}
NUMPAR=20 NUMPAR=20
IHEXFILE=tmpimage.ihex IHEXFILE=tmpimage.ihex
# If we are not running under Windows, we assume Linux ifeq ($(HOST_OS),Darwin)
ifndef MOTELIST
USBDEVPREFIX=
SERIALDUMP = $(CONTIKI)/tools/sky/serialdump-linux
MOTELIST = $(CONTIKI)/tools/z1/motelist-z1-macos
BSL = $(CONTIKI)/tools/z1/z1-bsl-nopic --z1
BSL_FILETYPE = -I
MOTES = $(shell $(MOTELIST) -c 2>&- | \
cut -f 2 -d ,)
CMOTES=$(MOTES)
endif
else
# If we are not running under Mac, we assume Linux
ifndef MOTELIST ifndef MOTELIST
USBDEVPREFIX= USBDEVPREFIX=
SERIALDUMP = $(CONTIKI)/tools/sky/serialdump-linux SERIALDUMP = $(CONTIKI)/tools/sky/serialdump-linux
@ -65,6 +77,9 @@ ifndef MOTELIST
perl -ne 'print $$1 . " " if(m-(/dev/\w+)-);') perl -ne 'print $$1 . " " if(m-(/dev/\w+)-);')
CMOTES=$(MOTES) CMOTES=$(MOTES)
endif endif
endif
motelist: z1-motelist motelist: z1-motelist

75
tools/z1/motelist-z1-macos Executable file
View 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.SLAB" ],
);
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.SLAB*
#
sub scan_dev {
my @devs;
foreach (`ls /dev/tty.SLAB* 2>&1`) {
my($dev, $serial) = /(\/dev\/tty.SLAB(\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 );
}
}
}