Uploading .ino files without starting arduino.exe

Dear members,

Currently I'm working on a project for childeren with bad motoric skills. I thought that a standalone hardware piece was the best for them since they can't go play on the PC... I need to make a program for the parents to change the difficulty of the program running on the Arduino. Since I'm familiar with Java I would like to build a GUI where the parents can 'adjust' the .ino files. I know this editting can be done by Java but how can I upload the .ino files to the arduino with java only(so without using arduino.exe)?

I need you guys!

Casper

Since I'm familiar with Java I would like to build a GUI where the parents can 'adjust' the .ino files. I know this editting can be done by Java but how can I upload the .ino files to the arduino with java only(so without using arduino.exe)?

You can't upload an ino file to the Arduino. That is not what the IDE does, either.

The IDE makes some changes to the code, invokes the C preprocessor, the C++ compiler, the linker, and the uploader to upload the resulting hex file.

You are free to replicate these steps in your IDE. Enable verbose mode in the Arduino IDE, to see the commands used, and use the same commands.

The IDE makes some changes to the code, invokes the C preprocessor, the C++ compiler, the linker, and the uploader to upload the resulting hex file.
You are free to replicate these steps in your IDE. Enable verbose mode in the Arduino IDE, to see the commands used, and use the same commands.

Thanks for yor reply!
I would like use those commands, but when I use shift + click on upload (verbose) I don't see any commands send. What am I doing wrong?

Which version of the IDE are you using?

I'm currently using the 1.0 version

Then you need to enable verbose output in the preferences dialog.

You've probably already thought about this, but... You could make the sketch accept simple commands through the serial interface to set (some of) its parameters, then write a java application that would make it simple for the user to set them and transmit their values to the Arduino.
An "hallo-world" example of this could be a trackbar with range 0-255, with a "change" event callback that would send e.g. *Txxx# on the serial port; the Arduino would extract the three-digit number (xxx) and pass it to digitalWrite() to dim e.g. the builtin led.
You could then "dim a led with a mouse".

