Electronic Load  1.0
Programmable Constant Current Sink
Macros | Functions | Variables
usartcmd.c File Reference

Handles commands from the Host Interface. More...

Include dependency graph for usartcmd.c:

Macros

#define MAXPARAMS   5
 Maximum number of Parameters passed to any Command. More...
 

Functions

void calDisp (void)
 
static int8_t CmdCalibrate (void)
 Calibrates the Voltage Sensors. More...
 
static int8_t CmdCurrent (void)
 Sets the Current to be drawn from the Source. More...
 
static int8_t CmdDumpConf (void)
 Prints the Configuration Memory in a human readable form. More...
 
static int8_t CmdFTest (void)
 Performs a Factory Test. More...
 
static int8_t CmdHelp (void)
 Lists a Description of all Commands. More...
 
static int8_t CmdReset (void)
 Sets Debug Options. More...
 
static int8_t CmdSetBright (void)
 Sets the Brightness of the LCD Backlight. More...
 
static int8_t CmdSetContrast (void)
 Sets the Contrast of the LCD Backlight. More...
 
static int8_t CmdStat (void)
 Prints Values of System Sensors. More...
 
static int8_t CmdWrite (void)
 Writes the Configuration to the EEPROM. More...
 
static double EnterDouble (void)
 Receives a Double from the Host. More...
 
uint8_t ExecCommand (char *str)
 Executes one command line. More...
 
static void ExtraIgnored (uint8_t n)
 Prints error message for superfluous parameters. More...
 
static void MissingArg (void)
 Prints error message for missing arguments. More...
 

Variables

static char * cmd
 Pointer to the Command Line. More...
 
static const commandTable_t commandTable []
 
static const char helpCalibrate []
 
static const char helpDebug []
 
static const char helpDumpConf [] = "Prints a human readable list of configuration data"
 
static const char helpFTest [] = "Executes the factory test"
 
static const char helpHelp [] = "This list of commands"
 
static const char helpReset []
 
static const char helpSetBright [] = "Sets backlight brightness, absolute or relative (e.g. 50, +10 -10)"
 
static const char helpSetContr [] = "Sets LCD contrast, absolute or relative (e.g. 25, +5 -5)"
 
static const char helpStatus [] = "Prints current status"
 
static const char helpUseRts []
 
static const char helpWrite []
 
static uint8_t nParams
 
static char * params [MAXPARAMS]
 
static const char helpCalibrate [] PROGMEM = "Calibrates the voltage sensors"
 

Detailed Description

Handles commands from the Host Interface.

Handles commands from the serial interface

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Macro Definition Documentation

◆ MAXPARAMS

#define MAXPARAMS   5

Maximum number of Parameters passed to any Command.

Function Documentation

◆ ExtraIgnored()

static void ExtraIgnored ( uint8_t  n)
static

Prints error message for superfluous parameters.

Parameters
nThe number of extra parameters
Here is the call graph for this function:
Here is the caller graph for this function:

◆ MissingArg()

static void MissingArg ( void  )
static

Prints error message for missing arguments.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CmdCurrent()

static int8_t CmdCurrent ( void  )
static

Sets the Current to be drawn from the Source.

Returns
0 on success, -1 on error.
Here is the call graph for this function:

◆ CmdDumpConf()

static int8_t CmdDumpConf ( void  )
static

Prints the Configuration Memory in a human readable form.

Returns
always 0
Here is the call graph for this function:

◆ CmdStat()

static int8_t CmdStat ( void  )
static

Prints Values of System Sensors.

Here is the call graph for this function:

◆ CmdSetBright()

static int8_t CmdSetBright ( void  )
static

Sets the Brightness of the LCD Backlight.

If the brightness is a pure number, it is treated as an absolute value, a preceding '+' or '-' increases or decreases the brightness for the specified value.

Returns
0 on success, -1 on error.
Here is the call graph for this function:

◆ CmdSetContrast()

static int8_t CmdSetContrast ( void  )
static

Sets the Contrast of the LCD Backlight.

If the contrast is a pure number, it is treated as an absolute value, a preceding '+' or '-' increases or decreases the contrast for the specified value.

Returns
0 on success, -1 on error.
Here is the call graph for this function:

◆ CmdWrite()

static int8_t CmdWrite ( void  )
static

Writes the Configuration to the EEPROM.

Returns
0 on success, -1 on error.
Here is the call graph for this function:

◆ calDisp()

void calDisp ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EnterDouble()

static double EnterDouble ( void  )
static

Receives a Double from the Host.

Returns
The Value
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CmdCalibrate()

static int8_t CmdCalibrate ( void  )
static

Calibrates the Voltage Sensors.

Normal operation is halted during the calibration so the RTC will be late afterwards.
The user is prompted to enter the voltages from which the real Volts per LSB for each channel is calculated.

