Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
71 lines (56 loc) · 2.06 KB

File metadata and controls

71 lines (56 loc) · 2.06 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import time
import argparse
from DCM.core.serial_interface import SerialInterface
# Example params for testing the microcontroller firmware
TEST_PARAMS = {
# "BYTE1": 0x16 = to enable sending data either direction
# "BYTE2": 0x22 = Simulink sends data to DCM
# or 0x55 = DCM sends data to Simulink
# DATA STARTS FROM BYTE 3
"MODE": 2, #AAI
"ARP": 250,
"VRP": 320,
"atrial_amp": 3.0,
"ventricular_amp": 3.0,
"atrial_width": 5, # Note: serial_interface casts to int. If this is ms, 5ms.
"ventricular_width": 6,
"atr_cmp_ref_pwm": 1200,
"vent_cmp_ref_pwm": 1300,
"reaction_time": 20,
"recovery_time": 10,
"PVARP": 200,
"AV_delay": 150, # FIXED_AV_DELAY -> AV_delay
"response_factor": 8,
"activity_threshold": 3,
"URL": 150, # UPPER_RATE_LIMIT -> URL
"LRL": 60, # LOWER_RATE_LIMIT -> LRL
"MSR": 160, # MAXIMUM_SENSOR_RATE -> MSR
"rate_smoothing": 5
}
def on_ack():
print("[MCU] ACK received")
def main():
parser = argparse.ArgumentParser(description="DCM UART test tool for Simulink team")
parser.add_argument("port", help="Serial port connected to microcontroller")
parser.add_argument("--baud", type=int, default=115200, help="UART baudrate")
parser.add_argument("--send", action="store_true", help="Send parameter packet")
args = parser.parse_args()
iface = SerialInterface(args.port, args.baud)
print(f"[INFO] Opening port {args.port} @ {args.baud} ...")
iface.ack_callback = on_ack
iface.connect()
time.sleep(0.5)
if args.send:
print("[INFO] Sending test parameters to microcontroller...")
iface.send_parameters(TEST_PARAMS)
print("[INFO] Running. Press CTRL+C to exit.")
try:
while True:
time.sleep(0.1)
except KeyboardInterrupt:
print("\n[INFO] Exiting...")
iface.disconnect()
# to run first find the uart port then send params using
# py uart_testing.py COM4 --send
if __name__ == "__main__":
main()
Morty Proxy This is a proxified and sanitized view of the page, visit original site.