Awesome, thanks @MitjaN
There is this project too which does some clever plotting of a visual diff to pngs between schematic revisions.
It seems that somebody was already working on eeschema and pcbnew command line interface, but their work has not been included in the release versions.
https://lists.launchpad.net/kicad-developers/msg06052.html
I am mostly posting this as a starting point for anybody looking for this feature and since not finding it has the time and means to implement it.
I experimented with UI automation and eeSchema (Scott Bezek’s blog post), and hit a major problem (for me anyway). UI automation will work in headless mode when a monitor is not installed, but not in a purely console-only environment. I suspected that when looking at the readme for Scott Bezek’s project, but I went ahead and tried it anyway.
I’m still working through the other links that have been posted, and will check out eeshow next.
I actually had to install xvfb to get the script to run. The script is supposed to handle running xvfb, but I also tried running it manually.
Xvfb :1 -screen 0 1600x1200x32
Maybe I’m just using xvfb wrong? I’ve tried several iterations of the command above, but I keep getting this:
Error: Can't open display: (null)
Sounds like maybe the DISPLAY
environment variable isn’t getting set?
Ah, remembered the DISPLAY environment variable after posting the last message.
export DISPLAY=":0.0"
After running this Xvfb line
Xvfb :0 -screen 0 1280x1024x32
I’m at least getting non-display related errors now.
@ppelleti I think you and I hit post at the same time. Thanks!
I’ll report back once I work through these other errors.
Here’s what I did to get the export_schematic.py script working on a headless Ubuntu 16.04 minimal VM.
1. sudo apt-get install kicad
2. sudo apt-get install xvfb
3. sudo apt-get install xdotool
4. sudo apt-get install imagemagick
5. Xvfb :0 -screen - 1280x1024x16&
6. export DISPLAY=":0.0"
Additionally, to run the generate_svg.py script that seems to export the PCB file, I had to install Inkscape.
7. sudo apt-get install inkscape
Next step is accepting an arbitrary file to convert. The existing scripts focus on the hardware project the scripts are embedded with.
I’ve got a script working on Ubuntu Server 16.04 (headless, text-only) which will convert a .sch file to a .svg file.
However, the eeschema file that I create on my Ubuntu 16.04 desktop throws an error about the motors library not being present. I’ve included the version info for each eeschema installation below. My question is how should I set the Ubuntu server KiCAD installation up to minimize the problems that users would have doing a conversion? Are there standard libraries that I need to install? Do I need to force the server to run the latest version of KiCAD? Once this script is working well the next step will be to wrap it in a sample Node.js app so that it can be used as a web service. I’d like to have instructions on how to install KiCAD available so that as many users as possible will be covered.
Ubuntu Server 16.04:
Ubuntu Desktop 16.04:
The -cache.lib file should come along the .sch file. All you need to do is parse .sch files and place the -cache.lib as the topmost library. You should also add -cache.lib to .pro file at the top of the list. This way the eeschema will find all of the symbols. It might still complain about not finding the rest of the libraries.
@MitjaN I’m showing my inexperience with KiCAD here. How do I place the *-cache.lib file as the “topmost library”? I tried creating a lib_sch directory and set the library search path as described in this Hack-a-day post.
When you talk about adding *-cache.lib to the .pro file, do mean adding it as the value for LibDir here in the text of the .pro file?
[eeschema]
version=1
LibDir=
[eeschema/libraries]
LibName1=power
LibName2=device
LibName3=switches
LibName4=relays
LibName5=motors
Or should there be a “LibName0” entry that points to the cache library file?
You need to set LibName1 as the highest priority library, and shuffle the rest down or remove them. The simple way is:
Leave LibDir blank and put the cache name in LibName1. e.g. for a project called “symgen”
[eeschema]
version=1
LibDir=
[eeschema/libraries]
LibName1=symgen-cache
Note that the path in LibName1 can also be full filesystem path, or relative to any of the library search paths, but always excludes “.lib” extension. KiCad automatically adds the path of the current project and standard KiCad installation libraries to the library search path. (I use Windows but the same principle applies, use forward slash “/” for Unix or Windows)
@bobc That worked great, thanks. I’ll have to figure out how to edit those library entries in the .pro file when it’s uploaded with the rest of the project files. I’ll probably use sed for that task.
We have a standard practice for a guy who starts a design the first thing he does is open a schematic place a symbol and save, so the -cache.lib is created. Then he adds the -cache.lib to the list of used libraries and places it at the top of the list with eeschema. Then the project can be added to the VCS and shared with others.
Once the cache file is listed at the top, are any of the other library entries below it needed anymore? I’m asking because I’m trying to figure out if I can reduce the complexity of having to shift every LibName entry down in the script. If I could just edit the first one and then remove the rest that would make things a little easier, but only makes sense if the other libraries aren’t needed once the cache library has been added at the top.
[eeschema]
version=1
LibDir=
[eeschema/libraries]
LibName1=sample-cache
LibName2=device
LibName3=switches
LibName4=relays
LibName5=power
LibName6=transistors
LibName7=conn
LibName8=linear
LibName9=regul
LibName10=74xx
LibName11=cmos4000
LibName12=adc-dac
LibName13=memory
LibName14=xilinx
LibName15=microcontrollers
LibName16=dsp
LibName17=microchip
LibName18=analog_switches
LibName19=motorola
LibName20=texas
LibName21=intel
LibName22=audio
LibName23=interface
LibName24=digital-audio
LibName25=philips
LibName26=display
LibName27=cypress
LibName28=siliconi
LibName29=opto
LibName30=atmel
LibName31=contrib
LibName32=valves
[general]
version=1
But just for converting the project that the user is feeding to the script, they’re not, correct?
Shifting the libraries down isn’t that complex. Here’s a Perl script that does it:
#!/usr/bin/perl -w
while (<>) {
s/(LibName)(\d+)/$1 . ($2 + 1)/e;
print;
}