Skip to content

[Feature] Implement NXT color sensor checksum #2607

@laurensvalk

Description

@laurensvalk

Is your feature request related to a problem? Please describe.
We receive information from the NXT Color Sensor here:

http://github.com/pybricks/pybricks-micropython/blob/d811a706da236068983aff9ecefc6465a50b06c6/lib/pbio/src/port_dcm_ev3.c#L402-L420

There is a note there saying:

        // REVISIT: Test checksum and exit on failure.

We have not yet done this, but may want to after all, to catch cases like #2601.

At the top of this file, set #define DEBUG 1 (instead of 0), to get debug prints in the Pybricks Code output pane for easy debugging.

What to do?

  • In pbio_port_dcm_nxt_color_sensor_state_t add a field crc.
  • In the loop that says Receive all calibration info, update this CRC as it comes in.
  • After the loop, Compare it to the crc field in pbio_port_dcm_nxt_color_sensor_data_t.
  • Return PBIO_ERROR_IO if they do not match.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is neededplatform: EV3Issues related to LEGO MINDSTORMS EV3topic: sensorsIssues involving sensors

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions