is there any way to find which program stored in arduino if we do not have hostory of program previous
Only by observing what it does!
You could identify your sketches by having them send out some identifying information over the serial port at startup...
You can also use logic analyzers to check the ports outputs, and know what and how the arduino does.
If you are writing the sketch; store the value in EEPROM and have a function that if you short a pin to ground, the value blinks on the "L" LED.
If you did not write the code; no.
All of my programs send a message to the consol during the setup() function. It says hi to me, program name and path, and the date yymmdd at a minimum. That makes it easy as I also standardized on the 115200 baud, then when I turn it on I know immediately what program it is. Also the IDE does not care what is connected at this point so if I have the wrong board, no problem the message comes up correctly.
Easily, no. If you really need to know, you can pull the compiled code from the Arduino using Avrdude and figure it out from there. Unless the lock bits were set, in which case you're SOL as far as I know.
If you can get the hex dump, there may be string data in there that you recognize that'll save you the trouble of disassembling the dump in its entirety. If not, it'll be a long job with lots of learning about the particular Arduino's CPU instruction set.
If you intend to reprogram it but need to keep the code, just get another one.
As @wildbill states, not easily,
Code is compiled to an "executable" and that executable is loaded in the Arduino. If the code is not protected in the microcontroller, you can get the executable back but not the original source code.
Your topic has been moved to a more suitable location on the forum. Please read the sticky topics in Uncategorized - Arduino Forum to find out why you should not have posted in "Uncategorized".
This!
A recent example:
To expand upon @gilshultz suggestion, consider.
I use Arduino Nanos exclusively on my RS485 network. The PC application they exchange data with would ignore extraneous messages, but as it's the master, I don't want the nodes talking out of turn if inadvertently reset, so I can't just code an always self-ID in setup(). What to do? I had a mode switch input anyway, so I made it a 3-state input. Two modes are normal, the third causes a self-ID message to be emitted, along with the contents of certain variables in the EEPROM space. If the mode is correct on startup, the Nano tells me everything I need to know about it.
"three state input", you ask? An SPDT center-off toggle wired to A7. Two 4.7k resistors across the switch poles to common, with one pole also wired to 5V, the other to GND. If the switch is up or down, you get 5V or GND, if the switch is centered, or the 3-conductor wire to it is disconnected, the input is 2.5V, and self-ID is invoked, as well as other things. Works nicely for my needs.
Just another idea. May not work, if what you're really trying to do is figure out what's already in some device you just picked up. In that case, you're pretty much out of luck, as going backwards to IDE code from compiled code isn't for beginners, and isn't usually worth it anyway.
Don't do the "self-id" on the operational comms line - have a separate debug/diagnostic port.
If your Arduino doesn't have a spare UART, you could use Software Serial for this...
Sure, but the whole idea was to not tie up hardware resources(i.e. pins for software serial) for a function I only need for a diagnostic occasionally. Adding the third 'state' for an input that's only checked to determine an additional operating mode during setup was a near-zero pain solution.
It won't work for everyone, granted, but it's just a suggestion.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.