Skip to content

Commit

Permalink
Added IPC-D-356 netlist generation
Browse files Browse the repository at this point in the history
  • Loading branch information
set-soft committed May 17, 2022
1 parent 68527a9 commit a8bc6c0
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions kiauto/file_util.py
Expand Up @@ -206,6 +206,7 @@ def create_user_hotkeys(cfg):
text_file.write('eeschema.InspectionTool.runERC\tCtrl+Shift+I\n')
text_file.write('pcbnew.DRCTool.runDRC\tCtrl+Shift+I\n')
text_file.write('pcbnew.ZoneFiller.zoneFillAll\tB\n')
text_file.write('pcbnew.EditorControl.generateD356File\tAlt+Shift+E\n')
text_file.write('3DViewer.Control.rotateXclockwise\tAlt+X\n')
text_file.write('3DViewer.Control.rotateXcounterclockwise\tAlt+Shift+X\n')
text_file.write('3DViewer.Control.rotateYclockwise\tAlt+Y\n')
Expand Down
1 change: 1 addition & 0 deletions kiauto/ui_automation.py
Expand Up @@ -212,6 +212,7 @@ def xdotool(command, id=None):
if id is not None:
command.insert(1, str(id))
command.insert(1, '--window')
# logger.debug(['xdotool'] + command)
return check_output(['xdotool'] + command, stderr=DEVNULL).decode()
# return check_output(['xdotool'] + command)

Expand Down
22 changes: 22 additions & 0 deletions src/pcbnew_do
Expand Up @@ -444,6 +444,20 @@ def export_gencad(cfg):
wait_for_file_created_by_process(cfg.pcbnew_pid, cfg.output_file)


def ipc_netlist(cfg):
wait_point(cfg)
if cfg.ki5:
keys = ['key', 'alt+f', 'f', 'Down', 'Down', 'Down', 'Return']
else:
keys = ['key', 'shift+alt+e']
open_dialog_with_retry("Open file save for IPC netlist", keys, "Dialog to save the IPC netlist",
'Export D-356 Test File', cfg)
xdotool(['key', 'ctrl+a'])
xdotool(['type', cfg.output_file])
xdotool(['key', 'Return'])
wait_for_file_created_by_process(cfg.pcbnew_pid, cfg.output_file)


def wait_ray_tracer(cfg):
# I can't find a mechanism to determine if the render finished.
# I think this is a bug in KiCad, you can save unfinished images!!!!
Expand Down Expand Up @@ -946,6 +960,12 @@ if __name__ == '__main__':
export_gencad_parser.add_argument('--save_origin', '-O', help='Save the origin coordinates in the file',
action='store_true')

# short commands: afnoOu
ipc_netlist_parser = subparsers.add_parser('ipc_netlist', help='Create the IPC-D-356 netlist')
ipc_netlist_parser.add_argument('kicad_pcb_file', help='KiCad PCB file')
ipc_netlist_parser.add_argument('output_dir', help='Output directory')
ipc_netlist_parser.add_argument('--output_name', '-o', nargs=1, help='Name of the output file', default=['pcb.d356'])

args = parser.parse_args()
# Set the specified verbosity
log.set_level(logger, args.verbose)
Expand Down Expand Up @@ -1124,6 +1144,8 @@ if __name__ == '__main__':
capture_3d_view(cfg)
elif args.command == 'export_gencad':
export_gencad(cfg)
elif args.command == 'ipc_netlist':
ipc_netlist(cfg)
else: # run_drc
run_drc(cfg)
error_level = process_drc_out(cfg)
Expand Down
10 changes: 10 additions & 0 deletions tests/eeschema/test_netlist.py
Expand Up @@ -37,3 +37,13 @@ def test_netlist(test_dir):
r'\(node \(ref "?R1"?\) \(pin "?2"?\)( \(pinfunction "2"\))?( \(pintype "passive"\))?\)',
r'\(export \(version "?[DE]"?\)'])
ctx.clean_up()


def test_ipc_netlist(test_dir):
prj = 'good-project'
net = prj+'.d356'
ctx = context.TestContext(test_dir, 'IPC_Netlist', prj)
cmd = ['pcbnew_do', 'ipc_netlist', '-o', net]
ctx.run(cmd)
ctx.expect_out_file(net)
ctx.clean_up()

0 comments on commit a8bc6c0

Please sign in to comment.