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
105105}
106106
107107template <int MAX_MOTORS> int SmartServoClass<MAX_MOTORS>::ping(uint8_t id) {
108+ timestamps[0 + (id-1) * 6] = millis();
108109 mutex.lock();
110+ timestamps[1 + (id-1) * 6] = millis();
109111 writeCmd(id, OP_PING);
112+ timestamps[2 + (id-1) * 6] = millis();
110113 // TODO: check return
111114 receiveResponse();
115+ timestamps[3 + (id-1) * 6] = millis();
112116 if (_rxLen==6 &&
113117 _rxBuf[0]==0xff &&
114118 _rxBuf[1]==0xf5 &&
115119 _rxBuf[2]==id &&
116120 _rxBuf[3]==2) {
117121
122+ timestamps[4 + (id-1) * 6] = millis();
118123 mutex.unlock();
124+ timestamps[5 + (id-1) * 6] = millis();
119125 return _rxBuf[4];
120126 }
127+ timestamps[4 + (id-1) * 6] = millis();
121128 mutex.unlock();
122129 errors++;
123130 if (onError) onError();
131+ timestamps[5 + (id-1) * 6] = millis();
124132 return -1;
125133}
126134
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+
127147template <int MAX_MOTORS> void SmartServoClass<MAX_MOTORS>::reset(uint8_t id) {
128148 mutex.lock();
129149 writeCmd(id, OP_RESET);
Original file line number Diff line number Diff line change @@ -58,6 +58,8 @@ class SmartServoClass
5858
5959 void reset (uint8_t id);
6060
61+ void printTimestamps ();
62+
6163 void onErrorCb (mbed::Callback<void ()> _onError) {
6264 onError = _onError;
6365 }
@@ -81,6 +83,8 @@ class SmartServoClass
8183 #define BROADCAST 0xFE
8284 #define MAX_POSITION 4000
8385
86+ int timestamps[6 * 6 ] = {0 };
87+
8488 typedef enum {
8589 _NI_MFG_YEAR, // 0 (0x00) Servo factory: year read/write --
8690 _NI_MFG_MONTH, // 1 (0x01) Servo factory: month read/write --
You can’t perform that action at this time.
0 commit comments