mirror of
git://projects.qi-hardware.com/ben-wpan.git
synced 2024-11-22 14:10:37 +02:00
Added Digi-Key catalog data for automated BOM processing.
- bom/dk/Makefile, bom/dk/dk-db.pl: Digi-Key catalog query environment from gta02-core - bom/dk/digi-key.equ: manufacturer-distributor equivalences for some parts used in atusd and atusb
This commit is contained in:
parent
f17613bc69
commit
6fc656fd7f
37
bom/dk/Makefile
Normal file
37
bom/dk/Makefile
Normal file
@ -0,0 +1,37 @@
|
||||
CACHE=query.data
|
||||
|
||||
.PHONY: update regen regenerate clean spotless
|
||||
|
||||
all: digi-key.dsc digi-key.inv
|
||||
|
||||
$(CACHE): digi-key.equ
|
||||
awk '/^#END/ { exit } /^DIGI-KEY / { print $$2 }' \
|
||||
digi-key.equ | \
|
||||
perl ./dk-db.pl query \
|
||||
`[ -r $(CACHE) ] && echo '' -i $(CACHE)` >_$@ || \
|
||||
{ rm -f $@ _$@; exit 1; }
|
||||
mv _$@ $@
|
||||
|
||||
digi-key.dsc: $(CACHE)
|
||||
perl ./dk-db.pl dsc $(CACHE) >$@ || { rm -f $@; exit 1; }
|
||||
|
||||
digi-key.inv: $(CACHE)
|
||||
perl ./dk-db.pl inv $(CACHE) >$@ || { rm -f $@; exit 1; }
|
||||
|
||||
update:
|
||||
$(MAKE) clean all
|
||||
|
||||
regen regenerate:
|
||||
rm -f digi-key.dsc digi-key.inv
|
||||
$(MAKE) all
|
||||
|
||||
clean:
|
||||
rm -f $(CACHE) _$(CACHE)
|
||||
|
||||
#
|
||||
# we don't do a "make clean" on "make spotless", so that things like "make
|
||||
# optimist" don't erase the cache.
|
||||
#
|
||||
|
||||
spotless:
|
||||
rm -f digi-key.dsc digi-key.inv _$(CACHE)
|
31
bom/dk/digi-key.equ
Normal file
31
bom/dk/digi-key.equ
Normal file
@ -0,0 +1,31 @@
|
||||
#EQU
|
||||
|
||||
DIGI-KEY AT86RF230-ZU-ND ATMEL AT86RF230-ZU
|
||||
|
||||
DIGI-KEY 336-1296-5-ND SILABS C8051F326-GM
|
||||
|
||||
DIGI-KEY 732-2230-1-ND WURTH 748421245
|
||||
|
||||
# resistors
|
||||
|
||||
DIGI-KEY RMCF0402ZT0R00CT-ND STACKPOLE RMCF0402ZT0R00
|
||||
DIGI-KEY P0.0JCT-ND PANASONIC ERJ-2GE0R00X
|
||||
DIGI-KEY 311-0.0JRCT-ND YAGEO RC0402JR-070RL
|
||||
|
||||
# caps
|
||||
|
||||
DIGI-KEY 490-1320-1-ND MURATA GRM155R60J105KE19D
|
||||
DIGI-KEY 445-4998-1-ND TDK C1005X5R0J105K
|
||||
DIGI-KEY 478-2583-1-ND AVX 04026D105KAT2A
|
||||
|
||||
DIGI-KEY 311-1018-1-ND YAGEO CC0402JRNP09BN220
|
||||
DIGI-KEY 490-1283-1-ND MURATA GRM1555C1H220JZ01D
|
||||
DIGI-KEY 445-1239-1-ND TDK C1005C0G1H220J
|
||||
|
||||
DIGI-KEY 311-1020-1-ND YAGEO CC0402JRNP09BN330
|
||||
DIGI-KEY 490-3220-1-ND MURATA GRM1555C1H330JZ01D
|
||||
DIGI-KEY 445-1241-1-ND TDK C1005C0G1H330J
|
||||
|
||||
DIGI-KEY 311-1035-1-ND YAGEO CC0402KRX7R9BB221
|
||||
DIGI-KEY 445-1254-1-ND TDK C1005X7R1H221K
|
||||
DIGI-KEY 490-1298-1-ND MURATA GRM155R71H221KA01D
|
105
bom/dk/dk-db.pl
Executable file
105
bom/dk/dk-db.pl
Executable file
@ -0,0 +1,105 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
sub rows
|
||||
{
|
||||
local $s = $_[0];
|
||||
my @res = ();
|
||||
|
||||
while ($s =~ m#.*?<tr>(.*?)</tr>#) {
|
||||
push(@res, $1);
|
||||
$s = $';
|
||||
}
|
||||
return @res;
|
||||
}
|
||||
|
||||
|
||||
sub cols
|
||||
{
|
||||
local $s = $_[0];
|
||||
my @res = ();
|
||||
|
||||
while ($s =~ m#.*?<td[^>]*>(.*?)</td>#) {
|
||||
push(@res, $1);
|
||||
$s = $';
|
||||
}
|
||||
return @res;
|
||||
}
|
||||
|
||||
|
||||
sub usage
|
||||
{
|
||||
print STDERR "usage: $0 (query [-i cache_file] | dsc | inv) [file ...]\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
$mode = shift @ARGV;
|
||||
&usage unless $mode eq "query" || $mode eq "dsc" || $mode eq "inv";
|
||||
|
||||
if ($mode eq "query") {
|
||||
if ($ARGV[0] eq "-i") {
|
||||
shift @ARGV;
|
||||
$name = shift @ARGV;
|
||||
open(OLD, $name) || die "$name: $!";
|
||||
$q = join("", <OLD>);
|
||||
($old = $q) =~ tr/\r\n//d;
|
||||
close OLD;
|
||||
}
|
||||
|
||||
while (<>) {
|
||||
chop;
|
||||
s/#.*//;
|
||||
next if /^\s*$/;
|
||||
next if /^\s/;
|
||||
s/\s.*//;
|
||||
next if $old =~ m#align=right>Digi-Key Part Number</th><td>$_</td#;
|
||||
push(@pn, $_);
|
||||
}
|
||||
|
||||
if (0+@pn) {
|
||||
$cmd = "wget -nv -O - ".join(" ",
|
||||
map
|
||||
"http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail\\&name=$_",
|
||||
@pn);
|
||||
$q .= `$cmd`;
|
||||
}
|
||||
|
||||
print $q;
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$q = join("", <>);
|
||||
$q =~ tr/\r\n//d;
|
||||
|
||||
print "#DSC\n" if $mode eq "dsc";
|
||||
print "#INV\n" if $mode eq "inv";
|
||||
print "# MACHINE-GENERATED. DO NOT EDIT !\n";
|
||||
print "# ", `date -u`;
|
||||
|
||||
for (split(/<!DOCTYPE HTML/, $q)) {
|
||||
next unless m#align=right>Digi-Key Part Number</th><td>([^<]+)</td#;
|
||||
$pn = $1;
|
||||
$qty = 0;
|
||||
if (m#align=right>Quantity Available</th><td[^>]*>([0-9,]+)<#) {
|
||||
($qty = $1) =~ tr/,//d;
|
||||
}
|
||||
next unless m#align=right>Description</th><td>(.*?)</td#;
|
||||
$dsc = $1;
|
||||
next unless m#<table.*<th>Price Break<(.*?)</table>#;
|
||||
if ($mode eq "dsc") {
|
||||
print "DIGI-KEY $pn $dsc\n";
|
||||
next;
|
||||
}
|
||||
print "DIGI-KEY $pn $qty USD";
|
||||
for (&rows($1)) {
|
||||
@c = &cols($_);
|
||||
next unless $c[0] =~ /^[0-9,]+$/;
|
||||
next unless $c[1] =~ /^[0-9.]+$/;
|
||||
$c[0] =~ tr/,//d;
|
||||
$c[1] =~ tr/,//d; # let's hope we don't need this one often :)
|
||||
$c[1] =~ s/0+$// if $c[1] =~ /\./;
|
||||
print " $c[0] $c[1]";
|
||||
}
|
||||
print "\n";
|
||||
}
|
Loading…
Reference in New Issue
Block a user