Pages: [1] 2   Go Down
Author Topic: Uploading .ino files without starting arduino.exe  (Read 2508 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 634
Posts: 50243
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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?
Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 21
Posts: 3113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Which version of the IDE are you using?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm currently using the 1.0 version
Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 21
Posts: 3113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Edison Member
*
Karma: 26
Posts: 1339
You do some programming to solve a problem, and some to solve it in a particular language. (CC2)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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?


Quote
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?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 634
Posts: 50243
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

Offline Offline
Edison Member
*
Karma: 26
Posts: 1339
You do some programming to solve a problem, and some to solve it in a particular language. (CC2)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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

Code:
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! )

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... ;-P

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.
« Last Edit: March 08, 2012, 02:59:12 pm by tuxduino » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

First, thanks all for the replies and keep em comming! :)
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 :) 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.27 KB - downloaded 24 times.)
« Last Edit: March 08, 2012, 04:42:10 pm by Airborne » Logged

Offline Offline
Edison Member
*
Karma: 26
Posts: 1339
You do some programming to solve a problem, and some to solve it in a particular language. (CC2)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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 ;-)

Quote
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
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 634
Posts: 50243
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
One line? Ok.. that would make me really happy smiley 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.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 498
Posts: 19065
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.

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.
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.

[
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?
« Last Edit: March 10, 2012, 04:22:23 am by Airborne » Logged

Pages: [1] 2   Go Up
Jump to: