Merge pull request #91 from JelmerT/z1-mac
Added support for motelist and uploading to Z1 motes under Mac OSX
This commit is contained in:
commit
a7b3e99644
|
@ -1,5 +1,3 @@
|
|||
# $Id: Makefile.z1,v 1.5 2011/02/26 enricmcalvo Exp $
|
||||
|
||||
ifdef GCC
|
||||
CFLAGS+=-Os -g
|
||||
endif
|
||||
|
@ -53,7 +51,19 @@ contiki-$(TARGET).a: ${addprefix $(OBJECTDIR)/,symbols.o}
|
|||
NUMPAR=20
|
||||
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
|
||||
USBDEVPREFIX=
|
||||
SERIALDUMP = $(CONTIKI)/tools/sky/serialdump-linux
|
||||
|
@ -65,6 +75,9 @@ ifndef MOTELIST
|
|||
perl -ne 'print $$1 . " " if(m-(/dev/\w+)-);')
|
||||
CMOTES=$(MOTES)
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
|
||||
motelist: z1-motelist
|
||||
|
||||
|
|
75
tools/z1/motelist-z1-macos
Executable file
75
tools/z1/motelist-z1-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.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 );
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue