Merge in com port switching from sangaboard v4

I've refactored the use of the serial port, to store the
current serial port in a global variable in a module.
This is set to the most recent port to receive data,
and so we should always be replying to the port
that was used to initiate a command.

If SECONDARY_SERIAL_PORT is not defined, this
should result in no change - if it is, we should be
able to communicate on either port.
This commit is contained in:
Richard Bowman 2023-02-22 12:05:48 +00:00
parent e65c290ae6
commit 3997d66cde
12 changed files with 180 additions and 145 deletions

View file

@ -1,6 +1,7 @@
#include "config.h"
#ifdef HELP
#include "help.h"
#include <ComPort.h>
void help_setup()
{
@ -9,78 +10,78 @@ void help_setup()
void help(String command)
{
SERIAL_PORT.println("");
SERIAL_PORT.print("Board: ");
SERIAL_PORT.println(F(BOARD_STRING));
comPort->println("");
comPort->print("Board: ");
comPort->println(F(BOARD_STRING));
#ifdef LIGHT_SENSOR
#if defined ADAFRUIT_TSL2591
SERIAL_PORT.println(F("Compiled with Adafruit TSL2591 support"));
comPort->println(F("Compiled with Adafruit TSL2591 support"));
#elif defined ADAFRUIT_ADS1115
SERIAL_PORT.println(F("Compiled with Adafruit ADS1115 support"));
comPort->println(F("Compiled with Adafruit ADS1115 support"));
#endif
#endif //LIGHT_SENSOR
#ifdef ENDSTOPS
#ifdef ENDSTOPS_MIN
SERIAL_PORT.println(F("Compiled with min endstops support"));
comPort->println(F("Compiled with min endstops support"));
#endif
#ifdef ENDSTOPS_MAX
SERIAL_PORT.println(F("Compiled with max endstops support"));
comPort->println(F("Compiled with max endstops support"));
#endif
#endif //ENDSTOPS
SERIAL_PORT.println("");
SERIAL_PORT.println(F("Commands (terminated by a newline character):"));
comPort->println("");
comPort->println(F("Commands (terminated by a newline character):"));
#ifdef STAGE
SERIAL_PORT.println(F("mrx <d> - relative move in x"));
SERIAL_PORT.println(F("mry <d> - relative move in y"));
SERIAL_PORT.println(F("mrz <d> - relative move in z"));
SERIAL_PORT.println(F("mr <d> <d> <d> - relative move in all 3 axes"));
SERIAL_PORT.println(F("release - de-energise all motors"));
SERIAL_PORT.println(F("p? - print position (3 space-separated integers"));
SERIAL_PORT.println(F("ramp_time <d> - set the time taken to accelerate/decelerate in us"));
SERIAL_PORT.println(F("min_step_delay <d> - set the minimum time between steps in us."));
SERIAL_PORT.println(F("dt <d> - set the minimum time between steps in us."));
SERIAL_PORT.println(F("ramp_time? - get the time taken to accelerate/decelerate in us"));
SERIAL_PORT.println(F("min_step_delay? - get the minimum time between steps in us."));
SERIAL_PORT.println(F("zero - set the current position to zero."));
SERIAL_PORT.println(F("stop - stop a move in progress."));
SERIAL_PORT.println(F("blocking_moves? - get blocking moves enabled"));
SERIAL_PORT.println(F("blocking_moves <bool> - enable/disable blocking moves"));
SERIAL_PORT.println(F("moving? - check if a move is in progress"));
SERIAL_PORT.println(F("notify_on_stop - respond with stopped when current move finishes"));
comPort->println(F("mrx <d> - relative move in x"));
comPort->println(F("mry <d> - relative move in y"));
comPort->println(F("mrz <d> - relative move in z"));
comPort->println(F("mr <d> <d> <d> - relative move in all 3 axes"));
comPort->println(F("release - de-energise all motors"));
comPort->println(F("p? - print position (3 space-separated integers"));
comPort->println(F("ramp_time <d> - set the time taken to accelerate/decelerate in us"));
comPort->println(F("min_step_delay <d> - set the minimum time between steps in us."));
comPort->println(F("dt <d> - set the minimum time between steps in us."));
comPort->println(F("ramp_time? - get the time taken to accelerate/decelerate in us"));
comPort->println(F("min_step_delay? - get the minimum time between steps in us."));
comPort->println(F("zero - set the current position to zero."));
comPort->println(F("stop - stop a move in progress."));
comPort->println(F("blocking_moves? - get blocking moves enabled"));
comPort->println(F("blocking_moves <bool> - enable/disable blocking moves"));
comPort->println(F("moving? - check if a move is in progress"));
comPort->println(F("notify_on_stop - respond with stopped when current move finishes"));
#endif //STAGE
#ifdef LIGHT_SENSOR
SERIAL_PORT.println(F("light_sensor_gain <d> - set the gain of the light sensor"));
SERIAL_PORT.println(F("light_sensor_gain? - get the gain of the light sensor"));
SERIAL_PORT.println(F("light_sensor_gain_values? - get the allowable gain values of the light sensor"));
SERIAL_PORT.println(F("light_sensor_integration_time? - get the integration time in milliseconds"));
SERIAL_PORT.println(F("light_sensor_intensity? - read the current value from the full spectrum diode"));
comPort->println(F("light_sensor_gain <d> - set the gain of the light sensor"));
comPort->println(F("light_sensor_gain? - get the gain of the light sensor"));
comPort->println(F("light_sensor_gain_values? - get the allowable gain values of the light sensor"));
comPort->println(F("light_sensor_integration_time? - get the integration time in milliseconds"));
comPort->println(F("light_sensor_intensity? - read the current value from the full spectrum diode"));
#endif //LIGHT_SENSOR
#if defined(ENDSTOPS_MIN) || defined(ENDSTOPS_MAX)
SERIAL_PORT.println(F("endstops? - get triggered endstops in (1,0,-1) format for max, none, min"));
SERIAL_PORT.println(F("home_min <axes?> - home given (00000zyx byte, e.g. 1 for x) or all axes to their min position"));
SERIAL_PORT.println(F("home_max <axes?> - home given (00000zyx byte, e.g. 3 for x and y) or all axes to their max position"));
SERIAL_PORT.println(F("max_p? - return positions of max endstops"));
SERIAL_PORT.println(F("max <d> <d> <d> - set maximum positions"));
comPort->println(F("endstops? - get triggered endstops in (1,0,-1) format for max, none, min"));
comPort->println(F("home_min <axes?> - home given (00000zyx byte, e.g. 1 for x) or all axes to their min position"));
comPort->println(F("home_max <axes?> - home given (00000zyx byte, e.g. 3 for x and y) or all axes to their max position"));
comPort->println(F("max_p? - return positions of max endstops"));
comPort->println(F("max <d> <d> <d> - set maximum positions"));
#endif
#ifdef STEPSTICK
SERIAL_PORT.println(F("stepstick_move <f> <d> - move stepper by <d> with max speed <f>"));
SERIAL_PORT.println(F("stepstick_release - release stepstick stepper"));
SERIAL_PORT.println(F("stepstick_stop - abort stepstick move"));
comPort->println(F("stepstick_move <f> <d> - move stepper by <d> with max speed <f>"));
comPort->println(F("stepstick_release - release stepstick stepper"));
comPort->println(F("stepstick_stop - abort stepstick move"));
#endif
//SERIAL_PORT.println(F("test_mode <s> - set test_mode <on> <off>"));
SERIAL_PORT.println(F("version - get firmware version string"));
SERIAL_PORT.println("");
SERIAL_PORT.println("Input Key:");
SERIAL_PORT.println(F("<d> - a decimal integer."));
SERIAL_PORT.println("");
SERIAL_PORT.println("--END--");
//comPort->println(F("test_mode <s> - set test_mode <on> <off>"));
comPort->println(F("version - get firmware version string"));
comPort->println("");
comPort->println("Input Key:");
comPort->println(F("<d> - a decimal integer."));
comPort->println("");
comPort->println("--END--");
}
#endif //HELP