Project 9  Stepper Motor
Neff Site
Macros | Enumerations | Functions
cli.h File Reference

This module implements a command line interface for the A4988 stepper motor driver. More...

Go to the source code of this file.

Macros

#define CLI_ARG_MOTOR_ON   0
 
#define CLI_ARG_MOTOR_OFF   1
 
#define CLI_ARG_TURN_LEFT   0
 
#define CLI_ARG_TURN_RIGHT   1
 

Enumerations

enum  cli_command_t { CLI_CMD_STEP, CLI_CMD_MOTOR, CLI_CMD_ADVANCE, CLI_CMD_DIRECTION }
 
enum  cli_state_t {
  CLI_STATE_GET_COMMAND, CLI_STATE_GET_MOTOR_ARG, CLI_STATE_GET_ADVANCE_ARG1, CLI_STATE_GET_ADVANCE_ARG2,
  CLI_STATE_GET_DIRECTION_ARG, CLI_STATE_GET_TERMINAL, CLI_STATE_EXECUTE, CLI_STATE_ERROR
}
 

Functions

cli_state_t cli_parse_command (char token, cli_command_t *command)
 Parse command. More...
 
cli_state_t cli_parse_direction_argument (char token, uint16_t *argument)
 Parse direction argument. More...
 
cli_state_t cli_parse_motor_argument (char token, uint16_t *argument)
 Parse motor argument. More...
 
cli_state_t cli_parse_advance_argument1 (char token, uint16_t *argument)
 Parse first advance argument. More...
 
cli_state_t cli_parse_advance_argument2 (char token, uint16_t *argument)
 Parse second advance argument. More...
 
cli_state_t cli_parse_terminal (char token)
 Parse terminal. More...
 
cli_state_t cli_execute (cli_command_t command, uint16_t argument)
 Execute command. More...
 
cli_state_t cli_error (void)
 Print error message. More...
 

Detailed Description

This module implements a command line interface for the A4988 stepper motor driver.

Protocol Definition
Author
Wolfgang Neff
Version
3.0
Date
2018-11-25
History
Created: 2017-08-06
Modified: 2018-06-02
Modified: 2018-07-11
Modified: 2018-11-25

Macro Definition Documentation

◆ CLI_ARG_MOTOR_OFF

#define CLI_ARG_MOTOR_OFF   1

◆ CLI_ARG_MOTOR_ON

#define CLI_ARG_MOTOR_ON   0

◆ CLI_ARG_TURN_LEFT

#define CLI_ARG_TURN_LEFT   0

◆ CLI_ARG_TURN_RIGHT

#define CLI_ARG_TURN_RIGHT   1

Enumeration Type Documentation

◆ cli_command_t

Enumerator
CLI_CMD_STEP 
CLI_CMD_MOTOR 
CLI_CMD_ADVANCE 
CLI_CMD_DIRECTION 

◆ cli_state_t

Enumerator
CLI_STATE_GET_COMMAND 
CLI_STATE_GET_MOTOR_ARG 
CLI_STATE_GET_ADVANCE_ARG1 
CLI_STATE_GET_ADVANCE_ARG2 
CLI_STATE_GET_DIRECTION_ARG 
CLI_STATE_GET_TERMINAL 
CLI_STATE_EXECUTE 
CLI_STATE_ERROR 

Function Documentation

◆ cli_error()

cli_state_t cli_error ( void  )

Print error message.

Prints an error message if an error occurred. The subsequent state is CLI_STATE_GET_COMMAND.

Returns
The subsequent state.

◆ cli_execute()

cli_state_t cli_execute ( cli_command_t  command,
uint16_t  argument 
)

Execute command.

Executes the provided command with the given argument. It returns CLI_STATE_GET_COMMAND if no error occured.

Parameters
commandThe command to be executed.
argumentThe argument for the command.
Returns
The subsequent state.

◆ cli_parse_advance_argument1()

cli_state_t cli_parse_advance_argument1 ( char  token,
uint16_t *  argument 
)

Parse first advance argument.

This routine parses the first argument that follows the CLI_CMD_ADVANCE command. The subsequent state is returned. It will be CLI_STATE_PARSE_ERROR if the argument is not valid.

Parameters
tokenThe input token.
argumentThe value of the parsed argument.
Returns
The subsequent state.

◆ cli_parse_advance_argument2()

cli_state_t cli_parse_advance_argument2 ( char  token,
uint16_t *  argument 
)

Parse second advance argument.

This routine parses the second argument that follows the CLI_CMD_ADVANCE command. The subsequent state is returned. It will be CLI_STATE_PARSE_ERROR if the argument is not valid. On entry parameter argument must contain argument1 as the value of both arguments is returned.

Parameters
tokenThe input token.
argumentThe value of argument1 and argument2.
Returns
The subsequent state.

◆ cli_parse_command()

cli_state_t cli_parse_command ( char  token,
cli_command_t command 
)

Parse command.

A parser analyzes input tokens and determines their meaning. Their meaning is defined by the protocol. This routine parses the input token and determines the specified command. It also returns the subsequent state. A CLI_STATE_PARSE_ERROR is returned if no valid command is found.

Parameters
tokenThe input token.
commandThe parsed command.
Returns
The subsequent state.

◆ cli_parse_direction_argument()

cli_state_t cli_parse_direction_argument ( char  token,
uint16_t *  argument 
)

Parse direction argument.

This routine parses the argument that follows the CLI_CMD_DIRECTION command. The subsequent state is returned. It will be CLI_STATE_PARSE_ERROR if the argument is not valid.

Parameters
tokenThe input token.
argumentThe value of the parsed argument.
Returns
The subsequent state.

◆ cli_parse_motor_argument()

cli_state_t cli_parse_motor_argument ( char  token,
uint16_t *  argument 
)

Parse motor argument.

This routine parses the argument that follows the CLI_CMD_MOTOR command. The subsequent state is returned. It will be CLI_STATE_PARSE_ERROR if the the argument is not valid.

Parameters
tokenThe input token.
argumentThe value of the parsed argument.
Returns
The subsequent state.

◆ cli_parse_terminal()

cli_state_t cli_parse_terminal ( char  token)

Parse terminal.

Terminal symbols are symbols which terminate a command. This routine checks if the token passed is a terminal. It returns CLI_STATE_EXECUTE if a terminal symbol was found or CLI_STATE_PARSE_ERROR otherwise.

Parameters
tokenThe input token.
Returns
The subsequent state.
Contact