Description
utils/consoleFileTransfer.h
provides the following function to a console application:
s_console_file_transfer_cmds()
:- recvFile – receives a file & saves it to serial flash
- sendFile FileName – sends a file from serial flash
Note: The SerialFlash has to be initialised in the in setup() function first, before it can be accessed by the console functions! The consoleFileTransfer.h library needs to access the serial flash that offers the functionality of the FileTransfer library.
Syntax (examples)
#include "utils/consoleSerialFlash.h"
#include "utils/consoleFileTransfer.h"
. . .
SerialFlash.begin();
. . .
s_console_string = s_console_serial_flash_cmds( s_console_string );
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 Codes:
#include "consoleLogin.h"
#include "utils/consoleSerialFlash.h"
#include "utils/consoleFileTransfer.h"
void setup()
{
SerialFlash.begin();
console_init(&Serial);
}
void loop()
{
String s_console_string = s_console_routine();
s_console_serial_flash_cmds(s_console_string);
s_console_file_transfer_cmds(s_console_string);
}
Notes and Warnings
This function and its commands might be helpful to test and learn how to send and receive files in the SerialFlash over a serial connection (e.g. CAN2SER)
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 functions might not be necessary or it might even be problematic to offer the end-user the opportunity to access files from the serial flash memory.
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
consoleSerialFlash.h
FileTransfer – Library
SerialFlash – Library