Index: trunk/scconfig/Rev.h =================================================================== --- trunk/scconfig/Rev.h (revision 35620) +++ trunk/scconfig/Rev.h (revision 35621) @@ -1 +1 @@ -static const int myrev = 35240; +static const int myrev = 35621; Index: trunk/scconfig/Rev.tab =================================================================== --- trunk/scconfig/Rev.tab (revision 35620) +++ trunk/scconfig/Rev.tab (revision 35621) @@ -1,3 +1,4 @@ +35621 configure ar_extern: new module for freerouting.cli 35240 configure io_dsn: merge import_dsn (as ses import) and export_dsn 35181 configure io_dsn: padstack proto hash 35076 configure io_pads: plugin configuration Index: trunk/src_plugins/ar_extern/ar_extern.c =================================================================== --- trunk/src_plugins/ar_extern/ar_extern.c (revision 35620) +++ trunk/src_plugins/ar_extern/ar_extern.c (revision 35621) @@ -63,8 +63,9 @@ } ext_router_t; #include "e_route-rnd.c" +#include "e_freerouting.c" -static const ext_router_t *routers[] = { &route_rnd, NULL }; +static const ext_router_t *routers[] = { &route_rnd, &freerouting, NULL }; static const ext_router_t *find_router(const char *name) { Index: trunk/src_plugins/ar_extern/ar_extern.conf =================================================================== --- trunk/src_plugins/ar_extern/ar_extern.conf (revision 35620) +++ trunk/src_plugins/ar_extern/ar_extern.conf (revision 35621) @@ -6,6 +6,14 @@ exe = route-rnd debug = 0 } + ha:freerouting_cli { + exe = freerouting.cli + debug = 0 + } + ha:freerouting_net { + exe = freerouting.net + debug = 0 + } } } } Index: trunk/src_plugins/ar_extern/ar_extern_conf.h =================================================================== --- trunk/src_plugins/ar_extern/ar_extern_conf.h (revision 35620) +++ trunk/src_plugins/ar_extern/ar_extern_conf.h (revision 35621) @@ -10,6 +10,14 @@ RND_CFT_STRING exe; RND_CFT_BOOLEAN debug; } route_rnd; + const struct freerouting_cli { + RND_CFT_STRING exe; + RND_CFT_BOOLEAN debug; + } freerouting_cli; + const struct freerouting_net { + RND_CFT_STRING exe; + RND_CFT_BOOLEAN debug; + } freerouting_net; } ar_extern; } plugins; } conf_ar_extern_t; Index: trunk/src_plugins/ar_extern/e_freerouting.c =================================================================== --- trunk/src_plugins/ar_extern/e_freerouting.c (nonexistent) +++ trunk/src_plugins/ar_extern/e_freerouting.c (revision 35621) @@ -0,0 +1,106 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * + * auto routing with external router process + * pcb-rnd Copyright (C) 2021 Tibor 'Igor2' Palinkas + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Contact: + * Project page: http://repo.hu/projects/pcb-rnd + * lead developer: http://repo.hu/projects/pcb-rnd/contact.html + * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") + */ + +static int freert_route(pcb_board_t *pcb, ext_route_scope_t scope, const char *method, int argc, fgw_arg_t *argv) +{ + const char *route_req = "freert.dsn", *route_res = "freert.ses"; + rnd_hidlib_t *hl = &pcb->hidlib; + char *cmd; + int n, r, sargc, rv = 1, mp = 12; + fgw_arg_t sres = {0}, *sargv; + + sargc = argc + 3; + sargv = calloc(sizeof(fgw_arg_t), sargc); + sargv[1].type = FGW_STR; sargv[1].val.cstr = "route_req"; + sargv[2].type = FGW_STR; sargv[2].val.cstr = route_req; + + /* copy the rest of the conf arguments */ + for(n = 0; n < argc; n++) { + sargv[n+3] = argv[n]; + sargv[n+3].type &= ~FGW_DYN; + } + + /* export */ + TODO("call the exporter"); + + /* run the router */ + cmd = rnd_strdup_printf("%s -cli -de '%s' -do '%s' -mp %d", conf_ar_extern.plugins.ar_extern.freerouting_cli.exe, route_req, route_res, mp); + r = rnd_system(hl, cmd); + if (r != 0) { + rnd_message(RND_MSG_ERROR, "freerouting.cli: failed to execute the router: '%s'\n", cmd); + free(cmd); + goto exit; + } + free(cmd); + + /* read and apply the result of the routing */ + r = rnd_actionva(hl, "ImportSes", route_res, NULL); + if (r != 0) { + rnd_message(RND_MSG_ERROR, "freerouting.cli: failed to import the route result from tEDAx\n"); + goto exit; + } + + rv = 0; /* success! */ + + exit:; + if (!conf_ar_extern.plugins.ar_extern.freerouting_cli.debug) { + rnd_unlink(hl, route_req); + rnd_unlink(hl, route_res); + } + return rv; +} + +static int freert_list_methods(rnd_hidlib_t *hl, vts0_t *dst) +{ + vts0_append(dst, rnd_strdup("freerouting.cli")); + vts0_append(dst, rnd_strdup("Erich's minimzed CLI-only fork")); + vts0_append(dst, rnd_strdup("freerouting.net")); + vts0_append(dst, rnd_strdup("The original variant with GUI support")); + + return 0; +} + + +static rnd_export_opt_t *freert_list_conf(rnd_hidlib_t *hl, const char *method) +{ + rnd_export_opt_t *rv = calloc(sizeof(rnd_export_opt_t), 1+1); + + rv[0].name = rnd_strdup("postroute optimization"); + rv[0].help_text = rnd_strdup("Maximum number of postroute optimization steps"); + rv[0].type = RND_HATT_INTEGER; + rv[0].default_val.lng = 12; + + return rv; +} + +static const ext_router_t freerouting = { + "freerouting", + freert_route, + freert_list_methods, + freert_list_conf +};