-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpyvescTest.py
More file actions
35 lines (29 loc) · 873 Bytes
/
pyvescTest.py
File metadata and controls
35 lines (29 loc) · 873 Bytes
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
import pyvesc
import serial
import time
conn=serial.Serial(port="/dev/ttyACM0",baudrate=115200)
#request data
conn.write(pyvesc.encode_request(pyvesc.GetValues))
while conn.inWaiting() < 70:
pass
_buffer= conn.read(70)
(vescMessage,consumed) = pyvesc.decode(_buffer)
if(vescMessage):
print("VESC Data:")
print(vescMessage.temp_fet_filtered)
print(vescMessage.temp_motor_filtered)
print(vescMessage.avg_motor_current)
print(vescMessage.avg_input_current)
print(vescMessage.duty_cycle)
print(vescMessage.rpm)
print(vescMessage.v_in)
print(vescMessage.amp_hours)
print(vescMessage.watt_hours)
print(vescMessage.tachometer)
print(vescMessage.tachometer_abs)
print(vescMessage.mc_fault_code)
print(vescMessage.temp_mos1)
print(vescMessage.temp_mos2)
print(vescMessage.temp_mos3)
throt_msg = pyvesc.SetDutyCycle(10000)
conn.write(pyvesc.encode(throt_msg))