This repository was archived by the owner on Feb 23, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcommands.go
More file actions
135 lines (127 loc) · 3.95 KB
/
commands.go
File metadata and controls
135 lines (127 loc) · 3.95 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package main
import (
"fmt"
)
type PMCommand byte
type ShortCommand byte
func (cmd ShortCommand) Frame() []byte {
return []byte{
0x01, // USB Shit.
StandardStartFlag, byte(cmd), 0 ^ byte(cmd), StopFlag,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
}
}
func (cmd ShortCommand) String() string {
if name, ok := commandName[byte(cmd)]; ok {
return name
} else {
return fmt.Sprintf("ShortCommand[% 2x]", byte(cmd))
}
}
// Standard CSAFE short commands
const (
CmdGetStatus ShortCommand = 0x80
CmdReset ShortCommand = 0x81
CmdGoIdle ShortCommand = 0x82
CmdGoHaveID ShortCommand = 0x83
CmdGoInUse ShortCommand = 0x85
CmdGoFinished ShortCommand = 0x86
CmdGoReady ShortCommand = 0x87
CmdBadID ShortCommand = 0x88
CmdGetVersion ShortCommand = 0x91
CmdGetID ShortCommand = 0x92 // User identifier number.
CmdGetUnits ShortCommand = 0x93
CmdGetSerial ShortCommand = 0x94
CmdGetList ShortCommand = 0x98
CmdGetUtilization ShortCommand = 0x99 // Utilization is the duraction of the current workout.
CmdGetMotorCurrent ShortCommand = 0x9A
CmdGetOdometer ShortCommand = 0x9B
CmdGetErrorCode ShortCommand = 0x9C
CmdGetServiceCode ShortCommand = 0x9D
CmdGetUserCfg1 ShortCommand = 0x9E
CmdGetUserCfg2 ShortCommand = 0x9F
CmdGetTWork ShortCommand = 0xA0
CmdGetHorizontal ShortCommand = 0xA1 // Work distance of workout.
CmdGetVertical ShortCommand = 0xA2
CmdGetCalories ShortCommand = 0xA3 // Accumulated calories burned.
CmdGetProgram ShortCommand = 0xA4
CmdGetSpeed ShortCommand = 0xA5
CmdGetPace ShortCommand = 0xA6 // Time elapsed per unit distance for a given stroke.
CmdGetCadence ShortCommand = 0xA7 // Strokes per minute for per stroke.
CmdGetGrade ShortCommand = 0xA8
CmdGetGear ShortCommand = 0xA9
CmdGetUpList ShortCommand = 0xAA
CmdGetUserInfo ShortCommand = 0xAB
CmdGetTorque ShortCommand = 0xAC
CmdGetHRCur ShortCommand = 0xB0 // Current heart beats per minute.
CmdGetHRTZone ShortCommand = 0xB2
CmdGetMETS ShortCommand = 0xB3
CmdGetPower ShortCommand = 0xB4 // Power generated based on the pace per stroke.
CmdGetHRAvg ShortCommand = 0xB5
CmdGetHRMax ShortCommand = 0xB6
CmdGetUserData1 ShortCommand = 0xBE
CmdGetUserData2 ShortCommand = 0xBF
CmdGetAudioChannel ShortCommand = 0xC0
CmdGetAudioVolume ShortCommand = 0xC1
CmdGetAudioMute ShortCommand = 0xC2
CmdDisplayPopup7 ShortCommand = 0xE1
)
// PM3 Specific commands, see http://pcrower.sourceforge.net/pm3.pdf
// I think these might be long commands.
const (
CmdPMGetWorkoutType PMCommand = 0x89
CmdPMGetWorkTime PMCommand = 0xA0 // Work time duration of workout.
CmdPMGetWorkDistance PMCommand = 0xA3 // Work distance of workout.
CmdPMGetStrokeState PMCommand = 0xBF
CmdPMGetDragFactor PMCommand = 0xC1
)
var (
commandName = map[byte]string{
0x80: "GetStatus",
0x81: "Reset",
0x82: "GoIdle",
0x83: "GoHaveID",
0x85: "GoInUse",
0x86: "GoFinished",
0x87: "GoReady",
0x88: "BadID",
0x91: "GetVersion",
0x92: "GetID",
0x93: "GetUnits",
0x94: "GetSerial",
0x98: "GetList",
0x99: "GetUtilization",
0x9A: "GetMotorCurrent",
0x9B: "GetOdometer",
0x9C: "GetErrorCode",
0x9D: "GetServiceCode",
0x9E: "GetUserCfg1",
0x9F: "GetUserCfg2",
0xA0: "GetTWork",
0xA1: "GetHorizontal",
0xA2: "GetVertical",
0xA3: "GetCalories",
0xA4: "GetProgram",
0xA5: "GetSpeed",
0xA6: "GetPace",
0xA7: "GetCadence",
0xA8: "GetGrade",
0xA9: "GetGear",
0xAA: "GetUpList",
0xAB: "GetUserInfo",
0xAC: "GetTorque",
0xB0: "GetHRCur",
0xB2: "GetHRTZone",
0xB3: "GetMETS",
0xB4: "GetPower",
0xB5: "GetHRAvg",
0xB6: "GetHRMax",
0xBE: "GetUserData1",
0xBF: "GetUserData2",
0xC0: "GetAudioChannel",
0xC1: "GetAudioVolume",
0xC2: "GetAudioMute",
0xE1: "DisplayPopup7",
}
)