MCPcopy Create free account
hub / github.com/DexterInd/GoPiGo3 / handle_GoPiGo3_msg

Function handle_GoPiGo3_msg

Software/Scratch/GoPiGo3Scratch.py:415–469  ·  view source on GitHub ↗

parses the message dispatches to appropriate method

(msg)

Source from the content-addressed store, hash-verified

413
414
415def handle_GoPiGo3_msg(msg):
416 '''
417 parses the message
418 dispatches to appropriate method
419 '''
420 logger.debug("received {}".format(msg.strip().lower()))
421
422 sensors = {}
423
424 regObj = compiled_regexGPG3.match(msg.strip().lower())
425 if regObj is None:
426 logger.info ("GoPiGo3 command is not recognized")
427 return None
428
429 # for i in range(len(regObj.groups())+1):
430 # logger.debug ("{}: {}".format(i,regObj.group(i)))
431
432 if regObj.group(DRIVE_GROUP):
433 logger.info("go for a drive")
434 sensors = drive_gpg(regObj)
435 # Drive forward/Backward (for X Units)
436
437 elif regObj.group(STOP_GROUP):
438 logger.info('stop')
439 sensors = gpg.stop()
440
441 elif regObj.group(SPEED_GROUP):
442 logger.info ("change speed")
443 set_speed(regObj)
444
445 elif regObj.group(DRIVE_TURN):
446 logger.info('turn')
447 sensors = turn_gpg(regObj)
448
449 elif regObj.group(EYES_GROUP):
450 logger.info("eyes")
451 sensors = handle_eyes(regObj)
452
453 elif regObj.group(EYE_COLOR_GROUP):
454 logger.info("eye color")
455 sensors = handle_eye_color(regObj)
456
457 elif regObj.group(BLINKER_GROUP):
458 logger.info("blinkers")
459 sensors = handle_blinkers(regObj)
460
461 elif regObj.group(RESET_GROUP):
462 logger.info("reset")
463 sensors = GoPiGo3_reset();
464
465 elif regObj.group(ENCODER_GROUP):
466 logger.info("encoders")
467 sensors = handle_encoders(regObj)
468
469 return sensors
470
471
472def handle_GoPiGo3_Sensor_msg(msg):

Callers 1

GoPiGo3Scratch.pyFile · 0.85

Calls 9

drive_gpgFunction · 0.85
set_speedFunction · 0.85
turn_gpgFunction · 0.85
handle_eyesFunction · 0.85
handle_eye_colorFunction · 0.85
handle_blinkersFunction · 0.85
GoPiGo3_resetFunction · 0.85
handle_encodersFunction · 0.85
stopMethod · 0.45

Tested by

no test coverage detected