libchk.pl 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/usr/bin/perl
  2. #
  3. # libchk.pl - Check pins in Eeschema libraries
  4. #
  5. #
  6. # The component editor has a check function, but this suffers the following
  7. # limitations:
  8. #
  9. # - one has to run it on every component, making it easy to miss some errors,
  10. # - the off-grid detection doesn't seem to detect pins off the current grid,
  11. # and even less off the standard 50 mil grid, and
  12. # - duplicate pin detection seems to miss duplicate pins in different units.
  13. #
  14. sub check
  15. {
  16. local ($part, $cvt, @a) = @_;
  17. my $name = $a[1];
  18. my $num = $a[2];
  19. my $x = $a[3];
  20. my $y = $a[4];
  21. my $unit = $a[9];
  22. warn "$part.$name ($x, $y) is off 50 mil grid\n"
  23. if ($x % 50) || ($y % 50);
  24. if (defined $p[$cvt]{$num}) {
  25. warn "$part($cvt): $num used for $p[$cvt]{$num} and $name\n";
  26. return 0;
  27. }
  28. $p[$cvt]{$num} = $name;
  29. return 1;
  30. }
  31. while (<>) {
  32. if (/^DEF\s(\S+)/) {
  33. $part = $1;
  34. undef @p;
  35. next;
  36. }
  37. next unless /^X/;
  38. my @a = split(/\s+/);
  39. my $cvt = $a[10];
  40. if ($cvt) {
  41. foreach $cvt (1, 2) {
  42. last unless &check($part, $cvt, @a);
  43. }
  44. } else {
  45. &check($part, $cvt, @a);
  46. }
  47. }