Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CAN Errors #201

Closed
BlakeFreer opened this issue Oct 2, 2024 · 0 comments · Fixed by #314 or #316
Closed

CAN Errors #201

BlakeFreer opened this issue Oct 2, 2024 · 0 comments · Fixed by #314 or #316
Assignees

Comments

@BlakeFreer
Copy link
Contributor

BlakeFreer commented Oct 2, 2024

CAN Errors

Number of members: 2

Relevant skills: C++, CAN, Go

Timeline: Mid November

Description

We have no mechanism for reporting errors from the vehicle microcontrollers. This project will send errors over the CAN line and process them on a host machine.

CAN messages can hold 64 bits of data. That's 64 boolean values which can each indicate whether a specific error has occured!

We should have a global "Error" object for each microcontroller which has 64 boolean values. Each project is free to define what errors it will report. For example, a FreeRTOS project should be able to indicate a Stack Overflow error, while the FrontController (which reads pedal positions) should be able to report when a sensor value is out of the expected range.

We will periodically send the Error struct over CAN. Other devices (like our data logger or Raspberry Pi) will log these messages and display them to the developer for debugging.

Tasks

This is a two person project. One member (upper year) will write the firmware to handle and send the messages while the other (first year) will write a command line tool which displays the error statuses. The interface between the two members is a DBC file which describes what each error message means.

Work together on steps 1 and 2, then break off for step 3a and 3b (these represent the bulk of the work for this issue).

1. Start a new Demo Project

This project is your deliverable. Follow these instructions to set it up https://macformula.github.io/racecar/firmware/project-structure/

You only need to write a CLI platform layer, not stm.

2. Create a CAN DBC for the Errors

There should be 1 message with 64 one-bit signals. You can call the signals error0-error63 for now.

There is no specified recipient for the message, so use Vector__XXX.

Create a config.yaml file to generate the C++ code from the DBC. See the Demo/CAN projects for an example config.

3a. C++ Implementation

A CAN object with 64 booleans has been created for you. Decide how you want to set and clear error bits throughout the program. In your Demo Project, mock up error states. Continuously (every 500 ms) send the CAN message.

3b. CLI Viewer

Create a CLI program, in Go, which reads CAN messages from a CAN socket (talk to me if you need to set up a linux environment).

You can put your code in a folder under racecar/scripts. Choose a cool name for your program (not just CAN_Error_CLI).

Here are some milestones you can strive for:

  1. Print incoming CAN messages to stdout.
  2. Parse the DBC file to print the names of the Errors which are currently set.
  3. Collect multiple instances of the same error message into one location to keep the UI clear.
  4. Allow the user to "Acknowledge" an error to remove it from the screen.
  5. Parse command line flags to ignore specific errors.

Add any other features that you would find helpful when debugging.

  1. Integration

Resources

CAN DBC Files https://www.csselectronics.com/pages/can-dbc-file-database-intro

@sokosam sokosam self-assigned this Oct 2, 2024
@luaibash luaibash self-assigned this Oct 2, 2024
@luaibash luaibash linked a pull request Nov 10, 2024 that will close this issue
@sokosam sokosam linked a pull request Nov 12, 2024 that will close this issue
@github-project-automation github-project-automation bot moved this from Backlog to Done in Firmware - Architecture Nov 20, 2024
BlakeFreer pushed a commit that referenced this issue Nov 20, 2024
* Moved all CANError demo code to branch

* Fixing the config files for the CAN project

* Added sending/logging functionality of errors in CANErrors project

* Reformatted code and added comments for clarity

* Combined all errors into one 64 bit signal in dbc file for easier use

* Created errors class to set/send errors

* Moved bindings to its own file and started using errors class

* Moved class to header file, added enums for errors

* Removed changes for foo/bar config files

* fixed foo config file

* Moved error class/enum to app.h file

* Removed NS section of dbc file, and added more content to readme

* Cleaned up ErrorHandler and main file

* Modified dbc file to create unsigned int

* Refactored app.h to follow naming conventions/best practices, and switch the enum to an enum class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
3 participants