Note
The JTAGEN-fuse has to be disabled for an accurate Value of P3 and no JTAG debugger must be connected else you would end up in heavy miscalibration of the P3-value!
Returns
0 on success, -1 on error.
Here is the call graph for this function:

◆ CmdReset()

static int8_t CmdReset ( void  )
static

Sets Debug Options.

Possible parameters are dcf and sensor. Adding a parameter switches debug output on, omitting it off. So debug without parameters completely disables debugging output.

Note
Be careful using debug output especially for DCF77. This includes calling interrupt serviced routines (UART) from an interrupt and may lock up if the transmit buffer is filled (e.g. by auxiliary communication) since in ATMega-architecture interrupts and non-interruptible!
Returns
0

Causes a Watchdog Reset. Useful for Debugging

Returns
This function does not return.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CmdHelp()

static int8_t CmdHelp ( void  )
static

Lists a Description of all Commands.

Here is the call graph for this function:

◆ CmdFTest()

static int8_t CmdFTest ( void  )
static

Performs a Factory Test.

Returns
This function does not return. It ends with a device reset.
Here is the call graph for this function:

◆ ExecCommand()

uint8_t ExecCommand ( char *  str)

Executes one command line.

Parameters
strA pointer to the line
Returns
0 on success, 1 on error
Here is the call graph for this function:

Variable Documentation

◆ helpCalibrate

const char helpCalibrate[]
static

◆ helpDebug

const char helpDebug[]
static

◆ helpDumpConf

static const char helpDumpConf = "Prints a human readable list of configuration data"
static

◆ helpFTest

static const char helpFTest = "Executes the factory test"
static

◆ helpHelp

static const char helpHelp = "This list of commands"
static

◆ helpReset

const char helpReset[]
static

◆ helpSetBright

static const char helpSetBright = "Sets backlight brightness, absolute or relative (e.g. 50, +10 -10)"
static

◆ helpSetContr

static const char helpSetContr = "Sets LCD contrast, absolute or relative (e.g. 25, +5 -5)"
static

◆ helpStatus

static const char helpStatus = "Prints current status"
static

◆ helpUseRts

const char helpUseRts[]
static

◆ helpWrite

static const char helpWrite
static
Initial value:
= "Writes configuration to non-volatile memory.\n\
Execute this after any changes in configuration\n or your changes will get lost at next reset!"

◆ cmd

char* cmd
static

Pointer to the Command Line.

◆ params

char* params[MAXPARAMS]
static

◆ nParams

uint8_t nParams
static

◆ PROGMEM

const char helpWrite [] PROGMEM = "Calibrates the voltage sensors"
static

◆ commandTable

const commandTable_t commandTable[]
static
Initial value:
= {
{"Calibrate",CmdCalibrate,helpCalibrate},
{"Current",CmdCurrent,helpCurrent},
{"DumpConf",CmdDumpConf,helpDumpConf},
{"Help",CmdHelp,helpHelp},
{"FTest",CmdFTest,helpFTest},
{"SetBright",CmdSetBright,helpSetBright},
{"Status",CmdStat,helpStatus},
{"Write",CmdWrite,helpWrite},
}
static int8_t CmdStat(void)
Prints Values of System Sensors.
Definition: usartcmd.c:120
static const char helpFTest[]
Definition: usartcmd.c:45
static const char helpCalibrate[]
Definition: usartcmd.c:42
static int8_t CmdCurrent(void)
Sets the Current to be drawn from the Source.
Definition: usartcmd.c:78
static const char helpWrite[]
Definition: usartcmd.c:52
static const char helpStatus[]
Definition: usartcmd.c:50
static int8_t CmdFTest(void)
Performs a Factory Test.
Definition: usartcmd.c:448
static int8_t CmdHelp(void)
Lists a Description of all Commands.
Definition: usartcmd.c:526
static const char helpSetBright[]
Definition: usartcmd.c:48
static int8_t CmdCalibrate(void)
Calibrates the Voltage Sensors.
Definition: usartcmd.c:321
static int8_t CmdDumpConf(void)
Prints the Configuration Memory in a human readable form.
Definition: usartcmd.c:108
static int8_t CmdWrite(void)
Writes the Configuration to the EEPROM.
Definition: usartcmd.c:259
static int8_t CmdSetContrast(void)
Sets the Contrast of the LCD Backlight.
Definition: usartcmd.c:219
static const char helpSetContr[]
Definition: usartcmd.c:49
static int8_t CmdSetBright(void)
Sets the Brightness of the LCD Backlight.
Definition: usartcmd.c:163
static const char helpDumpConf[]
Definition: usartcmd.c:44
static const char helpHelp[]
Definition: usartcmd.c:46