How do you trap the error from Propellent.exe in a batch file?
Don M
Posts: 1,652
I've never written an MSDOS batch file before and was playing around today. For example I am trying to figure out that when a Prop is not connected it will return the error 301 - No Propeller chip found on any serial port. SCAN_STATUS and how to trap it.
I was looking at MSDOS batch file commands from here http://www.eacsystems.com/misc/batch/batchcommands.htm and see this:
IF ERRORLEVEL 2 GOTO END
So I changed it to 301 instead of 2 in the following batch command:
I have 2 quickstart boards connected together and am using the first to load the other using Propeller Loader then loading another image into the first. That part works. Just trying to understand how to trap errors etc.
I was looking at MSDOS batch file commands from here http://www.eacsystems.com/misc/batch/batchcommands.htm and see this:
IF ERRORLEVEL 2 GOTO END
So I changed it to 301 instead of 2 in the following batch command:
I have 2 quickstart boards connected together and am using the first to load the other using Propeller Loader then loading another image into the first. That part works. Just trying to understand how to trap errors etc.
ECHO OFF Echo Flashing Stage 1.... Echo Wait for "Press any key to continue" message. propellent.exe /set /gui dialogs IF ERRORLEVEL 301 GOTO End propellent.exe /eeprom Blank_Prop_Loader_V2.binary >Blank_Prop_Loader_V2_Log.txt Echo Ready to flash stage 2.... pause Echo Flashing stage 2.... propellent.exe /eeprom blank_bin.binary >blank_bin.txt Echo Finished. :END pause
Comments
Sorry for chuckling, you do realize this is 2013....
Sorry again for being so flippant. It just tickled me to see a question about MSDOS batch files. I don't think I've seen one since last century.
As a result I'm not very helpful I'm afraid. These things are much more easily done in Unix shell scripts. I suspect installing cygwin to get that is more effort than its worth though.
Computer Hope has lots of helpful information on all kinds of scripting and built-in O/S commands.
After reading your initial question, I began to wonder if I told Propellent to actually pass the status code to the application's error code value. Turns out, I didn't. :-( Sorry, somehow I neglected to think of that.
So I fixed it! (attached). Please let me know if it works for you.
Also, I think your batch file examples are broken because they don't reference ERRORLEVEL in percent signs: % (but I could be wrong... though I couldn't get it to work without it)
Here's the batch file code I used to test the new Propellent executable:
So this way you can use the simple %ERRORLEVEL% method to check the response from Propellent.
NOTE: Not all values returned are actual errors (as noted in the documentation)... whatever ends up being the last value issued will be the value of %ERRORLEVEL% when Propellent exits. My batch code above doesn't take that into consideration... it treats every non-0 value as an error.
To run it, double click it in Windows explorer or create a shortcut to it
Ron- I'll have a play with your method and see if I can adapt that as well.
Oh good! You're welcome, and thanks for letting me know it works for you.
[SPECIAL NOTE]: I made that change quite quickly yesterday after finally figuring out how to do it. Today I looked more carefully through the code and made a couple other minor adjustments. None of the other changes should affect you or anyone else, however, I've updated the attachment (three posts above this one) and attached the latest one here as well. Please delete the one you downloaded previous to this and use the one now attached. Thanks!
Propellent-v1.6.zip
Here's my batch file for programming 2 Propellers one connected to another after compiling and configuring using the Propeller Loader object.
If the flash programming was successful it continues on the next stage and says so otherwise any error number other than 451 will be reported.
So in my example below I open up a text file called Log.txt and write the version of Propellent, the port that the Propeller was found on, any success / error command then on to the next file. Saves from having to look at different text logs.
Awesome Don! Thanks for sharing that with everybody also, that batch file can be a great starting place for someone doing a similar task.
What place I can find ERRORLEVEL numbers descriptions?
Run this command-line "Propellent.exe /Help" and it will display an .rtf file with lots of information. The messages are listed at the bottom of that file.
Also, it's included with the archive of Propellent as "Propeller Executable.pdf."
They are in the zipped attachment to post #12 above in a pdf file.
Just thought I'd pass this along.