KSU-MS / KS6e-VCU-firmware

CURRENT KS6E VCU code
1 stars 0 forks source link

Dash light if any NOT main code is on the car #14

Open KSUMotorsport opened 1 year ago

KSUMotorsport commented 1 year ago

Could include a single parameter for each board which would sent out a CAN packet indicating if any code currently running on the car is untested. Whenever code has been tested and verified to not break the car, the CAN packet would be enabled, broadcasting a "code is MAIN" message. Would just be a unique ID for each board, with all of the boards on CAN 1 being sent to VCU to get repeated onto CAN 2. The dash would then turn a light OFF if any message is being received, indicating that the code is current. This would also allow us to see which board has untested code on it, and save time instead of having to reupload code onto every single board each time the car goes out.

The OK message must be received to turn the light off, which keeps false "OK" messages being interpreted (i.e. the code being tested kills the CANBUS and thus no message would get to the dash)

mathbrook commented 8 months ago
import subprocess

def is_main_or_master_dirty():
    try:
        # Run 'git rev-parse --abbrev-ref HEAD' to get the current branch name
        current_branch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).decode('utf-8').strip()

        # Check if the current branch is either "main" or "master"
        is_main_or_master = current_branch in ['main', 'master']

        # Run 'git status --porcelain' to check for uncommitted changes
        is_dirty = subprocess.call(['git', 'status', '--porcelain']) != 0

        return is_main_or_master, is_dirty
    except Exception as e:
        print(f"Error: {e}")
        return False, False

is_main_or_master, is_dirty = is_main_or_master_dirty()
print(f"Is main or master: {is_main_or_master}")
print(f"Is dirty: {is_dirty}")

chatgpt script, integrating this with https://github.com/KSU-MS/pio-git-hash-gen would let you tell at compile time:

  1. commit ID (so we know what code is on a board)
  2. whether the code uploaded was "main" or "master"
  3. whether there were also not-pushed changes to the code that were uploaded. THe dash could then just consume the true/false flag of if the code is main or not, then by plugging into the CAN bus you could track down what board it is.