Description
utils/consoleUpdate.h
provides the following function (from the Update – Library) to a console application:
s_console_update_cmds()
: delivers the following commands- update_recover <file> – commands the bootloader to update the application <file> and to fall back to the current application if no confirmation ‘config update’ happens after first start
- update <fileA> – commands the bootloader to update the application from serial flash <fileA>
- update <fileB> <fileA> – commands bootloader to update to fileA (and fallback to fileB in case of no confirmation)
- confirm update – cancels/confirms all pending updates
- createImg <filename> – creates an image of the current application in a file (filename is optional)
Syntax (example)
#include "utils/consoleUpdate.h"
. . .SerialFlash.begin();
. . .
s_console_string = s_console_update_cmds( s_console_string );
Note: The update functions use the SerialFlash, hence there needs to be the SerialFlash.begin();
call in the setup() routine.
Parameters
String s_console_string – String that holds the user command. Normally returned by s_console_routine() or a previous console function.
Returns
String : the user command or an empty String “” if the user command was recognised and processed by this function. (see of commands above)
Example Code:
#include "consoleLogin.h"
#include "utils/consoleUpdate.h"
#include "utils/consoleSerialFlash.h"
void setup() {
SerialFlash.begin();
console_init(&Serial);
}
void loop() {
String s_console_string = s_console_routine();
s_console_string = s_console_serial_flash_cmds( s_console_string );
s_console_update_cmds(s_console_string);
}
Notes and Warnings
This console-function and its commands are helpful to test and learn to work with the Update – Library. See the source code as example code for your own application:
C:\Users\yourName\AppData\Local\Arduino15\packages\dice\hardware\samc\1.0.0\libraries\Console\src\...
In a ‘real world’ application, these commands might not be required but during development it could be helpful to test the Update library.
Please keep in mind that each included file and its used function increase the size of the resulting application. So in order to keep the application binaries as small as possible, include only functions that are really necessary for the final application.
An example can be found in the Arduino IDE menu:
File -> Examples -> Consoles ->
Dev_Console
See also
Update – Library
SerialFlash – Library
BOOTLOADER SETTINGS – Library