def register_profile(self): """ Register new profile on MCU """ req = line_protocol_pb2.Request() # pylint: disable=no-member req.registration.profile_id = self.profile_id req.registration.r_mcu_driver.SetInParent() controller.send(req.SerializeToString()) logging.info(" Registration sent for Profile: %i", self.profile_id) super().register_wait()
def register_profile(self): """ Register new profile on MCU """ req = line_protocol_pb2.Request() # pylint: disable=no-member req.registration.profile_id = self.profile_id req.registration.r_color_sensor.address = 0 # currently not used controller.send(req.SerializeToString()) logging.info(" Registration sent for Profile: %i", self.profile_id) super().register_wait()
def get_ram(self): """ Action function to get free RAM space """ req = line_protocol_pb2.Request() # pylint: disable=no-member req.action.profile_id = self.profile_id req.action.a_mcu_driver.mcu_action = line_protocol_pb2.RAM self.curr_request = line_protocol_pb2.RAM controller.send(req.SerializeToString()) self.profile_state = ProfileState.BLOCKING super().action_wait()
def get_version(self): """ Action function to get current firmware version """ req = line_protocol_pb2.Request() # pylint: disable=no-member req.action.profile_id = self.profile_id req.action.a_mcu_driver.mcu_action = line_protocol_pb2.VERSION self.curr_request = line_protocol_pb2.VERSION controller.send(req.SerializeToString()) self.profile_state = ProfileState.BLOCKING super().action_wait()
def register_profile(self): """ register new profile on MCU """ req = line_protocol_pb2.Request() # pylint: disable=no-member req.registration.profile_id = self.profile_id req.registration.r_uart_ttl_generic.port = self.port req.registration.r_uart_ttl_generic.baudrate = self.baudrate controller.send(req.SerializeToString()) logging.info(" UART: Registration sent (Profile: %i)", self.profile_id) super().register_wait()
def register_profile(self): """ register new profile on MCU """ req = line_protocol_pb2.Request() # pylint: disable=no-member req.registration.profile_id = self.profile_id req.registration.r_digital_generic.pin = self.pin req.registration.r_digital_generic.mode = self.mode controller.send(req.SerializeToString()) logging.info(" Registration sent for Profile: %i", self.profile_id) super().register_wait()
def set_steps(self, steps, time_min_val, wait): """ Action function for step_motor profiles to set the motor steps """ req = line_protocol_pb2.Request() # pylint: disable=no-member req.action.profile_id = self.profile_id req.action.a_step_motor.steps = steps req.action.a_step_motor.time_min_val = time_min_val req.action.a_step_motor.wait = wait controller.send(req.SerializeToString()) self.profile_state = ProfileState.BLOCKING super().action_wait()
def action_profile(self): """ Action function for ultrasonic_sensor profiles """ req = line_protocol_pb2.Request() # pylint: disable=no-member req.action.profile_id = self.profile_id req.action.a_ultrasonic_sensor.event_triggered = False # not supported controller.send(req.SerializeToString()) logging.info( "Ultrasonic sensor: sent action (Profile: %i)", self.profile_id) self.profile_state = ProfileState.BLOCKING super().action_wait()
def send_command(self, command, event): """ Send command to UART2/3 """ req = line_protocol_pb2.Request() # pylint: disable=no-member req.action.profile_id = self.profile_id req.action.a_uart_ttl_generic.command = command req.action.a_uart_ttl_generic.event_triggered = event controller.send(req.SerializeToString()) logging.info(" UART: Command sent (Profile: %i)", self.profile_id) self.profile_state = ProfileState.BLOCKING super().action_wait()
def read_digital(self): """ Read digital pin """ req = line_protocol_pb2.Request() # pylint: disable=no-member req.action.profile_id = self.profile_id req.action.a_digital_generic.event_triggered = False controller.send(req.SerializeToString()) logging.info( " Digital pin action: Read pin (Profile: %i)", self.profile_id) self.profile_state = ProfileState.BLOCKING super().action_wait() return self.pin_state
def read_event_digital(self, trigger_value): """Start event listening for digital pin. Args: trigger_value (HIGH/LOW): used to set value on which event will be triggered """ req = line_protocol_pb2.Request() # pylint: disable=no-member req.action.profile_id = self.profile_id req.action.a_digital_generic.output = trigger_value req.action.a_digital_generic.event_triggered = True controller.send(req.SerializeToString()) logging.info( " Digital pin action: Start event listening (Profile: %i)", self.profile_id ) self.profile_state = ProfileState.BLOCKING super().action_wait()
def write_digital(self, output): """ Write digital pin to HIGH/LOW """ req = line_protocol_pb2.Request() # pylint: disable=no-member req.action.profile_id = self.profile_id req.action.a_digital_generic.output = output controller.send(req.SerializeToString()) if output == line_protocol_pb2.HIGH: logging.info( " Digital pin action: HIGH sent (Profile: %i)", self.profile_id ) self.pin_state = True # IDEA: do this on receiving ack elif output == line_protocol_pb2.LOW: logging.info( " Digital pin action: LOW sent (Profile: %i)", self.profile_id) self.pin_state = False # IDEA: do this on receiving ack self.profile_state = ProfileState.BLOCKING super().action_wait()