Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is this an issue or a defined behavior? I am using Arduino IDE 1.6.6

Sometimes I made changes in code, and immediately upload them to the Arduino board. And many times issues already fixed are persisting, leaving me that feeling of "the uploaded code has not the changes I have just made". Then I save my sketch, compile and upload again and the issue vanishes. As long as the issue get someway fixed, I tend to forgot about it.

As software engineer, most of the times I assume the code I am compiling and uploading / publishing to any platform is always the latest, not the latest saved. I believe this is not the behavior of the Arduino IDE. It uploads the last saved version of code, not the last modified.

In summary: I believe the Arduino IDE uploads to the board the last saved version of the sketch, not the current one being modified. Can anyone confirm this?

Thanks in advance.

share|improve this question
1  
I can't confirm that since I use an external editor, which necessitates saving before compiling. I sometimes use a menu which I wave the mouse over to compile+upload. ¶ See the last post or two in topic #46983 in forum.arduino.cc which depending on interpretation may or may not suggest that in 2010 it did not work as you say. – jwpat7 Jan 5 at 20:15
1  
I can't prove it (i.e., I haven't looked at the code), but it seems to me that 1.6.6 saves before uploading – seems worth a test. Also worth mentioning the platform where you're seeing this behavior. I'm on a MacBook Pro running OS X 10.11.2. – dlu Jan 5 at 21:32
    
Yeah, the option is on. I am on Windows 10. If it's working correctly, then I probably had some issue with the upload, or simply believing I uploaded the last version when actually didn't. I would like to discard as much clues as possible, I hate this kind of "magic" fixes. Thank for your replies! – fabrosell Jan 6 at 1:03

I haven't tried it but it would be an easy experiment to make on some throw-away code.

However, do note that saving before compiling or uploading is optional in the Arduino IDE. That may very well be the key to what you observed. I keep mine enabled, i.e., to save before any compile or upload. The option is in the Preferences dialog accessed from the menus, not in the manually-edited preferences.txt file. That might be the key to what you observed.

Update: In that case, including the pre-defined macros __DATE__ and __TIME__ (of the pre-processor run) and __TIMESTAMP__ (of the file's last modification) in a "Hello" string can help debug this.

These pages list the standard, and common predefined macros implemented in gcc's pre-processor. Note also that most version control systems offer similar macros that get replaced at checkout to embed a revision number and other version-control information.

share|improve this answer
    
Thanks for your reply. Apparently I have the option to save when compiling or uploading on, but I still face some "outdated code" like issues. They got fixed after save, compile and upload. I am guessing now that I may had an upload error. Or not uploading at all. But I would like to discard as most clues as possible. Apparently, the IDE is saving my files as expected... (assuming there is no open bugs on that feature). – fabrosell Jan 5 at 21:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.