aboutsummaryrefslogtreecommitdiff
path: root/protocol2.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-12-30 03:26:51 +0100
committerDimitri Sokolyuk <demon@dim13.org>2016-12-30 03:26:51 +0100
commit7e62f728fe33fd81ccadf11eca43d424a9260d09 (patch)
treeb5542d22fa1f4a487fba883073e7def515807ed9 /protocol2.go
parentdca5172d2f2174ba3f272347840ad1842ded941e (diff)
tweak around
Diffstat (limited to 'protocol2.go')
-rw-r--r--protocol2.go25
1 files changed, 18 insertions, 7 deletions
diff --git a/protocol2.go b/protocol2.go
index 333b871..e578c9c 100644
--- a/protocol2.go
+++ b/protocol2.go
@@ -1,5 +1,10 @@
package anki
+import (
+ "fmt"
+ "time"
+)
+
const (
VehicleMsgV2CSpeedUpdate ID = 0x36
VehicleMsgV2CStatusUpdate ID = 0x3f
@@ -15,9 +20,9 @@ const (
type VehicleMsgSpeedUpdate struct {
Size uint8
MsgID ID
- DesiredSpeed uint16 // mm/sec
- Accel uint16 // mm/sec²
- CurrentSpeed uint16 // mm/sec
+ DesiredSpeed Speed // mm/sec
+ Accel Accel // mm/sec² -- missing on older firmware
+ CurrentSpeed Speed // mm/sec -- missing on older firmware
}
// 05 3F 01 00 01 00
@@ -36,8 +41,8 @@ type VehicleMsgLaneChangeUpdate struct {
MsgID ID
CurrentOffsetFromRoadCenter float32
TargetOffsetFromRoadCenter float32
- HorizontalSpeed uint16
- VerticalSpeed uint16
+ HorizontalSpeed Speed
+ VerticalSpeed Speed
LaneChangeID uint8
}
@@ -49,13 +54,19 @@ type VehicleMsgCollisionDetected struct {
WasFrontBackCollision uint8
}
+type UT uint32
+
+func (u UT) String() string {
+ return fmt.Sprintf("%v", time.Duration(u)*time.Microsecond)
+}
+
// 0B 86 11 00 26 08 00 00 13 10 00 00 cchii
type VehicleMsgCycleOvertime struct {
Size uint8
MsgID ID
NumOvertimeCycles uint16
- AverageCycleTime uint32 // µsec
- MaxCycleTime uint32 // µsec
+ AverageCycleTime UT // µsec
+ MaxCycleTime UT // µsec
}
// ID(201) | 04 15 03 00 00