Skip to content

Commit

Permalink
[#143] Capabilities command takes commndsSet as arg from Module
Browse files Browse the repository at this point in the history
  • Loading branch information
susanw1 committed Nov 28, 2023
1 parent bff1aef commit fb9dbf4
Show file tree
Hide file tree
Showing 15 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class I2cModule : public ZscriptModule<ZP> {
static void execute(ZscriptCommandContext<ZP> ctx, uint8_t bottomBits) {
switch (bottomBits) {
case ZscriptI2cCapabilitiesCommand<ZP>::CODE:
ZscriptI2cCapabilitiesCommand<ZP>::execute(ctx);
ZscriptI2cCapabilitiesCommand<ZP>::execute(ctx, MODULE_CAPABILITIES(005));
break;
#if defined(ZSCRIPT_HAVE_I2C_MODULE)
case ZscriptI2cSetupCommand<ZP>::CODE:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ namespace i2c_module {
template<class ZP>
class ZscriptI2cCapabilitiesCommand : public Capabilities_CommandDefs {
public:
static void execute(ZscriptCommandContext<ZP> ctx) {
static void execute(ZscriptCommandContext<ZP> ctx, uint16_t commandsSet) {
CommandOutStream<ZP> out = ctx.getOutStream();
out.writeField(RespCommandsSet__C, MODULE_CAPABILITIES(005));
out.writeField(RespCommandsSet__C, commandsSet);
out.writeField(RespInterfaceCount__I, 1);
out.writeField(RespFrequenciesSupported__F, 3);
#ifdef ZSCRIPT_HAVE_I2C_MODULE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class PinModule {
static void execute(ZscriptCommandContext<ZP> ctx, uint8_t bottomBits) {
switch (bottomBits) {
case 0x0:
PinCapabilitiesCommand<ZP>::execute(ctx);
PinCapabilitiesCommand<ZP>::execute(ctx, MODULE_CAPABILITIES(004));
break;
case 0x1:
DigitalPinSetupCommand<ZP>::execute(ctx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ namespace pins_module {
template<class ZP>
class PinCapabilitiesCommand : public Capabilities_CommandDefs {
public:
static void execute(ZscriptCommandContext<ZP> ctx) {
static void execute(ZscriptCommandContext<ZP> ctx, uint16_t commandsSet) {
CommandOutStream<ZP> out = ctx.getOutStream();
out.writeField(RespCommandsSet__C, MODULE_CAPABILITIES(004));
out.writeField(RespCommandsSet__C, commandsSet);
out.writeField(RespPinCount__P, ZP::pinCount);
out.writeField(RespAvailableControllers__B, RespAvailableControllers_Values::digital_field
| RespAvailableControllers_Values::atoD_field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class ZscriptServoModule : public ZscriptModule<ZP> {
static void execute(ZscriptCommandContext<ZP> ctx, uint8_t bottomBits, bool moveAlong) {
switch (bottomBits) {
case ServoCapabilitiesCommand<ZP>::CODE:
ServoCapabilitiesCommand<ZP>::execute(ctx);
ServoCapabilitiesCommand<ZP>::execute(ctx, MODULE_CAPABILITIES(008));
break;
case ServoSetupCommand<ZP>::CODE:
ServoSetupCommand<ZP>::execute(ctx, servos, persistenceStart);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ namespace servo_module {
template<class ZP>
class ServoCapabilitiesCommand: public Capabilities_CommandDefs {
public:
static void execute(ZscriptCommandContext<ZP> ctx) {
static void execute(ZscriptCommandContext<ZP> ctx, uint16_t commandsSet) {
CommandOutStream<ZP> out = ctx.getOutStream();
out.writeField(RespCommandsSet__C, MODULE_CAPABILITIES(008));
out.writeField(RespCommandsSet__C, commandsSet);
out.writeField(RespServoInterfaceCount__I, ZP::servoCount);
out.writeField(RespPulseRate__R, 20);
out.writeField(RespMinimumPulseTime__N, 544 - 127 * 4);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class UartModule : public ZscriptModule<ZP> {
static void execute(ZscriptCommandContext<ZP> ctx, uint8_t bottomBits) {
switch (bottomBits) {
case UartCapabilitiesCommand<ZP>::CODE:
UartCapabilitiesCommand<ZP>::execute(ctx);
UartCapabilitiesCommand<ZP>::execute(ctx, MODULE_CAPABILITIES(007));
break;
#ifdef ZSCRIPT_HAVE_UART_CHANNEL
case UartChannelInfoCommand<ZP>::CODE:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace uart_module {
template<class ZP>
class UartCapabilitiesCommand: public Capabilities_CommandDefs {
public:
static void execute(ZscriptCommandContext<ZP> ctx) {
static void execute(ZscriptCommandContext<ZP> ctx, uint16_t commandsSet) {
CommandOutStream<ZP> out = ctx.getOutStream();

constexpr uint8_t freqCount = sizeof(ZP::uartSupportedFreqs) / sizeof(ZP::uartSupportedFreqs[0]);
Expand All @@ -32,7 +32,7 @@ class UartCapabilitiesCommand: public Capabilities_CommandDefs {
return;
}

out.writeField(RespCommandsSet__C, MODULE_CAPABILITIES(007));
out.writeField(RespCommandsSet__C, commandsSet);
UartUtil<ZP>::writeFrequencySelection(out, freqIndex);

// implements just a single Serial port at this time. Should be expanded to more...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ namespace GenericCore {
template<class ZP>
class CapabilitiesCommand: public core_module::Capabilities_CommandDefs {
public:
static void execute(ZscriptCommandContext<ZP> ctx) {
static void execute(ZscriptCommandContext<ZP> ctx, uint16_t commandsSet) {
CommandOutStream<ZP> out = ctx.getOutStream();
out.writeField(RespCommandsSet__C, commandsSet);

uint16_t versionType = ctx.getField(ReqVersionType__V, userFirmware_Value);
const char *ident = NULL;
Expand Down Expand Up @@ -60,7 +61,6 @@ class CapabilitiesCommand: public core_module::Capabilities_CommandDefs {
} else {
ctx.status(ResponseStatus::VALUE_OUT_OF_RANGE);
}
out.writeField(RespCommandsSet__C, MODULE_CAPABILITIES(000));
out.writeField(RespModulesBankSet__M, COMMAND_SWITCH_EXISTS_BOTTOM_BYTE(00));
#ifdef ZSCRIPT_SUPPORT_NOTIFICATIONS
out.writeField(RespNotificationsSupported__N, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ZscriptCoreModule : public ZscriptModule<ZP> {
static void execute(ZscriptCommandContext<ZP> ctx, uint8_t bottomBits) {
switch (bottomBits) {
case CapabilitiesCommand<ZP>::CODE:
CapabilitiesCommand<ZP>::execute(ctx);
CapabilitiesCommand<ZP>::execute(ctx, MODULE_CAPABILITIES(000));
break;
case EchoCommand<ZP>::CODE:
EchoCommand<ZP>::execute(ctx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace GenericCore {
template<class ZP>
class ExtendedCapabilitiesCommand: public outer_core_module::ExtendedCapabilities_CommandDefs {
public:
static void execute(ZscriptCommandContext<ZP> ctx) {
static void execute(ZscriptCommandContext<ZP> ctx, uint16_t commandsSet) {
CommandOutStream<ZP> out = ctx.getOutStream();
uint16_t target;
if (ctx.getField(ReqModuleBankRequest__M, &target)) {
Expand Down Expand Up @@ -86,7 +86,7 @@ class ExtendedCapabilitiesCommand: public outer_core_module::ExtendedCapabilitie
}
out.writeField(RespModuleBanksLower__L, result);
}
out.writeField(RespCommandsSet__C, MODULE_CAPABILITIES(001));
out.writeField(RespCommandsSet__C, commandsSet);
out.writeField(RespModuleBanksUpper__M, BROAD_MODULE_EXISTENCE);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ZscriptOuterCoreModule: public ZscriptModule<ZP> {

switch (bottomBits) {
case ExtendedCapabilitiesCommand<ZP>::CODE:
ExtendedCapabilitiesCommand<ZP>::execute(ctx);
ExtendedCapabilitiesCommand<ZP>::execute(ctx, MODULE_CAPABILITIES(001));
break;
#ifdef ZSCRIPT_RESET_COMMAND
case outer_core_module::Reset_CommandDefs::CODE:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ template<class ZP>
class ScriptSpaceCapabilitiesCommand: public script_space_module::Capabilities_CommandDefs {
public:

static void execute(ZscriptCommandContext<ZP> ctx) {
static void execute(ZscriptCommandContext<ZP> ctx, uint16_t commandsSet) {
CommandOutStream<ZP> out = ctx.getOutStream();
out.writeField(RespCommandsSet__C, MODULE_CAPABILITIES(002));
out.writeField(RespCommandsSet__C, commandsSet);
out.writeField(RespScriptSpaceCount__P, Zscript<ZP>::zscript.getScriptSpaceCount());
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ScriptSpaceModule: public ZscriptModule<ZP> {
static void execute(ZscriptCommandContext<ZP> ctx, uint8_t bottomBits) {
switch (bottomBits) {
case ScriptSpaceCapabilitiesCommand<ZP>::CODE:
ScriptSpaceCapabilitiesCommand<ZP>::execute(ctx);
ScriptSpaceCapabilitiesCommand<ZP>::execute(ctx, MODULE_CAPABILITIES(002));
break;
case ScriptSpaceSetupCommand<ZP>::CODE:
ScriptSpaceSetupCommand<ZP>::execute(ctx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class SemanticParserTest {
checkActionType(a1, RUN_FIRST_COMMAND);

a1.performAction(&outStream);
checkAgainstOut("!\"Firmware\"V23C107M3NS");
checkAgainstOut("!C107\"Firmware\"V23M3NS");
outStream.reset();
checkParserState(SemanticParserState::COMMAND_COMPLETE);

Expand Down Expand Up @@ -198,7 +198,7 @@ class SemanticParserTest {
static void shouldProduceActionsForSingleCommands() {
SemanticParserTest s1;
SemanticActionType types1[] = { RUN_FIRST_COMMAND, END_SEQUENCE, WAIT_FOR_TOKENS, INVALID };
s1.shouldHandleActionTypesAndIO("Z0V1\n", types1, "!\"Hardware\"V42C107M3NS\n");
s1.shouldHandleActionTypesAndIO("Z0V1\n", types1, "!C107\"Hardware\"V42M3NS\n");
SemanticParserTest s2;
SemanticActionType types2[] = { RUN_FIRST_COMMAND, END_SEQUENCE, WAIT_FOR_TOKENS, INVALID };
s2.shouldHandleActionTypesAndIO("Z1A\n", types2, "!AS\n");
Expand Down

0 comments on commit fb9dbf4

Please sign in to comment.