Skip to content

Conversation

@arduinoenigma
Copy link
Contributor

@arduinoenigma arduinoenigma commented Sep 19, 2025

Pull request #128 gave compilation errors on some platforms, an invalid conversion in setNormalOneShotMode()

In Arduino 2.3.5 with Preferences->Compiler Warnings->All did not complain at all
In Arduino 1.8.19 with Preferences->Compiler Warnings->All throws that same message as a warning, not an error.

The error is here:

MCP2515::ERROR MCP2515::setNormalOneShotMode()
{
return setMode(CANCTRL_REQOP_NORMAL | CANCTRL_OSM);
}

The setMode function expects a (CANCTRL_REQOP_MODE) where the | operand returns an int

Since CANCTRL_REQOP_NORMAL is defined as 0x00; this error can be fixed by adding CANCTRL_REQOP_OSM to the CANCTRL_REQOP_MODE enum.

in mcp2515.h

    enum /*class*/ CANCTRL_REQOP_MODE : uint8_t {
        CANCTRL_REQOP_NORMAL     = 0x00,
        CANCTRL_REQOP_OSM        = 0x08,
        CANCTRL_REQOP_SLEEP      = 0x20,
        CANCTRL_REQOP_LOOPBACK   = 0x40,
        CANCTRL_REQOP_LISTENONLY = 0x60,
        CANCTRL_REQOP_CONFIG     = 0x80,
        CANCTRL_REQOP_POWERUP    = 0xE0
    };

and changing in mcp2515.cpp

MCP2515::ERROR MCP2515::setNormalOneShotMode()
{
return setMode(CANCTRL_REQOP_OSM);
}

Now it compiles without warnings/errors.

@autowp
Copy link
Owner

autowp commented Sep 19, 2025

@arduinoenigma may i ask you to squash changes into single commit?

@arduinoenigma
Copy link
Contributor Author

Had to close this PR to add all the changes under one commit

@PhilippeArdit
Copy link

PhilippeArdit commented Sep 21, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants