Command Line Invocation

62 views
Skip to first unread message

Victor Aprea

unread,
May 19, 2016, 7:15:55 PM5/19/16
to Arduino Developers
Hey all,

Just wanted to check in here to see if I'm doing it wrong... when I ssh into a machine and try to invoke Arduino to upload a sketch to a target using the command line, I get the following results (for example):

./arduino --upload -v ./libraries/Firmata/examples/StandardFirmataPlus/StandardFirmataPlus.ino 
Picked up JAVA_TOOL_OPTIONS: 
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.awt.HeadlessException: 
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
at java.awt.SplashScreen.getSplashScreen(SplashScreen.java:117)
at processing.app.Base.<clinit>(Base.java:91)

Isn't (at least some part of) the point of a command line invocation that you should be able to run it headless? I figure I can't be the first person to run into this, so:

(1) Am I doing something wrong?
(2) Is there already an issue about this or should one be created?
(3) Is there a known workaround?

Kind Regards,
Vic

Victor Aprea // Wicked Device

Matthijs Kooijman

unread,
May 20, 2016, 6:31:32 AM5/20/16
to devel...@arduino.cc
Hey Victor,

> Isn't (at least some part of) the point of a command line invocation that
> you should be able to run it headless? I figure I can't be the first person
> to run into this, so:
>
> (1) Am I doing something wrong?
Nope.

> (2) Is there already an issue about this or should one be created?
Yes: https://github.com/arduino/Arduino/issues/1981

> (3) Is there a known workaround?
You can run a dummy X server (can't remember if any instructions for
that are available there). Alternatively, you can call arduino-builder
directly, bypassing the IDE altogether, but that does require more info
on where things are installed.

Ideally, I'd see this issue fixed, but the IDE was clearly not designed
with this usecase in mind, so there is a lot of mixing of GUI and
non-GUI code. A big refactor in this area was done last year, but there
is still a lot of stuff to refactor before this issue can be properly
fixed, unfortunately.

Gr.

Matthijs
signature.asc

Matthew Beckler

unread,
May 20, 2016, 8:41:45 AM5/20/16
to devel...@arduino.cc
For doing headless Arduino build and upload on Linux, I have a little script I call "arduino-headless" that I put on my $PATH:

#!/bin/bash
SCREEN=3
Xvfb :$SCREEN -nolisten tcp -screen :$SCREEN 1280x800x24 &
xvfb="$!"
DISPLAY=:$SCREEN arduino $@
kill -9 $xvfb


I then call it like this:

arduino-headless --upload --board arduino:avr:uno --port /dev/ttyACM0 -v some_sketch_file.ino

It did require the installation of the xvfb package (Debian and Ubuntu: sudo apt-get install xvfb) but this has been working very well for me to compile and upload arduino code on remote machines where my only access is SSH.

This assumes that your arduino executable is also on your $PATH. Change the command line arguments to match your board, port, and sketch file.

-Matthew Beckler
Wayne and Layne, LLC
> --
> You received this message because you are subscribed to the Google Groups "Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to developers+...@arduino.cc.

Victor Aprea

unread,
May 20, 2016, 10:19:52 AM5/20/16
to Arduino Developers
Thanks Matthijs and Matthew for your replies! Matthew, that's great, I'll give your script a try, makes sense.

Cheers,
Vic

Victor Aprea // Wicked Device

q2dg2b .

unread,
May 20, 2016, 11:05:32 AM5/20/16
to Arduino Developers
Oh, this script is great!
I've put it on Playground: http://playground.arduino.cc/Main/Headless

Victor Aprea

unread,
May 20, 2016, 11:08:02 AM5/20/16
to Arduino Developers
Matthew, works like a charm, you rock.

Vic

Victor Aprea // Wicked Device

Reply all
Reply to author
Forward
0 new messages