(not: * = start marker, # = end marker, T = command (Trackbar), xxx = parameter value)

My 1 cents.

Then you need to enable verbose output in the preferences dialog.

Thanks that worked, I can see the commands that are send. I guess I have to type over the commands and build them into my java application, but isn't there an easier way, I mean there are almost 60 commands used to compile and 50 used to upload...
Is there any other way?

You've probably already thought about this, but... You could make the sketch accept simple commands through the serial interface to set (some of) its parameters, then write a java application that would make it simple for the user to set them and transmit their values to the Arduino.

Hi tuxduino, no I didn't thought about that, but I'm interested in you theory however I do not fully understand you because I'm a complete newbie at Arduino IDE. Could you explain yourself a little more?

I guess I have to type over the commands and build them into my java application, but isn't there an easier way, I mean there are almost 60 commands used to compile and 50 used to upload...
Is there any other way?

I don't know what you are looking at, but there is ONE command to upload. The number of commands to compile stuff depends on how many files need to be compiled.

Perhaps it would be a good idea to post the code that you compiled and the output from the build process.

Hi tuxduino, no I didn't thought about that, but I'm interested in you theory however I do not fully understand you because I'm a complete newbie at Arduino IDE. Could you explain yourself a little more?

The idea, at its core, is simple: suppose you have a delay of n seconds in a sketch and you want the user to be able to change it. Instead of writing

const int BLINK_DELAY_S 2   // at top of sketch

...

// later, somewhere inside the code...

delay(BLINK_DELAY_S * 1000);

and instruct the user to change "2" with e.g. "3" to have a 3 seconds delay, you write a program which has a default delay value but accepts simple (ascii-based) commands through the serial port to change that delay value at runtime.

To give you a simple, although not very robust, example, let's consider a sketch that lets you turn on and of the built-in led.
O means "turn the led On", F means turn the led oFf.

( disclaimer: only an untested snipped of code! )

void loop() {
    char ch;
    if (Serial.available() > 0) {
        ch = Serial.read();

        switch(ch) {
            case 'O':
                digitalWrite(13, HIGH);
                break;

            case 'F':
                digitalWrite(13, LOW);
                break;
        }
    }
}

Usage: open the serial monitor, type O or F and hit "send".

There are smarter and better ways to implement this, but you get the idea.
The next step is to handle commands with parameters (e.g. S10 could mean "set Speed to 10%").
Then comes the ability to store certain values in EEPROM and reload them at sketch startup.
Then... :stuck_out_tongue_winking_eye:

Once you have this all working, you can write a java application that sends those commands through the serial port like the Arduino serial monitor, but instead of forcing the user to type letters and values, it provides the usual UI controls (buttons, trackbars, etc.) and handles all the protocol and conversion issues under the hood.
To control the above example, you'd just need a button with label "ON" and an "onPressed" event handler that would write('0') to the serial port and another button with label "OFF" that would wirte('F') instead.

First, thanks all for the replies and keep em comming! :slight_smile:

PaulS:
I don't know what you are looking at, but there is ONE command to upload.
Perhaps it would be a good idea to post the code that you compiled and the output from the build process.

One line? Ok.. that would make me really happy :slight_smile: Output is in the attachment. I would like it if you could find me that piece of code. ( ps this is the upload output which should include the upload and compile output)

@tuxduino That's... actually pretty clever, but I don't think I would be able to figer out how to communicate with my arduino via a serial port. Or is it possible to write commando's via I/O streams to the COM port, with the Arduino knowing what you want to do?

log.txt (12.3 KB)

Or is it possible to write commando's via I/O streams to the COM port

I think the short answer is yes. But you're the java guy here :wink:

with the Arduino knowing what you want to do?

The code snipped I showed you earlier makes Arduino "know what to do" when it receives O or F chars through the serial port.
All in all, it's "just" a matter of parsing a stream of chars...

HTH

One line? Ok.. that would make me really happy :slight_smile: Output is in the attachment. I would like it if you could find me that piece of code. ( ps this is the upload output which should include the upload and compile output)

There are only 42 lines in that file. The avr-g++ commans is compiling the file created from your sketch.

The avr-g++ commands are compiling some C files that your sketch directly, or indirectly, references.

The avr-ar commands are creating a library that the linker can use,

The avr-gcc command 4th from the bottom is the invocation of the linker.

Then, there are 2 copy commands to move stuff around.

Finally, the avrdude command uploads the hex file to the Arduino.

Airborne:
I need to make a program for the parents to change the difficulty of the program running on the Arduino.

What about a trimpot on the side of the device that the parents could stick a small screwdriver in and turn it? From "easy" to "hard". Then you just read the value of that before you make a decision about the difficulty level.

The code snipped I showed you earlier makes Arduino "know what to do" when it receives O or F chars through the serial port.
All in all, it's "just" a matter of parsing a stream of chars...

HTH

This is a good idea I'd keep this in mind if things won't work out.

Yea I have thought about something similar to that but I do think that would be too easy since there is no software involved.. And I would really like to see that there is.

[

PaulS:
There are only 42 lines in that file. The avr-g++ commans is compiling the file created from your sketch.

The avr-g++ commands are compiling some C files that your sketch directly, or indirectly, references.
The avr-ar commands are creating a library that the linker can use,
The avr-gcc command 4th from the bottom is the invocation of the linker.
Then, there are 2 copy commands to move stuff around.
Finally, the avrdude command uploads the hex file to the Arduino.

Ok thank clarifies alot. However when I use the same commands (copy paste in cmd.exe on Windows) It cannot allocate some files. Is this a logical effect of the tmp files that are created by the Arduino IDE? Or does the Arduino IDE not create tmp files to store data? According to the commands there are tmp files involved?
If so, how can I fix this?

... I do think that would be too easy since there is no software involved..

Too easy for the end-user huh? Ah well.

Too easy for the end-user huh? Ah well.

Haha no, you are right.. for the end users it would be nicer to use a switch or something like that, but I do think it gets kinda complicated when you need to adjust a lot of variables in you compiled cpp file uploaded to the Arduino. For example, if you want to adjust the LEDs powered by the Arduino, to disable certain LEDs, buttons etc. I'd think that using software to adjust this settings by uploading new files would make your program run faster and it would also contain less bugs.

UPDATE:
I've managed to upload a simple file to the Arduino via commandline. I copied the build2134567341.tmp to my dekstop and renamed it to build2134567341. After that I excuted the code given by the verbose output where I renamed the tmp paths to where the build file was stored. Which did exactly what I wanted! : )

I have only one question: what commandlines are used to upload the .hex file? (See attachment file for log.txt) I'm guessin the last 4 lines, but I'm not sure

UploadingViaCMD.txt (11.3 KB)

Avrdude does the upload

C:\arduino-1.0\hardware/tools/avr/bin/avrdude -CC:\arduino-1.0\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -carduino -P\.\COM5 -b115200 -D -Uflash:w:C:\Users\Casper\Desktop\build7121856102984891376\sketch_feb15a.cpp.hex:i

tuxduino:
Avrdude does the upload

C:\arduino-1.0\hardware/tools/avr/bin/avrdude -CC:\arduino-1.0\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -carduino -P\.\COM5 -b115200 -D -Uflash:w:C:\Users\Casper\Desktop\build7121856102984891376\sketch_feb15a.cpp.hex:i

Great, that is all I needed to know. Thanks all for your help!

Yesterday, I made a little Java program that uploads (.ino to ->).cpp files remotely to any Arduino board. If one might be interested how I figured out how to do this, the .java file is in the attachment aswell as a jar file that can be run.

Little tutorial:

  1. Upload the file first to the Arduino via the Arduino IDE. Make sure verbose is on for compile. Enable this in at the tab file -> preferences. hit the checkbox for compile.
  2. Copy the path to the buildxxxxxxxxxxxxx.tmp folder. You can find this path somewhere between the lines in the verbose output. This path should look like this: C:\Users\YourName\AppData\Local\Temp\build3834200296320359542.tmp if you are on Windows, but I'm sure that this file is also somewhere located on other OSs.
  3. Copy that folder to your desktop, remove the .tmp extention, run the java program and follow the instructions. Make sure you know what you are doing ; )

The arguments that are send via the little java program are the commands to upload the file.

Casper

UploadtoArduino.java (6.21 KB)

UploadtoArduino.jar (4.86 KB)