Esempio n. 1
0
def cleanup(sig, frame):
  cmd = Command()
  emFile.mode = EngineeringModeMode.ENGINEERING_MODE_MODE_OFF
  cmd.add_action(
    RegularAction(
      operation=WriteFileData(
        operand=Data(
          offset=Offset(id=emFile.id),
          data=list(emFile)
        )
      )
    )
  )
  modem.execute_command(cmd)
  sys.exit(0)
Esempio n. 2
0
configure_default_logger(config.verbose)

modem = Modem(config.device,
              config.rate,
              unsolicited_response_received_callback=received_command_callback)
modem.connect()

# command to be executed as an action: first do an arithmetic comparison of the sensor value with the supplied value...
query_sensor_file_cmd = Command(generate_tag_request_action=False)
query_sensor_file_cmd.add_action(
    RegularAction(operation=BreakQuery(operand=QueryOperand(
        type=QueryType.ARITH_COMP_WITH_VALUE,
        mask_present=False,
        params=ArithQueryParams(signed_data_type=False,
                                comp_type=ArithComparisonType.GREATER_THAN),
        compare_length=Length(2),
        compare_value=[
            ord(b) for b in struct.pack(">H", int(config.temperature * 10))
        ],
        file_a_offset=Offset(id=0x40, offset=Length(0))))))

# ...if the query succeeds, read the file
query_sensor_file_cmd.add_action(
    RegularAction(operation=ReadFileData(
        operand=DataRequest(offset=Offset(id=0x40), length=Length(2)))))

# the interface config to send the result of above action to
interface_config = InterfaceConfiguration(
    InterfaceType.D7ASP,
    Configuration(qos=QoS(resp_mod=ResponseMode.RESP_MODE_NO,
Esempio n. 3
0
        )
      )
    )

  if (config.factory_gaussian != 0xFF) or (config.factory_paramp != 0xFF):
    if (config.factory_gaussian != 0xFF) or (config.factory_paramp != 0xFF):
      fact = FactorySettingsFile(gaussian=config.factory_gaussian, paramp=config.factory_paramp)
    elif config.factory_gaussian != 0xFF:
      fact = FactorySettingsFile(gaussian=config.factory_gaussian)
    else:
      fact = FactorySettingsFile(paramp=config.factory_paramp)
    cmd.add_action(
      RegularAction(
        operation=WriteFileData(
          operand=Data(
            offset=Offset(id=fact.id),
            data=list(fact)
          )
        )
      )
    )

  cmd.add_action(
    RegularAction(
      operation=WriteFileData(
        operand=Data(
          offset=Offset(id=emFile.id),
          data=list(emFile)
        )
      )
    )
  )
Esempio n. 4
0
print(data)

cmd = Command.create_with_write_file_action(file_id=199, data=data)
answ = modem.execute_command(cmd)
cmd = Command()

f = open(config.file, "rb")
total_length = os.path.getsize(config.file)

amount_of_bytes = 239
length = 0
try:
    bytes = list(bytearray(f.read(amount_of_bytes)))
    while len(bytes) != 0:
        cmd.add_action(
            RegularAction(operation=WriteFileData(operand=Data(
                offset=Offset(id=200, offset=Length(length)), data=bytes))))
        length += amount_of_bytes

        answ = modem.execute_command(cmd)
        worked = False
        for answer in answ:
            if answer.execution_completed and not answer.completed_with_error:
                worked = True
        if not worked:
            print("write failed")
            break
        cmd = Command()
        print(
            chr(27) + "[2J\n" + str(length) + "/" + str(total_length) + ": " +
            str(length * 100 / total_length) + "%")