MitjaNemec / Kicad_action_plugins

Kicad action plugins
414 stars 62 forks source link

Exception swapping pins #10

Closed robert128 closed 6 years ago

robert128 commented 6 years ago

I'm really excited to see this plugin work, but it isn't working for me.

I'm running Kicad 5.0 rc2 (June 21 version) on Windows 10 64-bit. With my schematic closed, I've selected 2 pads on a part and tried executing SwapPins through the Tools->External Plugins menu item, but I get an exception. I can't copy and paste the whole string of errors, but here is a summary:

Line 86: swap_pins.swap(board,pad1,pad2) Line39: all_sch_files = find_all_sch_files(main_sch_file,all_sch_files) Line 178: seznam = find_all_sch_files(sheet,list_of_files) Line 177: for sheet in extract_subsheets(filename):

File "C:/Program Files/Kicad/share/kicad/scripting/plugings/swap_pins.py", line 136, in extract subsheets with open(filename) as f: IOError (2, 'No such file or directory', C:\path_to_project_dir\~M2OE')

~M2OE is a signal name, so the script shouldn't be trying to open it as a file.

Hope that helps debug the issue.

MitjaNemec commented 6 years ago

Thanks for the bug report.

This is a weird one, but it will have to wait until tuesday as I have just half an hour available today and then I am gone till monday evening.

But I've seen that the plugin does not support swaping used and an unused pin. For that I started developing different approach to plugin, which is available in the "swap_pins_V2" branch under "swap_pins_V2" folder. I'll probably replace the current plugin with this implementation and you are welcome to try it out.

robert128 commented 6 years ago

I was swapping pins that were both connected to signals. Also, the signal (~M2OE) which was used as a filename wasn't one of the signals I was swapping. Regardless of the selected pins, your script looks for the file ~M2OE when it crashes.

MitjaNemec commented 6 years ago

Hi, I've managed to do some analysis, and I think I know where the problem is. Even before I start swapping, I scan the schematics hierarchy, and it is here that for reason unknown net name gets passed as as subsheet. Would you mind sharing your project?

MitjaNemec commented 6 years ago

P.S. I've added instrumentation to the plugin, so if you can run the latest version of the plugin and send me .log file, which should be created in the project folder, I might locate and correct the issue faster.

robert128 commented 6 years ago

06-26 08:41:29 plugins.action_swap_pins 63:Action plugin Swap pins started 06-26 08:41:32 plugins.swap_pins 33:Starting swap_pins 06-26 08:41:32 plugins.swap_pins 40:Swaping pins on U1 on nets ADC2DAT29, ADC2DAT28 06-26 08:41:32 plugins.swap_pins 44:main sch file is: C:\curie\DCB\Schematic\curie_dcb.sch 06-26 08:41:32 plugins.swap_pins 187:found subsheet: C:\curie\DCB\Schematic\~M2OE in: C:\curie\DCB\Schematic\curie_dcb.sch

MitjaNemec commented 6 years ago

Thanks, I really appreciate your effort.

This confirms that parsing for subsheets has an issue.

With recent version I've changed the parsing and I've also added additional instrumentation which will at least enable me to locate which line in your schematic file is causing this so you would not need to share complete schematics, only this line an a couple of preceeding line (10 should be enough).

If you can try again, and paste log file and if plugin fails also a couple of lines of your schematic file mentioned in the log (e.g. found subsheet: path_to_sheet\level_1.sch in: path_to_sheet\level_0.sch, line: 31).

Again thanks for testing.

robert128 commented 6 years ago

06-26 13:19:17 plugins.action_swap_pins 63:Action plugin Swap pins started 06-26 13:19:19 plugins.swap_pins 34:Starting swap_pins 06-26 13:19:19 plugins.swap_pins 41:Swaping pins on U1 on nets ADC2DAT26, ADC2DAT25 06-26 13:19:19 plugins.swap_pins 45:main sch file is: C:\curie\DCB\Schematic\curie_dcb.sch 06-26 13:19:19 plugins.swap_pins 190:found subsheet: C:\curie\DCB\Schematic\~M2OE in: C:\curie\DCB\Schematic\curie_dcb.sch, line: 3

Here is part of the schematic:

curie_dcb_snippet.zip

MitjaNemec commented 6 years ago

Thank you. Well it was really obvious once you know what to look for. Anyhow it is fixed, and I'll close the issue when you confirm it too.

Thank you very much for the initial report and debugging that followed.

robert128 commented 6 years ago

Unfortunately, it still didn't work. Here is a log and a screenshot of the exception.

Thanks for working on this! swap_pins.zip

MitjaNemec commented 6 years ago

Okay, solved one issue, hit another.

By the looks of it I think that you don't have any labels for the nets on the schematic page where the symbol is. I've added checks for this in order for the plugin to fail more gracefully with meaningful message. Anyhow I've added additional instrumentation so that the log should give me more information if this is not the case.

Thanks for testing.

robert128 commented 6 years ago

Capture.zip swap_pins.log

MitjaNemec commented 6 years ago

Can you attach the .log file

On 29 June 2018 22:16:36 CEST, robert128 notifications@github.com wrote:

Capture.zip

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/MitjaNemec/Kicad_action_plugins/issues/10#issuecomment-401462690

MitjaNemec commented 6 years ago

Here is a new thing I learned. If you edit your post, github does not send any notification emails. Thus the delay for a bugfix just got 10 days longer.

MitjaNemec commented 6 years ago

Ok, now I can confirm, that the plugin failed to find label for M3DAT16 in fpga_jtag.sch. There was a bug as the plugin did not correctly report this and fail gracefully. This has now been fixed.

Is there a label with this name anywhere in your design?

robert128 commented 6 years ago

Don't worry about the delay, I've been on vacation.

I do have a label M3DAT16 in my schematic, but it doesn't live in the fpga_jtag.sch file.

robert128 commented 6 years ago

Would you mind if I share my project with you using your email address? I don't mind sharing it privately, I just don't want to share it publicly. Maybe there is a way to do that on github instead?

MitjaNemec commented 6 years ago

This should certainly speed things up.

MitjaNemec commented 6 years ago

For anyone reading this, the issue was that at the time the plugin did not support working with multiple unit symbols, and robert128 tried using it on a multiple unit symbol