forked from commaai/panda
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'commaai:master' into master-new
- Loading branch information
Showing
25 changed files
with
352 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
name: drivers | ||
on: [push, pull_request] | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
|
||
jobs: | ||
build_socketcan: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
#define BEEPER_COUNTER_OVERFLOW 25000U // 4kHz | ||
|
||
void beeper_enable(bool enabled) { | ||
if (enabled) { | ||
register_set_bits(&(TIM4->CCER), TIM_CCER_CC3E); | ||
} else { | ||
register_clear_bits(&(TIM4->CCER), TIM_CCER_CC3E); | ||
} | ||
} | ||
|
||
void beeper_init(void) { | ||
// Enable timer and auto-reload | ||
register_set(&(TIM4->CR1), TIM_CR1_CEN | TIM_CR1_ARPE, 0x3FU); | ||
|
||
// Set channel as PWM mode 1 and disable output | ||
register_set_bits(&(TIM4->CCMR2), (TIM_CCMR2_OC3M_2 | TIM_CCMR2_OC3M_1 | TIM_CCMR2_OC3PE)); | ||
beeper_enable(false); | ||
|
||
// Set max counter value and compare to get 50% duty | ||
register_set(&(TIM4->CCR3), BEEPER_COUNTER_OVERFLOW / 2U, 0xFFFFU); | ||
register_set(&(TIM4->ARR), BEEPER_COUNTER_OVERFLOW, 0xFFFFU); | ||
|
||
// Update registers and clear counter | ||
TIM4->EGR |= TIM_EGR_UG; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,29 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import time | ||
import re | ||
from panda import PandaJungle | ||
|
||
RED = '\033[91m' | ||
GREEN = '\033[92m' | ||
|
||
def colorize_errors(value): | ||
if isinstance(value, str): | ||
if re.search(r'(?i)No error', value): | ||
return f'{GREEN}{value}\033[0m' | ||
elif re.search(r'(?i)(?<!No error\s)(err|error)', value): | ||
return f'{RED}{value}\033[0m' | ||
return str(value) | ||
|
||
if __name__ == "__main__": | ||
jungle = PandaJungle() | ||
|
||
while True: | ||
print(chr(27) + "[2J") # clear screen | ||
print("Connected to " + ("internal panda" if jungle.is_internal() else "External panda") + f" id: {jungle.get_serial()[0]}: {jungle.get_version()}") | ||
for bus in range(3): | ||
print(bus, jungle.can_health(bus)) | ||
print(f"\nBus {bus}:") | ||
health = jungle.can_health(bus) | ||
for key, value in health.items(): | ||
print(f"{key}: {colorize_errors(value)} ", end=" ") | ||
print() | ||
time.sleep(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env python3 | ||
import os | ||
import random | ||
from panda import PandaJungle | ||
|
||
def get_test_string(): | ||
return b"test" + os.urandom(10) | ||
|
||
if __name__ == "__main__": | ||
p = PandaJungle() | ||
|
||
p.set_safety_mode(PandaJungle.SAFETY_ALLOUTPUT) | ||
|
||
print("Spamming all buses...") | ||
while True: | ||
at = random.randint(1, 2000) | ||
st = get_test_string()[0:8] | ||
bus = random.randint(0, 2) | ||
p.can_send(at, st, bus) | ||
# print("Sent message on bus: ", bus) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.