Skip to content

Conversation

@AarjavJain101
Copy link
Contributor

@AarjavJain101 AarjavJain101 commented Jul 1, 2024

Sunlink Pull Request Description

API Mode Parsing and Radio diagnostics. All Work Credited to Evan Owens. PR separate created by me for testing purposes.

Steps Before Merge:

  • Test with serial data on car.
  • Test with offline mode on car (PCAN into CAN splitter).

My changes are as follows:

A. API Mode Parsing Support

  1. Changed linked_telemetry to split chunks based off a regex that identifies different api packets.

  2. Modified main.py to identify API packets and then split them into individual messages, storing those messages in a list

  3. Parse requests resemble Aarjav's latest changes, with main.py now returning a list of parse responses

  4. Created API_Frame python file, which contains functions that main.py uses to break down API Frames. These functions include:

  5. Split_API_Packet -> Loops through Each packet, and Grabs 24 byte long can messages into a list, appends a Type byte in front of each message (Always CAN, but can append different types of bytes when we bring back IMU and GPS)

  6. Parse API Packet - identifies the type of API packet, whether it is a 0x90 Receive Frame, or an AT Command (0x88, 0x97). If packet is a receive frame, it is passed to split_API_Packet.If packet is a AT command, the corresponding Type Byte is appended onto the front, and it is returned to main.py.

  7. Create_Message now creates messages based off the first byte in each message, which is the type byte. As mentioned above, these type bytes are added by the Parse API Packet Function (while I have also added code in respective areas to add type bytes to randomizer functions, and CAN messages from the PCAN.) These means that non api randomizers create parse-able messages.

  8. Created randomizer functions for API Frames, AT Local commands, and AT Remote commands. The API Frame randomizer utilizes CAN, GPS, and IMU randomizers to build the frame.

  9. Added Data classes for AT Local and AT Remote Messages.

B. AT Command Data Collection

  1. Added Data classes for AT Local and AT Remote Messages.

  2. Created AT Diagnostic Command Function/Thread which transmits Diagnostic AT commands on an interval. So far, we transmit RSSI (DB), GOOD Packets Received (GD), and Packets with Errors Received (ER). We can expand this list

  3. Slightly Restructured linked telemetry, and moved where the serial port is open in order to pass ser as a parameter to the Diagnostic At Command. This means that args.randomizer/can/else statement which selects the message source is slightly different.

  4. Implemented thread locking, and event scheduling to coordinate access over the serial port. Right now it works as follows:
    a. thread for Diagnostic At Commands (write thread) is created. Enters its forever loop. A forever loop for reading serial is also entered on the main thread but stops on event.wait() function call.
    b. write thread takes control of serial thread lock, and transmits AT commands. A Flag is then set that indicates that the AT commands have recently been transmitted.
    c. write thread checks flag, and if it has recently transmitted commands, it gives up lock, and sets an event allowing the main thread to start reading the serial stream. Write thread then goes to sleep. Read thread will continue reading the stream until the write thread wakes up again.
    d. When the write thread wakes up, it clears the read event, stopping serial reading, and allowing the write thread to take over the write lock.
    e. The last steps repeat over and over etc...

** Note: thinking about it now, i dont think flag is required in above process, just over complicates it. I will leave it in for now because i know it works, but i will test removing it tomorrow.

  1. added new parameters to parameters.py for various things.

Monday Link

Not sure if theres a monday card any more cant seem to find it.

Effected Components

  • Link Telemetry
  • Parser
  • Docs

Testing

  • [ ] Randomizer testing
  • Radio Receiver testing for AT Commands

Ran randomizer and radio receiver until I got no more Parse Fails.

Sanity check

  • CAN ID table / DBC updated
  • gitignore updated and commited
  • Steps confirmed

Sources

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.

3 participants