def bind_to_device(adapter): add_table_to_device(adapter, table_dual_rgb_sensor_tag) add_table_to_device(adapter, table_angle_sensor_tag) add_table_to_device(adapter, table_button_tag) add_table_to_device(adapter, table_dc_motor_driver_tag) add_table_to_device(adapter, table_flame_sensor_tag) add_table_to_device(adapter, table_gas_sensor_tag) add_table_to_device(adapter, table_humiture_sensor_tag) add_table_to_device(adapter, table_ir_transceiver_tag) add_table_to_device(adapter, table_joystick_tag) add_table_to_device(adapter, table_led_panel_tag) add_table_to_device(adapter, table_led_strip_tag) add_table_to_device(adapter, table_light_sensor_tag) add_table_to_device(adapter, table_magnetic_sensor_tag) add_table_to_device(adapter, table_motion_sensor_tag) add_table_to_device(adapter, table_multi_touch_tag) add_table_to_device(adapter, table_pir_sensor_tag) add_table_to_device(adapter, table_ranging_sensor_tag) add_table_to_device(adapter, table_rgb_led_tag) add_table_to_device(adapter, table_servo_driver_tag) add_table_to_device(adapter, table_slider_tag) add_table_to_device(adapter, table_smartservo_tag) add_table_to_device(adapter, table_smart_camera_tag) add_table_to_device(adapter, table_soil_moisture_sensor_tag) add_table_to_device(adapter, table_sound_sensor_tag) add_table_to_device(adapter, table_speaker_tag) add_table_to_device(adapter, table_temp_sensor_tag) add_table_to_device(adapter, table_ultrasonic_sensor_tag) adapter.link_obj.write( create_frame( create_package("mbuild.dual_rgb_sensor.__REPORT_TIME = 50", 0x00, 0x04)))
def start(self): start_heart_package = True port_device = link.p_link.get_available_port()[0] if not port_device.is_open(): self.link_obj = link.commu_uart.uart_link(["COM0", 115200]) self.link_obj.config([self.port, str(self.bauadrate)]) self.link_obj.open() self.link_obj.start_listening() port_device.status = 1 port_device.link_obj = self.link_obj start_heart_package = True else: start_heart_package = False self.link_obj = port_device.link_obj self.protocol_obj = engine.F0F7.protocol.F0F7_frame() self.process = engine.F0F7.process.neurons_process_c() self.protocol_obj.register_frame_process(self.process) self.link_obj.rigister_protocol_parse_handle(self.protocol_obj) engine.F0F7.neurons_engine.neuron_request_bind_phy( self.protocol_obj.send_protocol) self.process.start_engine(start_heart_package) # if mbuild modules are connected to halo, then set halo passthrough mode # even halo not available, send these commands either self.link_obj.write( create_frame(create_package("import communication", 0x00, 0x04))) time.sleep(0.1) self.link_obj.write( create_frame( create_package("halo.led.show_all(10,10,0)", 0x00, 0x04))) time.sleep(0.1) self.link_obj.write( create_frame( create_package( "communication.bind_passthrough_channels(\"uart0\", \"uart1\")", 0x00, 0x04)))
def send_sys_cmd(self, script): if self.protocol: print(create_package(script, 0x00, 0x03)) self.protocol.send_protocol(create_package(script, 0x00, 0x03))
def create_subcribe_frame(self, cell_item, para): key = cell_item['obj'].get_key_by_para(para) func_script = cell_item['obj'].func # para = str(cell_item['obj'].paras) return create_package("subscribe.add_item('%s', %s, %s)" % (key, func_script, para))
def create_frame(sllf, cell_item): func_script = cell_item['obj'].func para = str(cell_item['obj'].paras) return create_package(func_script + para)