Description

utils/consoleDev.h provides the following functions and their commands to a console application.
Note: These functions should serve as a source code example for your own development. See the file path below to find it in the Arduino sources of the dice package.

  • s_console_io_cmds() :
    • get ignition – returns the state of the ignition pin
    • set selfhold x – switches self-hold on(1) or off(0)
    • dis/enable 5V – switches the 5V boost converter on/off
    • pinX low/high – switches output pinX (1,3,7,9) high(UB) or low(flouting)
    • read pin1 – returns the voltage of pin1
    • read pin3 – returns the voltage of pin3
    • read UB – returns the voltage of UBatt pin
    • freeRam – shows the free space remaining in RAM memory
  • s_console_Dev_serial_flash_cmds() :
    • createFile FileName RecSize NbOfRecSets FileVersion – creates a file in SerialFlash
    • addRecSet FileName – appends and fills a new record set at the end of file
    • printFile FileName – prints the content of FileName to the console
    • eraseFile FileName Version – erases the files content and updates the file version
    • serialFlash info – give general information about the flash chip
  • s_console_Dev_rtc_cmds() :
    • motionWkUp on/off – use acceleration sensor to wake up
    • sleep x – puts the device to sleep for x sec. – wakeup by rtc, ign, can0 & 1, acc etc.
  • s_console_1Wire() : in case the device has an iButton interface
    • 1wire scan – scans the 1wire interface for devices
  • s_console_acc_cmds() : in case the device has an acceleration sensor
    • show acc – returns the acceleration sensor values

Syntax (examples)

#include "utils/consoleDev.h"
. . .
rtc.begin();
. . .
s_console_string = s_console_io_cmds( s_console_string );

s_console_string = s_console_Dev_serial_flash_cmds( s_console_string );
s_console_string = s_console_Dev_rtc_cmds( s_console_string );
s_console_string = s_console_acc_cmds( s_console_string );
s_console_string = s_console_1Wire( 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/consoleDev.h"

void setup() {
  SerialFlash.begin();
  rtc.begin();
 #ifdef ACC_WKUP
  ACC.init(LIS2DH12_RANGE_2GA);
 #endif
  
  console_init(&Serial);
}
void loop() {
  String s_console_string = s_console_routine();  
  s_console_string = s_console_io_cmds( s_console_string );
  s_console_string = s_console_Dev_serial_flash_cmds( s_console_string );
  s_console_string = s_console_Dev_rtc_cmds( s_console_string );
 #ifdef ACC_WKUP
  s_console_string = s_console_acc_cmds( s_console_string );
 #endif
 #ifdef HAS_DS2484
  s_console_1Wire( s_console_string );
 #endif
}

Notes and Warnings

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 control the I/Os , sleep mode etc.

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

LowPowerSAMC- Library
SerialFlash – Library