Description
utils/consoleUSB.h
provides the following function to a console application:
s_console_usb()
: delivers the following commands- USB baud <baud> – sets the baud rate of the USB-UART interface
This function also handles USB-plugin events and redirects the serial data from the Serial
to SerialUSB
if the USB cable is plugged in. See the source code that explains ow to used a console application not only via CAN2SER but also via any other serial interface, like the USB serial interface in this example.
Syntax (example)
#include "utils/consoleUSB.h"
. . .
s_console_string = s_console_usb( 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 Code:
#include "consoleLogin.h"
#include "utils/consoleUSB.h"
void setup() {
console_init(&Serial);
}
void loop() {
String s_console_string = s_console_routine();
s_console_usb(s_console_string);
}
Notes and Warnings
This console-function and its commands are helpful to test and learn to work with the serial USB interface of the dice-USB. 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 USB interface of the device.
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