diff --git a/board/jungle/main.c b/board/jungle/main.c index 940fbc1b22..40777d9965 100644 --- a/board/jungle/main.c +++ b/board/jungle/main.c @@ -53,21 +53,6 @@ uint16_t button_press_cnt = 0U; void tick_handler(void) { if (TICK_TIMER->SR != 0) { if (generated_can_traffic) { - // queue up messages - for (uint16_t i = 0U; i < 100U; i++) { - CANPacket_t to_send; - to_send.returned = 0U; - to_send.rejected = 0U; - to_send.extended = 0U; - to_send.addr = 0x200U + i; - to_send.bus = i % 3U; - to_send.data_len_code = 8U; - (void)memcpy(to_send.data, "\xff\xff\xff\xff\xff\xff\xff\xff", dlc_to_len[to_send.data_len_code]); - can_set_checksum(&to_send); - - can_send(&to_send, to_send.bus, true); - } - for (int i = 0; i < 3; i++) { if (can_health[i].transmit_error_cnt >= 128) { (void)llcan_init(CANIF_FROM_CAN_NUM(i)); @@ -216,8 +201,32 @@ int main(void) { #endif // LED should keep on blinking all the time - uint64_t cnt = 0; + uint32_t cnt = 0; for (cnt=0;;cnt++) { + if (generated_can_traffic) { + // fill up all the queues + can_ring *qs[] = {&can_tx1_q, &can_tx2_q, &can_tx3_q}; + for (int j = 0; j < 3; j++) { + for (uint16_t n = 0U; n < can_slots_empty(qs[j]); n++) { + uint16_t i = cnt % 100U; + CANPacket_t to_send; + to_send.returned = 0U; + to_send.rejected = 0U; + to_send.extended = 0U; + to_send.addr = 0x200U + i; + to_send.bus = i % 3U; + to_send.data_len_code = i % 8U; + (void)memcpy(to_send.data, "\xff\xff\xff\xff\xff\xff\xff\xff", dlc_to_len[to_send.data_len_code]); + can_set_checksum(&to_send); + + can_send(&to_send, to_send.bus, true); + } + } + + delay(1000); + continue; + } + // useful for debugging, fade breaks = panda is overloaded for (uint32_t fade = 0U; fade < MAX_LED_FADE; fade += 1U) { current_board->set_led(LED_RED, true);