summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-10-31 13:05:05 -0300
committerGenerated from internal repo <nobody@neo900.org>2016-10-31 13:05:05 -0300
commit694f494ca2ddef425d9d330f6a9a3c4086ddd0f0 (patch)
tree99a9cb7ba5385acdb045084648eb18ac5e89459d /scripts
parent18ec72f7dcc7a2cf2da9ddddc900379e6202827d (diff)
downloadee-694f494ca2ddef425d9d330f6a9a3c4086ddd0f0.tar.gz
ee-694f494ca2ddef425d9d330f6a9a3c4086ddd0f0.tar.bz2
ee-694f494ca2ddef425d9d330f6a9a3c4086ddd0f0.zip
scripts/libchk.pl: Eeschema library checker
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/libchk.pl58
1 files changed, 58 insertions, 0 deletions
diff --git a/scripts/libchk.pl b/scripts/libchk.pl
new file mode 100755
index 0000000..03e0ace
--- /dev/null
+++ b/scripts/libchk.pl
@@ -0,0 +1,58 @@
+#!/usr/bin/perl
+#
+# libchk.pl - Check pins in Eeschema libraries
+#
+
+#
+# The component editor has a check function, but this suffers the following
+# limitations:
+#
+# - one has to run it on every component, making it easy to miss some errors,
+# - the off-grid detection doesn't seem to detect pins off the current grid,
+# and even less off the standard 50 mil grid, and
+# - duplicate pin detection seems to miss duplicate pins in different units.
+#
+
+
+sub check
+{
+ local ($part, $cvt, @a) = @_;
+
+ my $name = $a[1];
+ my $num = $a[2];
+ my $x = $a[3];
+ my $y = $a[4];
+ my $unit = $a[9];
+
+ warn "$part.$name ($x, $y) is off 50 mil grid\n"
+ if ($x % 50) || ($y % 50);
+
+ if (defined $p[$cvt]{$num}) {
+ warn "$part($cvt): $num used for $p[$cvt]{$num} and $name\n";
+ return 0;
+ }
+ $p[$cvt]{$num} = $name;
+
+ return 1;
+}
+
+
+while (<>) {
+ if (/^DEF\s(\S+)/) {
+ $part = $1;
+ undef @p;
+ next;
+ }
+ next unless /^X/;
+
+ my @a = split(/\s+/);
+ my $cvt = $a[10];
+
+ if ($cvt) {
+ foreach $cvt (1, 2) {
+ last unless &check($part, $cvt, @a);
+ }
+ } else {
+ &check($part, $cvt, @a);
+ }
+}