Skip to content

Commit

Permalink
[#110] Fix code quality comments
Browse files Browse the repository at this point in the history
  • Loading branch information
susanw1 committed Nov 18, 2023
1 parent 17c30f8 commit cd2b459
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ class UartModule : public ZscriptModule<ZP> {

static void execute(ZscriptCommandContext<ZP> ctx, uint8_t bottomBits) {
switch (bottomBits) {
case uart_module::ZscriptUartCapabilitiesCommand<ZP>::CODE:
uart_module::ZscriptUartCapabilitiesCommand<ZP>::execute(ctx);
case uart_module::UartCapabilitiesCommand<ZP>::CODE:
uart_module::UartCapabilitiesCommand<ZP>::execute(ctx);
break;
#ifdef ZSCRIPT_HAVE_UART_CHANNEL
case uart_module::ZscriptUartChannelInfoCommand<ZP>::CODE:
uart_module::ZscriptUartChannelInfoCommand<ZP>::execute(ctx);
case uart_module::UartChannelInfoCommand<ZP>::CODE:
uart_module::UartChannelInfoCommand<ZP>::execute(ctx);
break;
case uart_module::ZscriptUartChannelSetupCommand<ZP>::CODE:
uart_module::ZscriptUartChannelSetupCommand<ZP>::execute(ctx);
case uart_module::UartChannelSetupCommand<ZP>::CODE:
uart_module::UartChannelSetupCommand<ZP>::execute(ctx);
break;
#endif
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class UartChannel : public ZscriptChannel<ZP> {
}

UartChannel() :
buffer(), ZscriptChannel<ZP>(&out, &tBuffer, uart_module::MODULE_FULL_ID, true),
ZscriptChannel<ZP>(&out, &tBuffer, uart_module::MODULE_FULL_ID, true),
tBuffer(buffer, ZP::uartChannelBufferSize), tokenizer(tBuffer.getWriter(), 2), usingTmp(false) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Zscript {
namespace uart_module {

template<class ZP>
class ZscriptUartCapabilitiesCommand: public Capabilities_CommandDefs {
class UartCapabilitiesCommand: public Capabilities_CommandDefs {
public:
static void execute(ZscriptCommandContext<ZP> ctx) {
CommandOutStream<ZP> out = ctx.getOutStream();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ class ZscriptUartOutStream;
namespace uart_module {

template<class ZP>
class ZscriptUartChannelInfoCommand : public ChannelInfo_CommandDefs {
class UartChannelInfoCommand : public ChannelInfo_CommandDefs {
public:
static void execute(ZscriptCommandContext<ZP> ctx) {
uint16_t channelIndex;
if (!ctx.getReqdFieldCheckLimit(ReqChannel__C, Zscript<ZP>::zscript.getChannelCount(), &channelIndex)) {
return;
}
UartChannel<ZP> *selectedChannel = Zscript<ZP>::zscript.getChannels()[channelIndex];
UartChannel<ZP> *selectedChannel = (UartChannel<ZP> *) Zscript<ZP>::zscript.getChannels()[channelIndex];
if (selectedChannel->getAssociatedModule() != MODULE_FULL_ID) {
ctx.status(ResponseStatus::VALUE_UNSUPPORTED);
return;
Expand All @@ -60,10 +60,8 @@ class ZscriptUartChannelInfoCommand : public ChannelInfo_CommandDefs {

out.writeField(RespBitsetCapabilities__B, (parity & 0x2 ? RespBitsetCapabilities_Values::parityOn_field : 0)
| (parity & 0x1 ? RespBitsetCapabilities_Values::parityOdd_field : 0)
| (stopBits? RespBitsetCapabilities_Values::doubleStop_field : 0)
| (stopBits ? RespBitsetCapabilities_Values::doubleStop_field : 0)
);

out.writeField(RespBitsetCapabilities__B, RespBitsetCapabilities_Values::parityOn_field | RespBitsetCapabilities_Values::doubleStop_field);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ class ZscriptUartOutStream;
namespace uart_module {

template<class ZP>
class ZscriptUartChannelSetupCommand : public ChannelSetup_CommandDefs {
class UartChannelSetupCommand : public ChannelSetup_CommandDefs {
public:
static void execute(ZscriptCommandContext<ZP> ctx) {
uint16_t channelIndex;
if (!ctx.getReqdFieldCheckLimit(ReqChannel__C, Zscript<ZP>::zscript.getChannelCount(), &channelIndex)) {
return;
}

UartChannel<ZP> *selectedChannel = Zscript<ZP>::zscript.getChannels()[channelIndex];
auto selectedChannel = (UartChannel<ZP> *) Zscript<ZP>::zscript.getChannels()[channelIndex];
if (selectedChannel->getAssociatedModule() != MODULE_FULL_ID) {
ctx.status(ResponseStatus::VALUE_UNSUPPORTED);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ class UartUtil {
public:
static void writeFrequencySelection(CommandOutStream<ZP> out, uint8_t freqIndex) {
const uint32_t maxBaud = ZP::uartSupportedFreqs[freqIndex];
uint8_t maxBaudBytes[4]{(maxBaud >> 24) & 0xff, (maxBaud >> 16) & 0xff, (maxBaud >> 8) & 0xff, (maxBaud) & 0xff};
uint8_t maxBaudBytes[4]{(uint8_t) ((maxBaud >> 24) & 0xff),
(uint8_t) ((maxBaud >> 16) & 0xff),
(uint8_t) ((maxBaud >> 8) & 0xff),
(uint8_t) ((maxBaud) & 0xff)};
out.writeBigHex(maxBaudBytes, 4);
}
};
Expand Down

0 comments on commit cd2b459

Please sign in to comment.