google / pcbdl

PCB Design Language: A programming way to design schematics.
Other
155 stars 23 forks source link

Use of LED leads to for-pcbdl netlistsvg crash #27

Open amstan opened 4 years ago

amstan commented 4 years ago

Thanks Alan for finding this!

For the following test file:

from pcbdl import *

pp3300 = Net("PP3300")

led = LED()
pp3300 << led.P1
Net("LED_K") << led.P2

You might get an error with the current https://github.com/amstan/netlistsvg/tree/for-pcbdl:

TypeError: Cannot read property '1' of undefined
    at Cell.renderAirwire (/home/amstan/Projects/netlistsvg/built/Cell.js:443:22)
    at /home/amstan/Projects/netlistsvg/built/Cell.js:338:23
    at Array.forEach (<anonymous>)
    at Cell.render (/home/amstan/Projects/netlistsvg/built/Cell.js:327:30)
    at /home/amstan/Projects/netlistsvg/built/drawModule.js:25:18
    at Array.map (<anonymous>)
    at Object.drawModule [as default] (/home/amstan/Projects/netlistsvg/built/drawModule.js:23:30)
    at /home/amstan/Projects/netlistsvg/built/index.js:57:61

This is due to this line: https://github.com/amstan/netlistsvg/blob/for-pcbdl/lib/Cell.ts#L464

Problems don't end there:

Looks like netlistsvg.py also outputs the json wrong for LEDs, even though netlistsvg will render it as a generic, we still output it as if it puts a skinned JellyBean (with pins named A and B). My netlistsvg modifications aren't reliable enough and it crashes when it looks a pin name and pin number syntax and doesn't find any because it's a generic.