20
20
* THE SOFTWARE.
21
21
*******************************************************************************/
22
22
23
- #include " CaBotHandle.hpp"
23
+ #include " CaBotHandle.hpp" // NOLINT
24
24
25
25
// #define DEBUG 1
26
26
@@ -103,15 +103,15 @@ void Handle::spinOnce()
103
103
need_to_update = true ;
104
104
} else {
105
105
snprintf (
106
- buff, sizeof (buff), " large time jump %lu.%09lu -> %lu.%09lu " ,
106
+ buff, sizeof (buff), " large time jump %u.%09u -> %u.%09u " ,
107
107
prev.sec , prev.nsec , current.sec , current.nsec );
108
108
logwarn (buff);
109
109
}
110
110
111
111
// #ifdef DEBUG
112
112
snprintf (
113
113
buff, sizeof (buff),
114
- " sync,%lu,%lu.%03lu,%lu.%03lu,%lu.%03lu,%ld,%ld,%ld,%ld " , ms,
114
+ " sync,%u,%u.%03u,%u.%03u,%u.%03u,%d,%d,%d,%d " , ms,
115
115
newTime.sec , newTime.nsec / 1000000 , prev.sec , prev.nsec / 1000000 ,
116
116
current.sec , current.nsec / 1000000 , jump, turn_around_time,
117
117
back_time, temp);
@@ -145,11 +145,11 @@ void Handle::subscribe(uint8_t cmd, void (* callback)(const uint8_t))
145
145
146
146
void Handle::logdebug (char * text) {sendCommand (0x02 , text, strlen (text));}
147
147
148
- void Handle::loginfo (char * text) {sendCommand (0x03 , text, strlen (text));}
148
+ void Handle::loginfo (const char * text) {sendCommand (0x03 , text, strlen (text));}
149
149
150
- void Handle::logwarn (char * text) {sendCommand (0x04 , text, strlen (text));}
150
+ void Handle::logwarn (const char * text) {sendCommand (0x04 , text, strlen (text));}
151
151
152
- bool Handle::getParam (char * name, int * out, size_t num, int timeout_ms)
152
+ bool Handle::getParam (const char * name, int * out, size_t num, int timeout_ms)
153
153
{
154
154
sendCommand (0x08 , name, strlen (name));
155
155
uint8_t cmd = 0x08 ;
@@ -341,7 +341,7 @@ size_t Handle::readCommand(uint8_t * expect, uint8_t ** ptr)
341
341
size = (received & 0xFF ) << size_count * 8 ;
342
342
size_count += 1 ;
343
343
if (size_count == DATA_MAX_SIZE_BYTE) {
344
- if (size < 0 || sizeof (buffer) < size) {
344
+ if (sizeof (buffer) < size) {
345
345
state = 0 ;
346
346
return 0 ;
347
347
} else if (size == 0 ) {
@@ -375,7 +375,7 @@ size_t Handle::readCommand(uint8_t * expect, uint8_t ** ptr)
375
375
bool Handle::sendCommand (uint8_t type, uint8_t * data, size_t num)
376
376
{
377
377
static uint8_t buffer[256 + 6 ];
378
- if (num < 0 || 256 < num) {
378
+ if (256 < num) {
379
379
return false ;
380
380
}
381
381
@@ -399,9 +399,9 @@ bool Handle::sendCommand(uint8_t type, uint8_t * data, size_t num)
399
399
return true ;
400
400
}
401
401
402
- bool Handle::sendCommand (uint8_t type, char * data, size_t num)
402
+ bool cabot:: Handle::sendCommand (uint8_t type, const char * data, size_t num)
403
403
{
404
- return sendCommand (type, reinterpret_cast <uint8_t *>(data), num);
404
+ return sendCommand (type, reinterpret_cast <uint8_t *>(const_cast < char *>( data) ), num);
405
405
}
406
406
407
407
uint8_t Handle::checksum (uint8_t * data, size_t num)
0 commit comments