Esempio n. 1
0
  def write_and_read( self, string, repetitions=1, repetition_delay=0, timeout=None ):
    rf_spy = self.serial_rf_spy

    if timeout == None:
      timeout = 0.5

    timeout_ms = int(timeout * 1000)


    log.debug("write_and_read: %s" % str(string).encode('hex'))

    if repetitions > self.MAX_REPETITION_BATCHSIZE:
      raise CommsException("repetition count of %d is greater than max repitition count of %d" % (repetitions, self.MAX_REPETITION_BATCHSIZE))

    crc = CRC8.compute(string)

    listen_channel = self.channel

    cmd_body = chr(self.channel) + chr(repetitions - 1) + chr(repetition_delay) + chr(listen_channel)

    if self.uint16_timeout_width:
      timeout_ms_high = int(timeout_ms / 256)
      timeout_ms_low = int(timeout_ms - (timeout_ms_high * 256))
      cmd_body += chr(timeout_ms_high) + chr(timeout_ms_low)
    else:
      cmd_body += chr(timeout_ms >> 24) + chr((timeout_ms >> 16) & 0xff) + \
        chr((timeout_ms >> 8) & 0xff) + chr(timeout_ms & 0xff)

    retry_count = 0
    cmd_body += chr(retry_count)

    cmd_body += FourBySix.encode(string)

    resp = rf_spy.do_command(rf_spy.CMD_SEND_AND_LISTEN, cmd_body, timeout=(timeout_ms/1000.0 + 1))
    return self.handle_response(resp)['data']
Esempio n. 2
0
 def send_packet(self, data, repetitions=1, repetition_delay=0, timeout=1):
     buf = bytearray()
     buf.extend(data.decode('hex'))
     buf.extend([CRC8.compute(buf)])
     self.link.write(buf,
                     repetitions=repetitions,
                     repetition_delay=repetition_delay,
                     timeout=timeout)
Esempio n. 3
0
  def write( self, string, repetitions=1, repetition_delay=0, timeout=None ):
    rf_spy = self.serial_rf_spy

    remaining_messages = repetitions
    while remaining_messages > 0:
      if remaining_messages < self.MAX_REPETITION_BATCHSIZE:
        transmissions = remaining_messages
      else:
        transmissions = self.MAX_REPETITION_BATCHSIZE
      remaining_messages = remaining_messages - transmissions

      crc = CRC8.compute(string)

      message = chr(self.channel) + chr(transmissions - 1) + chr(repetition_delay) + FourBySix.encode(string)

      rf_spy.do_command(rf_spy.CMD_SEND_PACKET, message, timeout=timeout)
Esempio n. 4
0
    def write(self, string, repetitions=1, repetition_delay=0, timeout=None):
        rf_spy = self.serial_rf_spy

        remaining_messages = repetitions
        while remaining_messages > 0:
            if remaining_messages < self.MAX_REPETITION_BATCHSIZE:
                transmissions = remaining_messages
            else:
                transmissions = self.MAX_REPETITION_BATCHSIZE
            remaining_messages = remaining_messages - transmissions

            crc = CRC8.compute(string)

            message = chr(self.channel) + chr(transmissions - 1) + chr(
                repetition_delay) + FourBySix.encode(string)

            rf_spy.do_command(rf_spy.CMD_SEND_PACKET, message, timeout=timeout)
Esempio n. 5
0
 def send_packet(self, data, tx_count=1, msec_repeat_delay=0):
   buf = bytearray()
   buf.extend(data.decode('hex'))
   buf.extend([CRC8.compute(buf)])
   self.link.write(buf, tx_count, msec_repeat_delay)
Esempio n. 6
0
 def send_packet(self, data, tx_count=1, msec_repeat_delay=0):
     buf = bytearray()
     buf.extend(data.decode('hex'))
     buf.extend([CRC8.compute(buf)])
     self.link.write(buf, tx_count, msec_repeat_delay)
Esempio n. 7
0
 def send_packet(self, data, repetitions=1, repetition_delay=0, timeout=1):
   buf = bytearray()
   buf.extend(data.decode('hex'))
   buf.extend([CRC8.compute(buf)])
   self.link.write(buf, repetitions=repetitions, repetition_delay=repetition_delay, timeout=timeout)