def a_qr_str(self, cod_categoria=None, con_dnis=True): """Devuelve la informacion del recuento para almacenar en qr.""" # tipo de qr # cod_mesa encoded_data = string_to_array(self.a_tag(cod_categoria, con_dnis)) datos = [int(TOKEN, 16), len(encoded_data) * 2] datos.extend(encoded_data) todo = "R" + array_to_printable_string(datos) return todo
def _streams_iter(): """Iterador que va devolviendo en cada pedido la respuesta al comando. construyo las respuestas con las mismas estructuras que uso para parsear cosa de que si machea con lo que nos van a mandar en el ARM lo vamos a saber parsear. """ yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_PWR, msg_type=MSG_RESPONSE, size=8, command=CMD_PWR_SOURCE, data="\x01" )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_PWR, size=10, msg_type=MSG_RESPONSE, command=CMD_PWR_CONNECTED, data="\x02\x01\x00" )) status_batt = struct_batt_get_status.build(Container( batt_number=2, batt_data=[ Container(slot_number=1, tension=65535, corriente=-32768, temp=-273.15, remaining=65535, full_charge=65535, ciclos=65535 ), Container(slot_number=2, tension=100, corriente=32767, temp=273.15, remaining=10, full_charge=65535, ciclos=5 ) ] )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_PWR, msg_type=MSG_RESPONSE, size=38, command=CMD_PWR_GET_STATUS, data=status_batt )) params_batt = struct_batt_params.build(Container( batt_number=1, batt_data=[ Container(slot_number=1, design_capacity=65535, manufacturer=string_to_array("abcdefghijk"), serial_number=256, model=string_to_array("abcdefg"), chem=string_to_array("abdc"), date_manuf=12345, nominal_tension=65535 ) ] )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_PWR, msg_type=MSG_RESPONSE, size=39, command=CMD_PWR_PARAMS, data=params_batt )) params_pwr_check = struct_power_check.build(Container( v_24=-25.5, v_12=-25.5, v_5=-25.5, v_3=-25.5, ) ) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_PWR, msg_type=MSG_RESPONSE, size=23, command=CMD_PWR_CHECK, data=params_pwr_check )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_PWR, msg_type=MSG_RESPONSE, size=8, command=CMD_PWR_SOURCE_CONTROL_MODE, data="\x01" )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_PWR, msg_type=MSG_RESPONSE, size=8, command=CMD_PWR_SOURCE_CONTROL, data="\x01" )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_PWR, msg_type=MSG_RESPONSE, size=7, data='', command=EVT_PWR_DISCHARGE )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_PWR, msg_type=MSG_RESPONSE, size=8, command=EVT_PWR_LVL_MIN, data="\x01" )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_PWR, msg_type=MSG_RESPONSE, size=8, command=EVT_PWR_LVL_CRI, data="\x01" )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_PWR, msg_type=MSG_RESPONSE, size=8, command=EVT_PWR_LVL_MAX, data="\x01" )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_PWR, msg_type=MSG_RESPONSE, size=7, command=EVT_PWR_SWITCH_AC, data="" )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_PWR, msg_type=MSG_RESPONSE, size=8, command=EVT_PWR_UNPLUGGED, data="\x01" )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_PWR, msg_type=MSG_RESPONSE, size=8, command=EVT_PWR_EMPTY, data="\x01" )) printer_status = struct_printer_get_status.build(Container( paper_out_1=1, paper_out_2=1, lever_open=0 )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_PRINTER, msg_type=MSG_RESPONSE, size=10, command=CMD_PRINTER_GET_STATUS, data=printer_status )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_PRINTER, msg_type=MSG_RESPONSE, size=7, command=CMD_PRINTER_MOVE, data="" )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_PRINTER, msg_type=MSG_RESPONSE, size=9, command=CMD_PRINTER_LOAD_BUFFER, data="\x01\xFF" )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_PRINTER, msg_type=MSG_RESPONSE, size=7, command=CMD_PRINTER_PRINT, data="" )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_PRINTER, msg_type=MSG_RESPONSE, size=7, command=CMD_PRINTER_CLEAR_BUFFER, data="" )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_PRINTER, msg_type=MSG_RESPONSE, size=7, command=CMD_PRINTER_PAPER_REMOVE, data="" )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_PRINTER, msg_type=MSG_RESPONSE, size=7, command=CMD_PRINTER_PAPER_START, data="" )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_PRINTER, msg_type=MSG_RESPONSE, size=9, command=CMD_PRINTER_GET_AUTOFEED, data="\x00\xFF" )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_PRINTER, msg_type=MSG_RESPONSE, size=7, command=CMD_PRINTER_SET_AUTOFEED, data="" )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_PRINTER, msg_type=MSG_RESPONSE, size=10, command=EVT_PRINTER_PAPER_INSERTED, data="\x01\x01\x01" )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_PRINTER, msg_type=MSG_RESPONSE, size=10, command=EVT_PRINTER_PAPER_OUT_1, data="\x01\x01\x01" )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_PRINTER, msg_type=MSG_RESPONSE, size=10, command=EVT_PRINTER_PAPER_OUT_2, data="\x01\x01\x01" )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_PRINTER, msg_type=MSG_RESPONSE, size=10, command=EVT_PRINTER_LEVER_OPEN, data="\x01\x01\x01" )) tags = struct_tags_list.build( Container(number=2, serial_number=[ string_to_array("\x00\x01\x02\x03\x04\x05\x06\x07"), string_to_array("\x00\x01\x02\x03\x04\x05\x06\x07"), ] ) ) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_RFID, msg_type=MSG_RESPONSE, size=24, command=CMD_RFID_GET_TAGS, data=tags )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_RFID, msg_type=MSG_RESPONSE, size=7, command=CMD_RFID_SELECT_TAG, data="" )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_RFID, msg_type=MSG_RESPONSE, size=11, command=CMD_RFID_READ_BLOCK, data="\x00\x01\x02\x03" )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_RFID, msg_type=MSG_RESPONSE, size=23, command=CMD_RFID_READ_BLOCKS, data="\x00\x01\x02\x03\x00\x01\x02\x03\x00\x01\x02\x03\x00\x01\x02\x03" )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_RFID, msg_type=MSG_RESPONSE, size=7, command=CMD_RFID_WRITE_BLOCK, data="" )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_RFID, msg_type=MSG_RESPONSE, size=7, command=CMD_RFID_WRITE_BLOCKS, data="" )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_RFID, msg_type=MSG_RESPONSE, size=11, command=CMD_RFID_IS_READONLY, data="\x01\x00\x01\x01" )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_RFID, msg_type=MSG_RESPONSE, size=7, command=CMD_RFID_SET_RO_BLOCK, data="" )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_RFID, msg_type=MSG_RESPONSE, size=7, command=CMD_RFID_SET_RO_BLOCKS, data="" )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_RFID, msg_type=MSG_RESPONSE, size=7, command=CMD_RFID_CLEAR_BUFFER, data="" )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_RFID, msg_type=MSG_RESPONSE, size=8, command=CMD_RFID_GET_ANTENNA_LVL, data="\xFF" )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_RFID, msg_type=MSG_RESPONSE, size=7, command=CMD_RFID_SET_ANTENNA_LVL, data="" )) # yield struct_common.build(Container(version=PROTOCOL_VERSION_1, # device=DEV_RFID, # msg_type=MSG_RESPONSE, # size=7, # command=CMD_RFID_SET_PWR_LED, # data="" # )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_RFID, msg_type=MSG_RESPONSE, size=24, command=EVT_RFID_NEW_TAG, data=tags )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_BACKLIGHT, msg_type=MSG_RESPONSE, size=8, command=CMD_BACKLIGHT_GET_BRIGHTNESS, data="\x16" )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_BACKLIGHT, msg_type=MSG_RESPONSE, size=7, command=CMD_BACKLIGHT_SET_BRIGHTNESS, data="" )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_BACKLIGHT, msg_type=MSG_RESPONSE, size=8, command=CMD_BACKLIGHT_GET_STATUS, data="\xFF" )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_BACKLIGHT, msg_type=MSG_RESPONSE, size=7, command=CMD_BACKLIGHT_SET_STATUS, data="" )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_FAN_COOLERS, msg_type=MSG_RESPONSE, size=8, command=CMD_FAN_COOLERS_GET_SPEED, data="\x25" )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_FAN_COOLERS, msg_type=MSG_RESPONSE, size=7, command=CMD_FAN_COOLERS_SET_SPEED, data="" )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_PIR, msg_type=MSG_RESPONSE, size=7, command=EVT_PIR_DETECTED, data="" )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_PIR, msg_type=MSG_RESPONSE, size=7, command=EVT_PIR_NOT_DETECTED, data="" )) yield struct_common.build(Container(version=PROTOCOL_VERSION_1, device=DEV_BUZZER, msg_type=MSG_RESPONSE, size=7, command=CMD_BUZZER_BUZZ, data="" ))
def _streams_iter(): """Iterador que va devolviendo en cada pedido la respuesta al comando. construyo las respuestas con las mismas estructuras que uso para parsear cosa de que si machea con lo que nos van a mandar en el ARM lo vamos a saber parsear. """ yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_PWR, msg_type=MSG_RESPONSE, size=8, command=CMD_PWR_SOURCE, data="\x01")) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_PWR, size=10, msg_type=MSG_RESPONSE, command=CMD_PWR_CONNECTED, data="\x02\x01\x00")) status_batt = struct_batt_get_status.build( Container(batt_number=2, batt_data=[ Container(slot_number=1, tension=65535, corriente=-32768, temp=-273.15, remaining=65535, full_charge=65535, ciclos=65535), Container(slot_number=2, tension=100, corriente=32767, temp=273.15, remaining=10, full_charge=65535, ciclos=5) ])) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_PWR, msg_type=MSG_RESPONSE, size=38, command=CMD_PWR_GET_STATUS, data=status_batt)) params_batt = struct_batt_params.build( Container(batt_number=1, batt_data=[ Container(slot_number=1, design_capacity=65535, manufacturer=string_to_array("abcdefghijk"), serial_number=256, model=string_to_array("abcdefg"), chem=string_to_array("abdc"), date_manuf=12345, nominal_tension=65535) ])) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_PWR, msg_type=MSG_RESPONSE, size=39, command=CMD_PWR_PARAMS, data=params_batt)) params_pwr_check = struct_power_check.build( Container( v_24=-25.5, v_12=-25.5, v_5=-25.5, v_3=-25.5, )) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_PWR, msg_type=MSG_RESPONSE, size=23, command=CMD_PWR_CHECK, data=params_pwr_check)) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_PWR, msg_type=MSG_RESPONSE, size=8, command=CMD_PWR_SOURCE_CONTROL_MODE, data="\x01")) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_PWR, msg_type=MSG_RESPONSE, size=8, command=CMD_PWR_SOURCE_CONTROL, data="\x01")) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_PWR, msg_type=MSG_RESPONSE, size=7, data='', command=EVT_PWR_DISCHARGE)) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_PWR, msg_type=MSG_RESPONSE, size=8, command=EVT_PWR_LVL_MIN, data="\x01")) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_PWR, msg_type=MSG_RESPONSE, size=8, command=EVT_PWR_LVL_CRI, data="\x01")) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_PWR, msg_type=MSG_RESPONSE, size=8, command=EVT_PWR_LVL_MAX, data="\x01")) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_PWR, msg_type=MSG_RESPONSE, size=7, command=EVT_PWR_SWITCH_AC, data="")) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_PWR, msg_type=MSG_RESPONSE, size=8, command=EVT_PWR_UNPLUGGED, data="\x01")) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_PWR, msg_type=MSG_RESPONSE, size=8, command=EVT_PWR_EMPTY, data="\x01")) printer_status = struct_printer_get_status.build( Container(paper_out_1=1, paper_out_2=1, lever_open=0)) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_PRINTER, msg_type=MSG_RESPONSE, size=10, command=CMD_PRINTER_GET_STATUS, data=printer_status)) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_PRINTER, msg_type=MSG_RESPONSE, size=7, command=CMD_PRINTER_MOVE, data="")) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_PRINTER, msg_type=MSG_RESPONSE, size=9, command=CMD_PRINTER_LOAD_BUFFER, data="\x01\xFF")) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_PRINTER, msg_type=MSG_RESPONSE, size=7, command=CMD_PRINTER_PRINT, data="")) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_PRINTER, msg_type=MSG_RESPONSE, size=7, command=CMD_PRINTER_CLEAR_BUFFER, data="")) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_PRINTER, msg_type=MSG_RESPONSE, size=7, command=CMD_PRINTER_PAPER_REMOVE, data="")) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_PRINTER, msg_type=MSG_RESPONSE, size=7, command=CMD_PRINTER_PAPER_START, data="")) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_PRINTER, msg_type=MSG_RESPONSE, size=9, command=CMD_PRINTER_GET_AUTOFEED, data="\x00\xFF")) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_PRINTER, msg_type=MSG_RESPONSE, size=7, command=CMD_PRINTER_SET_AUTOFEED, data="")) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_PRINTER, msg_type=MSG_RESPONSE, size=10, command=EVT_PRINTER_PAPER_INSERTED, data="\x01\x01\x01")) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_PRINTER, msg_type=MSG_RESPONSE, size=10, command=EVT_PRINTER_PAPER_OUT_1, data="\x01\x01\x01")) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_PRINTER, msg_type=MSG_RESPONSE, size=10, command=EVT_PRINTER_PAPER_OUT_2, data="\x01\x01\x01")) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_PRINTER, msg_type=MSG_RESPONSE, size=10, command=EVT_PRINTER_LEVER_OPEN, data="\x01\x01\x01")) tags = struct_tags_list.build( Container(number=2, serial_number=[ string_to_array("\x00\x01\x02\x03\x04\x05\x06\x07"), string_to_array("\x00\x01\x02\x03\x04\x05\x06\x07"), ])) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_RFID, msg_type=MSG_RESPONSE, size=24, command=CMD_RFID_GET_TAGS, data=tags)) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_RFID, msg_type=MSG_RESPONSE, size=7, command=CMD_RFID_SELECT_TAG, data="")) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_RFID, msg_type=MSG_RESPONSE, size=11, command=CMD_RFID_READ_BLOCK, data="\x00\x01\x02\x03")) yield struct_common.build( Container( version=PROTOCOL_VERSION_1, device=DEV_RFID, msg_type=MSG_RESPONSE, size=23, command=CMD_RFID_READ_BLOCKS, data= "\x00\x01\x02\x03\x00\x01\x02\x03\x00\x01\x02\x03\x00\x01\x02\x03") ) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_RFID, msg_type=MSG_RESPONSE, size=7, command=CMD_RFID_WRITE_BLOCK, data="")) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_RFID, msg_type=MSG_RESPONSE, size=7, command=CMD_RFID_WRITE_BLOCKS, data="")) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_RFID, msg_type=MSG_RESPONSE, size=11, command=CMD_RFID_IS_READONLY, data="\x01\x00\x01\x01")) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_RFID, msg_type=MSG_RESPONSE, size=7, command=CMD_RFID_SET_RO_BLOCK, data="")) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_RFID, msg_type=MSG_RESPONSE, size=7, command=CMD_RFID_SET_RO_BLOCKS, data="")) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_RFID, msg_type=MSG_RESPONSE, size=7, command=CMD_RFID_CLEAR_BUFFER, data="")) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_RFID, msg_type=MSG_RESPONSE, size=8, command=CMD_RFID_GET_ANTENNA_LVL, data="\xFF")) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_RFID, msg_type=MSG_RESPONSE, size=7, command=CMD_RFID_SET_ANTENNA_LVL, data="")) # yield struct_common.build(Container(version=PROTOCOL_VERSION_1, # device=DEV_RFID, # msg_type=MSG_RESPONSE, # size=7, # command=CMD_RFID_SET_PWR_LED, # data="" # )) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_RFID, msg_type=MSG_RESPONSE, size=24, command=EVT_RFID_NEW_TAG, data=tags)) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_BACKLIGHT, msg_type=MSG_RESPONSE, size=8, command=CMD_BACKLIGHT_GET_BRIGHTNESS, data="\x16")) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_BACKLIGHT, msg_type=MSG_RESPONSE, size=7, command=CMD_BACKLIGHT_SET_BRIGHTNESS, data="")) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_BACKLIGHT, msg_type=MSG_RESPONSE, size=8, command=CMD_BACKLIGHT_GET_STATUS, data="\xFF")) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_BACKLIGHT, msg_type=MSG_RESPONSE, size=7, command=CMD_BACKLIGHT_SET_STATUS, data="")) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_FAN_COOLERS, msg_type=MSG_RESPONSE, size=8, command=CMD_FAN_COOLERS_GET_SPEED, data="\x25")) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_FAN_COOLERS, msg_type=MSG_RESPONSE, size=7, command=CMD_FAN_COOLERS_SET_SPEED, data="")) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_PIR, msg_type=MSG_RESPONSE, size=7, command=EVT_PIR_DETECTED, data="")) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_PIR, msg_type=MSG_RESPONSE, size=7, command=EVT_PIR_NOT_DETECTED, data="")) yield struct_common.build( Container(version=PROTOCOL_VERSION_1, device=DEV_BUZZER, msg_type=MSG_RESPONSE, size=7, command=CMD_BUZZER_BUZZ, data=""))