Skip to content

Commit fc086ba

Browse files
committed
Add tests for slc control
1 parent dc72159 commit fc086ba

8 files changed

+115
-5
lines changed

cap_sense.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import time
2+
3+
from tools.plotter import Plot
4+
from tools.serial_manager import DataType, SerialManager, unpack_data
5+
6+
manager = SerialManager("flex-control", baud=38400)
7+
plot = Plot(1, 20000, 40000, pixel_shift=2)
8+
9+
while True:
10+
data = manager.read_bytes(4)
11+
values = unpack_data([DataType.UInt16, DataType.UInt16], data)
12+
13+
# print(f"{values[0]:05d} : 0x{values[0]:04x} : 0b{(values[0]>>8):08b} {(values[0]&0xff):08b}")
14+
# print(values[0]//16)
15+
16+
plot.push(values)
17+
18+
time.sleep(0.001)

compass_test.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import time
2+
3+
from tools.serial_manager import DataType, SerialManager, pack_data, unpack_data
4+
5+
manager = SerialManager("slc-control-lib", baud=115200)
6+
7+
msg_type = [DataType.Float]
8+
9+
while True:
10+
data = unpack_data(msg_type, manager.read_bytes(4))
11+
print(data[0])
12+
13+
time.sleep(0.001)

imu_test.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import time
2+
3+
from tools.plotter import Plot
4+
from tools.serial_manager import DataType, SerialManager, pack_data, unpack_data
5+
6+
manager = SerialManager("slc-control-lib", baud=115200)
7+
# plotter = Plot(3, -32768, 32767)
8+
9+
msg_type = [DataType.UInt8, DataType.Int16, DataType.Int16, DataType.Int16, DataType.Int16, DataType.Int16, DataType.Int16, DataType.Int16, DataType.UInt16, DataType.UInt8, DataType.UInt8, DataType.UInt8]
10+
11+
while True:
12+
data = unpack_data(msg_type, manager.read_bytes(20))
13+
print(data)
14+
15+
time.sleep(0.001)

mag_test.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@
33
from tools.plotter import Plot
44
from tools.serial_manager import DataType, SerialManager, pack_data, unpack_data
55

6-
manager = SerialManager("mag-test", baud=115200)
7-
plotter = Plot(3, -32768, 32767)
6+
manager = SerialManager("slc-control-lib", baud=115200)
7+
# plotter = Plot(3, -32768, 32767)
88

9-
msg_type = [DataType.Int16, DataType.Int16, DataType.Int16]
9+
msg_type = [DataType.Int16, DataType.Int16, DataType.Int16, DataType.UInt16]
1010

1111
while True:
12-
data = unpack_data(msg_type, manager.read_bytes(6))
13-
plotter.push(data)
12+
data = manager.read_bytes(8)
13+
values = unpack_data(msg_type, data)
14+
print(values)
15+
# plotter.push(data)
16+
17+
# data = manager.read_bytes(6)
18+
# print(f"{data[0]} {data[1]}")
1419

1520
time.sleep(0.001)

memory_test.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import time
2+
3+
from tools.plotter import Plot
4+
from tools.serial_manager import DataType, SerialManager, pack_data, unpack_data
5+
6+
manager = SerialManager("slc-control-lib", baud=115200)
7+
8+
# msg_type = [DataType.UInt32, DataType.UInt32, DataType.UInt32, DataType.UInt32]
9+
msg_type = [DataType.Float]
10+
11+
while True:
12+
data = unpack_data(msg_type, manager.read_bytes(4))
13+
print(data)
14+
15+
time.sleep(0.001)

nmea_test.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import time
2+
3+
from tools.plotter import Plot
4+
from tools.serial_manager import DataType, SerialManager, pack_data, unpack_data
5+
6+
manager = SerialManager("slc-control-lib", baud=115200)
7+
8+
msg_type = [DataType.Float]
9+
10+
while True:
11+
data = unpack_data(msg_type, manager.read_bytes(4))
12+
print(data)
13+
14+
time.sleep(0.001)

pressure_test.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import time
2+
3+
from tools.plotter import Plot
4+
from tools.serial_manager import DataType, SerialManager, pack_data, unpack_data
5+
6+
manager = SerialManager("slc-control-lib", baud=115200)
7+
8+
while True:
9+
data = manager.read_bytes(5)
10+
11+
pressure = data[2] << 16 | data[1] << 8 | data[0]
12+
temperature = data[4] << 8 | data[3]
13+
14+
temperature /= 100
15+
pressure /= 40.96
16+
17+
print(f"P: {pressure:.2f}, T: {temperature:.2f}")
18+
19+
time.sleep(0.001)

serial_print_raw.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import time
2+
3+
from tools.serial_manager import SerialManager
4+
5+
manager = SerialManager("slc-control-lib", baud=38400)
6+
7+
while True:
8+
data = manager.read_all()
9+
if data:
10+
print(data)
11+
time.sleep(0.001)

0 commit comments

Comments
 (0)