File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -105,25 +105,45 @@ template <int MAX_MOTORS> int SmartServoClass<MAX_MOTORS>::readByteCmd(uint8_t i
105
105
}
106
106
107
107
template <int MAX_MOTORS> int SmartServoClass<MAX_MOTORS>::ping(uint8_t id) {
108
+ timestamps[0 + (id-1) * 6] = millis();
108
109
mutex.lock();
110
+ timestamps[1 + (id-1) * 6] = millis();
109
111
writeCmd(id, OP_PING);
112
+ timestamps[2 + (id-1) * 6] = millis();
110
113
// TODO: check return
111
114
receiveResponse();
115
+ timestamps[3 + (id-1) * 6] = millis();
112
116
if (_rxLen==6 &&
113
117
_rxBuf[0]==0xff &&
114
118
_rxBuf[1]==0xf5 &&
115
119
_rxBuf[2]==id &&
116
120
_rxBuf[3]==2) {
117
121
122
+ timestamps[4 + (id-1) * 6] = millis();
118
123
mutex.unlock();
124
+ timestamps[5 + (id-1) * 6] = millis();
119
125
return _rxBuf[4];
120
126
}
127
+ timestamps[4 + (id-1) * 6] = millis();
121
128
mutex.unlock();
122
129
errors++;
123
130
if (onError) onError();
131
+ timestamps[5 + (id-1) * 6] = millis();
124
132
return -1;
125
133
}
126
134
135
+ template <int MAX_MOTORS> void SmartServoClass<MAX_MOTORS>::printTimestamps() {
136
+ Serial.print("\n-> ");
137
+ for (int i = 0; i<6; i++) {
138
+ for (int j = 0; j<6; j++) {
139
+ Serial.print(timestamps[6*i + j]);
140
+ Serial.print( " " );
141
+ }
142
+ Serial.println("");
143
+ }
144
+ }
145
+
146
+
127
147
template <int MAX_MOTORS> void SmartServoClass<MAX_MOTORS>::reset(uint8_t id) {
128
148
mutex.lock();
129
149
writeCmd(id, OP_RESET);
Original file line number Diff line number Diff line change @@ -58,6 +58,8 @@ class SmartServoClass
58
58
59
59
void reset (uint8_t id);
60
60
61
+ void printTimestamps ();
62
+
61
63
void onErrorCb (mbed::Callback<void ()> _onError) {
62
64
onError = _onError;
63
65
}
@@ -81,6 +83,8 @@ class SmartServoClass
81
83
#define BROADCAST 0xFE
82
84
#define MAX_POSITION 4000
83
85
86
+ int timestamps[6 * 6 ] = {0 };
87
+
84
88
typedef enum {
85
89
_NI_MFG_YEAR, // 0 (0x00) Servo factory: year read/write --
86
90
_NI_MFG_MONTH, // 1 (0x01) Servo factory: month read/write --
You can’t perform that action at this time.
0 commit comments