commaai / panda

code powering the comma.ai panda
MIT License
1.53k stars 776 forks source link

On startup Panda sends old can messages #137

Closed adhintz closed 5 years ago

adhintz commented 6 years ago

When starting up, Panda sends old can messages.

Steps to reproduce: 1) Have EON connected to Panda. Have Panda's 12VIN and Ignition pins connected to the car's ignition. This way the Panda only gets power when the car is on. Optionally have a second Panda connected to OBD2 to observe what's on the can bus. 2) Drive around with EON and OpenPilot. 3) Turn off the car. This immediately turns off power to the Panda. 4) Turn on the car.

Expected results: The Panda doesn't send any can bus messages until the EON tells it to.

Actual results: As observed by the second Panda, when the Panda starts up, it sends some can bus messages left over from the previous drive. I'm unsure if these messages are just queued up from the previous run or if some memory structure is somewhat corrupted.

adhintz commented 6 years ago

This fix this, in board/drivers/can.h I tried modifying can_init() to call can_clear()

void can_init(uint8_t can_number) {
  if (can_number == 0xff) return;

  uint8_t bus_number = BUS_NUM_FROM_CAN_NUM(can_number);
  can_clear(can_queues[bus_number]);

However then running debug_console.py I just see a bunch of "can_push failed!" messages and the Panda doesn't work properly.

adhintz commented 5 years ago

This hasn't recently been an issue for me, so closing the issue for now.

tssheth commented 3 years ago

@adhintz How do you resolve the "can_push failed" and what does it indicate?