mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-09-27 15:23:52 +08:00
ee5c1c4507
* allow re-regage * bump opendbc * bump panda * apply pause/resume fix for hyundai (should do this in a separate PR) * bump opendbc * fix * rename * Fix? * make sure to disengage for allow always cars * fix * combine * more fix * not needed * check if engagement is from openpilot's state machine * Rename * fix panda safety * fix * no fake lfa button for @devtekve ;) * fix non drive gear re-engage * fix settings * combine * add replace method * use replace * remoev already checks if it exists * fix * group * add todo * reserve events * cleaner * hyundai: only allow for cars with lfa button * sunnyParams * make sure it's car only * Move car-specific changes to opendbc * no need * bump opendbc * more fixes * no more available * more! * final? * always emit user disable * no longer needed * move unit test * add sunnypilot to unit tests * bump opendbc * use new cereal * bump opendbc * static analysis * no unittest * no need available * UI border update * show MADS updates * Add TODO * no longer needed * fix changed events * fix cluster enabled * don't add pre enable if not long * should use enabled * enabled <-> active * better format * bump opendbc * static analysis * static analysis * Rename test as collector was dying * Show our overriding * Revert "show MADS updates" This reverts commitdaf0ad62Revert "fix changed events" This reverts commit31d8c97f* ignoring reserved events * adjusting creation delays * back to stock removing allow_cancel * should be enabled * revert * silent lkas disable * no need * user disable tests * just warning * MUST REMOVE test process replay * fix no entry * fixme * bump opendbc * need this check * cleanup * allow entering paused state if no entry from disabled * brake hold should apply to all * in lists * update unit test * simpler * unused * same thing * fix * only mads in enabled state and long in disabled state * unify silent enable * do this for dlob * bump submodules * fix * bump submodules * bump opendbc * less frequent * more events * fix * allow no entry to paused for non-drive gears * fix * use cereal * Revert "allow no entry to paused for non-drive gears" This reverts commit6d64a4dd9c. * allow in all * Revert "allow in all" This reverts commit6375f14891. * should not be all! * rename for clarity * silent park brake * flipped * bump submodules * Bump to latest mads-new panda * bump panda * more nissan * bump panda * bump msgq * bump panda * bump submodules * bump opendbc * bump opendbc * improving the state * Revert "PlayStation® model (#34133)" This reverts commit5160bee543. * should be none * bump panda * bump opendbc * Apply suggestions from code review * bump panda * bump ref panda * add todo-sp * bump panda ref * bump more panda * changing refs * nuke nuke nuke * use sunny's newer states * bump with new panda * bump panda * Parse more flags from alt exp, more tests, hyundai main cruise allowed * Parse more flags from alt exp, more tests, hyundai main cruise allowed * missed * mutation for controls allowed rising edge * ford mutation * license * remove * unused * bump submodules * use always allowed mads button alt exp * fix * whitelist jason's lastname to codespell * test_processes: update ref logs to82c0278* bump submodules * bump submodules * bump submodules * bump panda * add controls mismatch lateral event * Simplify lateral disengagement logic for MADS configuration Reversed the conditional to align the logic with the `disengage_lateral_on_brake` parameter. This ensures that lateral disengagement behavior is more intuitive and matches the expected configuration. Improves code readability and reduces potential misconfigurations. * remove unified engagement mode in panda * controls allow should be allowed at all times * squash! treat MADS button as user entry * heartbeat for mads * heartbeat mismatch exit control * remove always allow mads button from alt * move to safety_mads * remove main cruise allowed from alt * bump panda * heartbeat engaged mads mismatch mutation test * bump panda * use mads the third panda * ignore pre enable with mads * only force exit if actually actuating * use brake signal instead of pedal events when dlob is active * fix tests * fix panda tests * bump panda * new events to retain long blocks * format * uem: do not engage mads if long is engaged * bump submodules * fix not allowed engaged bug * block uem from engaging * flipped * use different heartbeat check if dlob * hard code to skip heartbeat check * remove toyota lta status for lkas, causes weird behaviors * block tesla * bump panda * bump to merged panda * bump opendbc * bump opendbc * bump opendbc * bump opendbc * Apply suggestions from code review * code ignore spells * needs to be in carstate * Bump opendbc * Update MADS toggle descriptions for clarity. Added notes to clarify behavior of the "MadsMainCruiseAllowed" setting, particularly its impact on vehicles without LFA/LKAS buttons. This ensures users are informed about potential implications when disabling this feature. * Updating translations + Adding spanish * Disengage Lateral on Brake -> Pause Lateral on Brake * test_processes: update ref logs todd41005* Apply suggestions from code review * fix mads button not allowed * bump submodules * bump submodule * test_processes: update ref logs to0a0b998* has multiple lists * Revert "has multiple lists" This reverts commita37c1d26fe. * base * Reapply "has multiple lists" This reverts commitd1cd8dcc81. * migrate mads toggles to sp panel * this is why it keeps crashing * house keeping * more housekeeping * more housekeeping * don't show description by default (yet) * reset to main panel when clicked away * more * some more with interactions * don't stretch cause it looks weird with descriptions * simpler to handle offroad transition * some are toggleable while onroad * remove unused event * slight cleanup * default to true for HKG main cruise toggle * append to list after * add Customize MADS to UI preview * simpler * move to sp list * how tf was this removed * update mads settings button on show event * test_processes: update ref logs toefa9c32--------- Co-authored-by: Jason Wen <haibin.wen3@gmail.com>
98 lines
2.8 KiB
C++
98 lines
2.8 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <ctime>
|
|
#include <functional>
|
|
#include <list>
|
|
#include <memory>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "cereal/gen/cpp/car.capnp.h"
|
|
#include "cereal/gen/cpp/log.capnp.h"
|
|
#include "panda/board/health.h"
|
|
#include "panda/board/can.h"
|
|
#include "selfdrive/pandad/panda_comms.h"
|
|
|
|
#define USB_TX_SOFT_LIMIT (0x100U)
|
|
#define USBPACKET_MAX_SIZE (0x40)
|
|
|
|
#define RECV_SIZE (0x4000U)
|
|
|
|
#define CAN_REJECTED_BUS_OFFSET 0xC0U
|
|
#define CAN_RETURNED_BUS_OFFSET 0x80U
|
|
|
|
#define PANDA_BUS_OFFSET 4
|
|
|
|
struct __attribute__((packed)) can_header {
|
|
uint8_t reserved : 1;
|
|
uint8_t bus : 3;
|
|
uint8_t data_len_code : 4;
|
|
uint8_t rejected : 1;
|
|
uint8_t returned : 1;
|
|
uint8_t extended : 1;
|
|
uint32_t addr : 29;
|
|
uint8_t checksum : 8;
|
|
};
|
|
|
|
struct can_frame {
|
|
long address;
|
|
std::string dat;
|
|
long src;
|
|
};
|
|
|
|
|
|
class Panda {
|
|
private:
|
|
std::unique_ptr<PandaCommsHandle> handle;
|
|
|
|
public:
|
|
Panda(std::string serial="", uint32_t bus_offset=0);
|
|
|
|
cereal::PandaState::PandaType hw_type = cereal::PandaState::PandaType::UNKNOWN;
|
|
const uint32_t bus_offset;
|
|
|
|
bool connected();
|
|
bool comms_healthy();
|
|
std::string hw_serial();
|
|
|
|
// Static functions
|
|
static std::vector<std::string> list(bool usb_only=false);
|
|
|
|
// Panda functionality
|
|
cereal::PandaState::PandaType get_hw_type();
|
|
void set_safety_model(cereal::CarParams::SafetyModel safety_model, uint16_t safety_param=0U);
|
|
void set_alternative_experience(uint16_t alternative_experience);
|
|
void set_fan_speed(uint16_t fan_speed);
|
|
uint16_t get_fan_speed();
|
|
void set_ir_pwr(uint16_t ir_pwr);
|
|
std::optional<health_t> get_state();
|
|
std::optional<can_health_t> get_can_state(uint16_t can_number);
|
|
void set_loopback(bool loopback);
|
|
std::optional<std::vector<uint8_t>> get_firmware_version();
|
|
bool up_to_date();
|
|
std::optional<std::string> get_serial();
|
|
void set_power_saving(bool power_saving);
|
|
void enable_deepsleep();
|
|
void send_heartbeat(bool engaged, bool engaged_mads);
|
|
void set_can_speed_kbps(uint16_t bus, uint16_t speed);
|
|
void set_can_fd_auto(uint16_t bus, bool enabled);
|
|
void set_data_speed_kbps(uint16_t bus, uint16_t speed);
|
|
void set_canfd_non_iso(uint16_t bus, bool non_iso);
|
|
void can_send(const capnp::List<cereal::CanData>::Reader &can_data_list);
|
|
bool can_receive(std::vector<can_frame>& out_vec);
|
|
void can_reset_communications();
|
|
|
|
protected:
|
|
// for unit tests
|
|
uint8_t receive_buffer[RECV_SIZE + sizeof(can_header) + 64];
|
|
uint32_t receive_buffer_size = 0;
|
|
|
|
Panda(uint32_t bus_offset) : bus_offset(bus_offset) {}
|
|
void pack_can_buffer(const capnp::List<cereal::CanData>::Reader &can_data_list,
|
|
std::function<void(uint8_t *, size_t)> write_func);
|
|
bool unpack_can_buffer(uint8_t *data, uint32_t &size, std::vector<can_frame> &out_vec);
|
|
uint8_t calculate_checksum(uint8_t *data, uint32_t len);
|
|
};
|