-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import serial | ||
import binascii | ||
|
||
com = "/dev/cu.usbserial-0001" | ||
|
||
con = serial.Serial(com, baudrate=115200, timeout=5) | ||
while True: | ||
header = con.read(size=2) | ||
print(binascii.hexlify(header)) | ||
|
||
msg_type = con.read(size=1) | ||
print(binascii.hexlify(msg_type)) | ||
|
||
package_id = con.read(size=1) | ||
print(binascii.hexlify(package_id)) | ||
|
||
message_size = con.read(size=2) | ||
print(binascii.hexlify(message_size)) | ||
|
||
body = con.read(size=int.from_bytes(message_size, byteorder="big")) | ||
print(binascii.hexlify(body)) | ||
|
||
if msg_type == bytes.fromhex("20"): | ||
print("received debug message:") | ||
print(body) | ||
|
||
con.close() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import serial | ||
import binascii | ||
import logging | ||
|
||
com = "/dev/cu.usbserial-0001" | ||
|
||
logging.basicConfig(level=logging.INFO) | ||
|
||
con = serial.Serial(com, baudrate=115200, timeout=5) | ||
|
||
while True: | ||
header = con.read(size=2) | ||
|
||
msg_type = con.read(size=1) | ||
|
||
package_id = con.read(size=1) | ||
|
||
|
||
message_size = con.read(size=2) | ||
|
||
|
||
body = con.read(size=int.from_bytes(message_size, byteorder="big")) | ||
|
||
|
||
if msg_type == bytes.fromhex("20"): | ||
logging.info("received debug message:") | ||
logging.info(body) | ||
|
||
elif msg_type == bytes.fromhex("00"): | ||
logging.info("receive sync") | ||
con.write(bytes.fromhex("445080000000")) | ||
elif msg_type == bytes.fromhex("01"): | ||
logging.info("receive heartbeat") | ||
con.write(bytes.fromhex("445081000000")) | ||
elif msg_type == bytes.fromhex("10"): | ||
logging.info("receive position") | ||
""" | ||
4450 // magic number | ||
10 // message type: position | ||
00 // packet ID: not utilized | ||
0028 // payload length: 2 handles, 5 values each, 4 bytes each - 2*5*4 = 40 = 0x28 | ||
FFFFFFFF // x position of first handle | ||
FFFFFFFF // y position of first handle | ||
FFFFFFFF // rotation of first handle | ||
FFFFFFFF // x position of first handle's god object | ||
FFFFFFFF // y position of first handle's god object | ||
FFFFFFFF // x position of second handle | ||
FFFFFFFF // y position of second handle | ||
FFFFFFFF // rotation of second handle | ||
FFFFFFFF // x position of second handle's god object | ||
FFFFFFFF // y position of second handle's god object | ||
""" | ||
x_1 = int.from_bytes(body[:4], byteorder='big', signed=False) | ||
y_1 = int.from_bytes(body[4:8], byteorder='big', signed=False) | ||
r_1 = int.from_bytes(body[8:12], byteorder='big', signed=False) | ||
g_x1 = int.from_bytes(body[12:16], byteorder='big', signed=False) | ||
g_y1 = int.from_bytes(body[16:20], byteorder='big', signed=False) | ||
x_2 = int.from_bytes(body[20:24], byteorder='big', signed=False) | ||
y_2 = int.from_bytes(body[24:28], byteorder='big', signed=False) | ||
r_2 = int.from_bytes(body[28:32], byteorder='big', signed=False) | ||
g_x2 = int.from_bytes(body[32:36], byteorder='big', signed=False) | ||
g_y2 = int.from_bytes(body[36:40], byteorder='big', signed=False) | ||
|
||
|
||
logging.info(f"{x_1} {y_1} {r_1} {g_x1} {g_y1} {x_2} {y_2} {r_2} {g_x2} {g_y2}") | ||
else: | ||
logging.warning(binascii.hexlify(header)) | ||
|
||
logging.warning((binascii.hexlify(msg_type))) | ||
|
||
logging.warning(binascii.hexlify(package_id)) | ||
logging.warning(binascii.hexlify(message_size)) | ||
logging.warning(binascii.hexlify(body)) | ||
|
||
con.close() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Dualpanto Testing | ||
|
||
Goal of this repository is to provide some (semi) automatic testing for the dualpanto platform. | ||
|
||
This involves basic functionality checks of the hardware, the firmware and potentially the unity integration | ||
|
||
## Levels of Testing and Repository structure | ||
|
||
### Hardware | ||
|
||
On a hardware level we need to test that the dualpanto can | ||
|
||
- show up as a serial device | ||
- receive uploaded (mini) firmware | ||
- read encoders | ||
- actuate motors | ||
- move two handles in sync | ||
|
||
### Firmware | ||
|
||
On a firmware level we need to test that the dualpanto can | ||
- perform the handshake | ||
- keep the connection alive | ||
- move the handles if instructed | ||
- report the handle position | ||
- accept obstacles | ||
- render obstacles | ||
|
||
### Unity | ||
|
||
TODO | ||
|
||
|
||
This project is currenty under developement | ||
|
||
For questions, please reach out to [email protected] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
COM_PORT = "/dev/tty.SLAB_USBtoUART" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.pio |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[platformio] | ||
description = Dual Panto firmware | ||
|
||
[env:esp32dev] | ||
platform = [email protected] | ||
framework = arduino | ||
board = esp32dev | ||
monitor_speed = 115200 | ||
|
||
# On OSX you need to use the following USB port | ||
# On Windows outcomment this line‚ | ||
# upload_port = /dev/cu.SLAB_USBtoUART |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include "Arduino.h" | ||
|
||
#ifndef LED_BUILTIN | ||
#define LED_BUILTIN 13 | ||
#endif | ||
|
||
void setup() | ||
{ | ||
// initialize LED digital pin as an output. | ||
pinMode(LED_BUILTIN, OUTPUT); | ||
} | ||
|
||
void loop() | ||
{ | ||
// turn the LED on (HIGH is the voltage level) | ||
digitalWrite(LED_BUILTIN, HIGH); | ||
|
||
// wait for a second | ||
delay(1000); | ||
|
||
// turn the LED off by making the voltage LOW | ||
digitalWrite(LED_BUILTIN, LOW); | ||
|
||
// wait for a second | ||
delay(1000); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.pio |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[platformio] | ||
description = Dual Panto firmware | ||
|
||
[env:esp32dev] | ||
platform = [email protected] | ||
framework = arduino | ||
board = esp32dev | ||
monitor_speed = 115200 | ||
|
||
# On OSX you need to use the following USB port | ||
# On Windows outcomment this line‚ | ||
# upload_port = /dev/cu.SLAB_USBtoUART |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include "Arduino.h" | ||
|
||
#ifndef LED_BUILTIN | ||
#define LED_BUILTIN 13 | ||
#endif | ||
|
||
void setup() | ||
{ | ||
// initialize LED digital pin as an output. | ||
pinMode(LED_BUILTIN, OUTPUT); | ||
} | ||
|
||
void loop() | ||
{ | ||
// turn the LED on (HIGH is the voltage level) | ||
digitalWrite(LED_BUILTIN, HIGH); | ||
|
||
// wait for a second | ||
delay(1000); | ||
|
||
// turn the LED off by making the voltage LOW | ||
digitalWrite(LED_BUILTIN, LOW); | ||
|
||
// wait for a second | ||
delay(1000); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.pio |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[platformio] | ||
description = Dual Panto firmware | ||
|
||
[env:esp32dev] | ||
platform = [email protected] | ||
framework = arduino | ||
board = esp32dev | ||
monitor_speed = 115200 | ||
|
||
# On OSX you need to use the following USB port | ||
# On Windows outcomment this line‚ | ||
# upload_port = /dev/cu.SLAB_USBtoUART |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include "Arduino.h" | ||
|
||
int incomingByte = 0; // for incoming serial data | ||
|
||
|
||
void setup() | ||
{ | ||
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps | ||
} | ||
|
||
void loop() | ||
{ | ||
// send data only when you receive data: | ||
if (Serial.available() > 0) { | ||
// read the incoming byte: | ||
incomingByte = Serial.read(); | ||
// say what you got: | ||
Serial.write(incomingByte); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.sh text eol=lf |