@@ -247,7 +247,8 @@ def _read_response(self, dsize):
247
247
raise RPLidarException ('Wrong body size' )
248
248
return data
249
249
250
- def get_info (self ):
250
+ @property
251
+ def info (self ):
251
252
'''Get device information
252
253
253
254
Returns
@@ -258,7 +259,7 @@ def get_info(self):
258
259
self ._send_cmd (GET_INFO_BYTE )
259
260
dsize , is_single , dtype = self ._read_descriptor ()
260
261
if dsize != INFO_LEN :
261
- raise RPLidarException ('Wrong get_info reply length' )
262
+ raise RPLidarException ('Wrong info reply length' )
262
263
if not is_single :
263
264
raise RPLidarException ('Not a single response mode' )
264
265
if dtype != INFO_TYPE :
@@ -274,7 +275,8 @@ def get_info(self):
274
275
}
275
276
return data
276
277
277
- def get_health (self ):
278
+ @proprety
279
+ def health (self ):
278
280
'''Get device health state. When the core system detects some
279
281
potential risk that may cause hardware failure in the future,
280
282
the returned status value will be 'Warning'. But sensor can still work
@@ -292,15 +294,15 @@ def get_health(self):
292
294
self ._send_cmd (GET_HEALTH_BYTE )
293
295
dsize , is_single , dtype = self ._read_descriptor ()
294
296
if dsize != HEALTH_LEN :
295
- raise RPLidarException ('Wrong get_info reply length' )
297
+ raise RPLidarException ('Wrong info reply length' )
296
298
if not is_single :
297
299
raise RPLidarException ('Not a single response mode' )
298
300
if dtype != HEALTH_TYPE :
299
301
raise RPLidarException ('Wrong response data type' )
300
302
raw = self ._read_response (dsize )
301
303
status = _HEALTH_STATUSES [raw [0 ]]
302
304
error_code = (raw [1 ] << 8 ) + raw [2 ]
303
- return status , error_code
305
+ return ( status , error_code )
304
306
305
307
def clear_input (self ):
306
308
'''Clears input buffer by reading all available data'''
@@ -345,13 +347,13 @@ def iter_measurments(self, max_buf_meas=500):
345
347
In millimeter unit. Set to 0 when measurment is invalid.
346
348
'''
347
349
self .start_motor ()
348
- status , error_code = self .get_health ()
350
+ status , error_code = self .health
349
351
self .log ('debug' , 'Health status: %s [%d]' % (status , error_code ))
350
352
if status == _HEALTH_STATUSES [2 ]:
351
353
self .log ('warning' , 'Trying to reset sensor due to the error. '
352
354
'Error code: %d' % (error_code ))
353
355
self .reset ()
354
- status , error_code = self .get_health ()
356
+ status , error_code = self .health
355
357
if status == _HEALTH_STATUSES [2 ]:
356
358
raise RPLidarException ('RPLidar hardware failure. '
357
359
'Error code: %d' % error_code )
@@ -362,7 +364,7 @@ def iter_measurments(self, max_buf_meas=500):
362
364
self ._send_cmd (cmd )
363
365
dsize , is_single , dtype = self ._read_descriptor ()
364
366
if dsize != 5 :
365
- raise RPLidarException ('Wrong get_info reply length' )
367
+ raise RPLidarException ('Wrong info reply length' )
366
368
if is_single :
367
369
raise RPLidarException ('Not a multiple response mode' )
368
370
if dtype != SCAN_TYPE :
0 commit comments