Beispiel #1
0
  def readStatus(self):
    """
    result = False
    def fetch_status( ):
      res = self.link.sendComLink2Command(3)
      status = res[0] # 0 indicates success
      if status == 0:
        result = res
        return True
      return False
      
    if not retry(fetch_status) or not result or len(result) == 0:
      raise RFFailed("rf read header indicates failure")
    """
    result         = self.link.sendComLink2Command(3)
    commStatus     = result[0] # 0 indicates success
    
    status         = result[2]
    lb, hb         = result[3], result[4]

    stat = StickStatusStruct(status)
    header = result[0:3]
    test = [ StickStatusStruct(s) for s in header ]
    log.info(test)
    log.info("HEADER:\n%s" % lib.hexdump(header))
    if 0 != commStatus:
      raise DeviceCommsError('\n'.join([ "rf read header indicates failure"
                                       , "%s" % lib.hexdump(header) ]))
    assert commStatus == 0, ("command status not 0: %s:%s" % (commStatus, stat))
    bytesAvailable = lib.BangInt((lb, hb))
    self.status    = status

    if (status & 0x1) > 0:
      return bytesAvailable
    return 0
Beispiel #2
0
 def decode( self, msg ):
   data = bytearray( msg[ 3: len(msg) - 3 ] )
   date = time.ctime( ls_long( data[ 2:6 ] ) )
   io.info( 'relevant message: %s' % lib.hexdump( data ) )
   io.info( 'glucose: %s' % lib.hexdump( data[ 6:10 ] ) )
   glucose = ls_long( data[ 6:10 ] )
   return ( date, glucose )
Beispiel #3
0
def loopingRead(carelink):
    for x in itertools.count():
        print '######### BEGIN LOOP ###########'
        print 'loop:%s' % x
        length = getBytesAvailable(carelink)
        print 'found length %s' % length
        response = readBytes(carelink, length)
        print lib.hexdump(response)
        print "Read a total of %s bytes / %s requested" % (len(response),
                                                           length)
        if len(response) < length:
            remaining = length - len(response)
            print "Response was less than requested... "
            print "trying the remainder: %s" % remaining
            response = readBytes(carelink, remaining + (remaining % 64))
        pprint(carelink(USBStatus()).info)
        print 'finishing loop:%s' % x
        print '######### STATS ###########'
        print 'signal strength: %sdBm' % \
               carelink( USBSignalStrength( ) ).info
        pprint(carelink(RadioInterfaceStats()).info)
        pprint(carelink(USBInterfaceStats()).info)
        pprint(carelink(USBProductInfo()).info)
        pprint(carelink(USBStatus()).info)
        print
Beispiel #4
0
def send_command(port, comm):
    log.info("sending:")
    log.info(lib.hexdump(bytearray(comm)))
    port.write(str(comm))
    time.sleep(1)
    response = ''.join(port.readlines())
    if len(response) > 0:
        print "RESPONSE!!!!"
        print lib.hexdump(bytearray(response))
    return response
Beispiel #5
0
def send_command(port, comm):
  log.info("sending:")
  log.info(lib.hexdump(bytearray(comm)))
  port.write(str(comm))
  time.sleep(1)
  response = ''.join(port.readlines( ))
  if len(response) > 0:
    print "RESPONSE!!!!"
    print lib.hexdump(bytearray(response))
  return response
Beispiel #6
0
def debug_response(response):
    header, body = response[:14], response[14:14 + response[13]]
    print "HEADER"
    print "readable 1 == %s" % header[0]
    print "success (U) fail (f) == %s (%s)" % (chr(header[1]), header[1])
    print "error code 0 == %s" % header[2]
    print "message length: %s" % header[13]
    print lib.hexdump(header)
    print "msg"
    print lib.hexdump(body)
    print "msg: %s" % (str(body))
Beispiel #7
0
def debug_response( response ):
  header, body = response[ :14 ], response[ 14 : 14+response[13] ]
  print "HEADER"
  print "readable 1 == %s" % header[ 0 ]
  print "success (U) fail (f) == %s (%s)" % ( chr( header[ 1 ] ),
                                                   header[ 1 ] )
  print "error code 0 == %s" % header[ 2 ]
  print "message length: %s" % header[ 13 ]
  print lib.hexdump( header )
  print "msg"
  print lib.hexdump( body )
  print "msg: %s" % ( str( body ) )
Beispiel #8
0
  def getData(self):
    data = self.data
    log.info("READ pump settings:\n%s" % lib.hexdump(data))
    

    auto_off_duration_hrs = data[0]
    alarm = self.alarm(data[1])
    audio_bolus_enable = data[2] == 1
    audio_bolus_size = 0
    if audio_bolus_enable:
      audio_bolus_size = data[3] / 10.0
    variable_bolus_enable = data[4] == 1  
    #MM23 is different
    maxBolus = data[5]/ 10.0
    # MM512 and up
    maxBasal = lib.BangInt(data[6:8]) / 40
    timeformat = data[8]
    insulinConcentration = {0: 100, 1: 50}[data[9]]
    patterns_enabled = data[10] == 1
    selected_pattern = data[11]
    rf_enable = data[12] == 1
    block_enable = data[13] == 1
    """
    # MM12
    insulin_action_type = data[17] == 0 and 'Fast' or 'Regular'
    """
    #MM15
    insulin_action_type = data[17]
    low_reservoir_warn_type = data[18]
    low_reservoir_warn_point = data[19]
    keypad_lock_status = data[20]

    return locals( )
Beispiel #9
0
    def readData(self):
        bytesAvailable = self.getNumBytesAvailable()
        packet = [
            12, 0,
            lib.HighByte(bytesAvailable),
            lib.LowByte(bytesAvailable)
        ]
        packet.append(CRC8(packet))

        response = self.writeAndRead(packet, bytesAvailable)
        # assert response.length > 14
        # assert (int(response[0]) == 2), repr(response)

        rcode = response[0]
        if len(response) < 14:
            raise DeviceCommsError('\n'.join(
                ["readData: insufficientData",
                 lib.hexdump(response)]))

        if rcode != 2:
            raise DeviceCommsError("readData: bad response code: %#04x" %
                                   rcode)
        # response[1] != 0 # interface number !=0
        # response[2] == 5 # timeout occurred
        # response[2] == 2 # NAK
        # response[2] # should be within 0..4
        log.info("readData ACK")
        return response
Beispiel #10
0
    def getData(self):
        data = self.data
        log.info("READ pump settings:\n%s" % lib.hexdump(data))

        auto_off_duration_hrs = data[0]
        alarm = self.alarm(data[1])
        audio_bolus_enable = data[2] == 1
        audio_bolus_size = 0
        if audio_bolus_enable:
            audio_bolus_size = data[3] / 10.0
        variable_bolus_enable = data[4] == 1
        #MM23 is different
        maxBolus = data[5] / 10.0
        # MM512 and up
        maxBasal = lib.BangInt(data[6:8]) / 40
        timeformat = data[8]
        insulinConcentration = {0: 100, 1: 50}[data[9]]
        patterns_enabled = data[10] == 1
        selected_pattern = data[11]
        rf_enable = data[12] == 1
        block_enable = data[13] == 1
        """
    # MM12
    insulin_action_type = data[17] == 0 and 'Fast' or 'Regular'
    """
        #MM15
        insulin_action_type = data[17]
        low_reservoir_warn_type = data[18]
        low_reservoir_warn_point = data[19]
        keypad_lock_status = data[20]

        return locals()
Beispiel #11
0
 def stage2_wakeup(self):
     stage2a = [0x80, 0x25, 0x00, 0x00, 0x00, 0x00, 0x07]
     stage2b = [0x80, 0x25, 0x00, 0x00, 0x00, 0x00, 0x08]
     stage2c = [0x11, 0x0D, 0x44, 0x4D, 0x53, 0x0D, 0x0D]
     stage2d = [0x11, 0x0D, 0x44, 0x4D, 0x53, 0x0D, 0x0D]
     stage2e = [0x00, 0x96, 0x00, 0x00, 0x00, 0x00, 0x08]
     stage2f = [0x11, 0x0D, 0x44, 0x4D, 0x53, 0x0D]
     stages = [
         stage2a,
         stage2b,
         stage2c,
         stage2d,
         stage2e,
         stage2f,
     ]
     awake = False
     for stage in stages:
         msg = bytearray(stage)
         self.write(str(msg))
         response = self.readlines()
         if len(response) > 0:
             io.info("got a response!!!")
             io.info(lib.hexdump(bytearray(response)))
             awake = True
     return awake
Beispiel #12
0
 def getData(self):
   data = self.data
   ids = [ ]
   ids.append( str(data[0:6]) )
   ids.append( str(data[6:12]) )
   ids.append( str(data[12:18]) )
   log.info("READ radio ACL:\n%s" % lib.hexdump(data))
   return ids
Beispiel #13
0
 def getData(self):
     data = self.data
     log.info("READ totals today:\n%s" % lib.hexdump(data))
     totals = {
         'today': lib.BangInt(data[0:2]) / 10.0,
         'yesterday': lib.BangInt(data[2:4]) / 10.0
     }
     return totals
Beispiel #14
0
 def getData(self):
     data = self.data
     ids = []
     ids.append(str(data[0:6]))
     ids.append(str(data[6:12]))
     ids.append(str(data[12:18]))
     log.info("READ radio ACL:\n%s" % lib.hexdump(data))
     return ids
Beispiel #15
0
 def getData(self):
   data = self.data
   log.info("READ totals today:\n%s" % lib.hexdump(data))
   totals = {
     'today': lib.BangInt(data[0:2]) / 10.0,
     'yesterday': lib.BangInt(data[2:4]) / 10.0
   }
   return totals
Beispiel #16
0
    def readStatus(self):
        result = []

        def fetch_status():
            res = self.link.sendComLink2Command(3)
            #status = res and res[0] # 0 indicates success
            log.info("res: %r" % res)
            if res and res[0] == 0:  # 0 indicates success
                return res
            #if status == 0:
            #result = res
            #return True
            return False

        #if not retry(fetch_status) or len(result) == 0:
        result = retry(fetch_status)
        if not result:
            raise RFFailed("rf read header indicates failure")
        """
    """
        #result         = self.link.sendComLink2Command(3)

        commStatus = result[0]  # 0 indicates success

        status = result[2]
        lb, hb = result[3], result[4]

        stat = StickStatusStruct(status)
        header = result[0:3]
        test = [StickStatusStruct(s) for s in header]
        log.info(test)
        log.info("HEADER:\n%s" % lib.hexdump(header))
        if 0 != commStatus:
            raise DeviceCommsError('\n'.join([
                "rf read header indicates failure",
                "%s" % lib.hexdump(header)
            ]))
        assert commStatus == 0, ("command status not 0: %s:%s" %
                                 (commStatus, stat))
        bytesAvailable = lib.BangInt((lb, hb))
        self.status = status

        if (status & 0x1) > 0:
            return bytesAvailable
        return 0
Beispiel #17
0
 def __call__(self, port):
     stuff = port.write("")
     #time.sleep(5)
     stuff = port.readlines()
     io.info("RECIEVED HANDSHAKE REPLY: %s bytes" % len(stuff))
     io.info(lib.hexdump(bytearray(stuff)))
     if len(stuff) > 0:
         return True
     return False
Beispiel #18
0
 def __call__(self, port ):
   stuff = port.write("")
   time.sleep(5)
   stuff = port.readlines( )
   io.info( "RECIEVED HANDSHAKE REPLY: %s bytes" % len(stuff) )
   io.info(lib.hexdump(bytearray( stuff )))
   if len(stuff) > 0:
     return True
   return False
Beispiel #19
0
  def readDeviceDataIO(self):
    results   = self.readData()
    lb, hb    = results[5] & 0x7F, results[6]
    self.eod  = (results[5] & 0x80) > 0
    resLength = lib.BangInt((lb, hb))
    assert resLength > 63, ("cmd low byte count:\n%s" % lib.hexdump(results))

    data = results[13:13+resLength]
    assert len(data) == resLength
    crc = results[-1]
    # crc check
    log.info('readDeviceDataIO:msgCRC:%r:expectedCRC:%r:data:%r' % (crc, CRC8(data), data))
    assert crc == CRC8(data)
    return data
Beispiel #20
0
 def __requireAck__( self ):
   """Try to read an ack, raising MissingAck if we don't read it. Returns
   bytearray ack."""
   ack = None
   for i in xrange( RETRIES ):
     ack = bytearray( self.read( 6 ) )
     if ack == '':
       io.debug( "empty ack:%s:%s:sleeping:%s" % ( i, ack, self.__pause__ ) )
       time.sleep( self.__pause__ )
     else:
       break
   io.info( 'ACK: %s' % lib.hexdump( ack ) )
   if ack == '':
     raise MissingAck(i)
   return ack
Beispiel #21
0
def loopingRead( carelink ):
  for x in itertools.count( ):
    print '######### BEGIN LOOP ###########'
    print 'loop:%s' % x
    length = getBytesAvailable( carelink )
    print 'found length %s' % length
    response = readBytes( carelink, length )
    print lib.hexdump( response )
    print "Read a total of %s bytes / %s requested" % ( len( response), length )
    if len( response ) < length:
      remaining = length - len( response )
      print "Response was less than requested... "
      print "trying the remainder: %s" % remaining
      response = readBytes( carelink, remaining + ( remaining % 64 ) )
    pprint( carelink( USBStatus( ) ).info )
    print 'finishing loop:%s' % x
    print '######### STATS ###########'
    print 'signal strength: %sdBm' % \
           carelink( USBSignalStrength( ) ).info
    pprint( carelink( RadioInterfaceStats( ) ).info )
    pprint( carelink( USBInterfaceStats(   ) ).info )
    pprint( carelink( USBProductInfo(      ) ).info )
    pprint( carelink( USBStatus(           ) ).info )
    print 
Beispiel #22
0
    def readDeviceDataIO(self):
        results = self.readData()
        lb, hb = results[5] & 0x7F, results[6]
        self.eod = (results[5] & 0x80) > 0
        resLength = lib.BangInt((lb, hb))
        assert resLength > 63, ("cmd low byte count:\n%s" %
                                lib.hexdump(results))

        data = results[13:13 + resLength]
        #log.debug('readDeviceDataIO:data length check:%r:expected length:%r' % ())
        assert len(data) == resLength
        crc = results[-1]
        # crc check
        log.debug('readDeviceDataIO:msgCRC:%r:expectedCRC:%r:data:%r' %
                  (crc, CRC8(data), data))
        assert crc == CRC8(data)
        return data
Beispiel #23
0
 def stage2_wakeup(self):
   stage2a = [ 0x80, 0x25, 0x00, 0x00, 0x00, 0x00, 0x07 ]
   stage2b = [ 0x80, 0x25, 0x00, 0x00, 0x00, 0x00, 0x08 ]
   stage2c = [ 0x11, 0x0D, 0x44, 0x4D, 0x53, 0x0D, 0x0D ]
   stage2d = [ 0x11, 0x0D, 0x44, 0x4D, 0x53, 0x0D, 0x0D ]
   stage2e = [ 0x00, 0x96, 0x00, 0x00, 0x00, 0x00, 0x08 ]
   stage2f = [ 0x11, 0x0D, 0x44, 0x4D, 0x53, 0x0D ]
   stages = [ stage2a, stage2b, stage2c, stage2d, stage2e, stage2f, ]
   awake = False
   for stage in stages:
     msg = bytearray(stage)
     self.write( str( msg ) )
     response = self.readlines( )
     if len(response) > 0:
       io.info("got a response!!!")
       io.info(lib.hexdump(bytearray(response)))
       awake = True
   return awake
Beispiel #24
0
 def checkAck(self):
   time.sleep(.100)
   result     = bytearray(self.read(64))
   if len(result) == 0:
     raise AckError('checkAck must have a response')
   io.info('checkAck:read')
   commStatus = result[0]
   # usable response
   #assert commStatus == 1
   if commStatus != 1:
     raise DeviceCommsError('\n'.join([ "checkAck: bad response code"
                                      , lib.hexdump(result[0:4]) ]))
   status     = result[1]
   # status == 102 'f' NAK, look up NAK
   if status == 85: # 'U'
     log.info('ACK OK')
     return result[3:]
   assert False, "NAK!!"
Beispiel #25
0
 def checkAck(self, sleep=.01):
     time.sleep(sleep)
     result = bytearray(self.read(64))
     if len(result) == 0:
         return False
         raise AckError('checkAck must have a response')
     io.info('checkAck:read')
     commStatus = result[0]
     # usable response
     #assert commStatus == 1
     if commStatus != 1:
         raise DeviceCommsError('\n'.join(
             ["checkAck: bad response code",
              lib.hexdump(result[0:4])]))
     status = result[1]
     # status == 102 'f' NAK, look up NAK
     if status == 85:  # 'U'
         log.info('checkACK: ACK OK')
         return result[3:]
     assert False, "NAK!!"
Beispiel #26
0
  def readData(self):
    bytesAvailable = self.getNumBytesAvailable()
    packet = [12, 0, lib.HighByte(bytesAvailable), lib.LowByte(bytesAvailable)]
    packet.append( CRC8(packet) )

    response = self.writeAndRead(packet, bytesAvailable)
    # assert response.length > 14
    # assert (int(response[0]) == 2), repr(response)

    rcode = response[0]
    if len(response) < 14:
      raise DeviceCommsError('\n'.join([ "readData: insufficientData",
                             lib.hexdump(response) ]))

    if rcode != 2:
      raise DeviceCommsError("readData: bad response code: %#04x" % rcode)
    # response[1] != 0 # interface number !=0
    # response[2] == 5 # timeout occurred
    # response[2] == 2 # NAK
    # response[2] # should be within 0..4
    log.info("readData ACK")
    return response
Beispiel #27
0
 def __nak__(self):
     return '%s:raw:%s' % (self.reason(), lib.hexdump(self.head))
Beispiel #28
0
 def getData(self):
     data = self.data
     log.info("READ contrast:\n%s" % lib.hexdump(data))
     return data
Beispiel #29
0
 def getData(self):
     data = self.data
     log.info("XXX: READ cur page number:\n%s" % lib.hexdump(data))
     return lib.BangLong(data[0:4])
Beispiel #30
0
 def readlines(self):
     r = self.serial.readlines()
     io.info('usb.read.len: %s\n%s' %
             (len(r), lib.hexdump(bytearray(''.join(r)))))
     return r
Beispiel #31
0
def FormatCommand(serial='665455',
                  command=141,
                  params=[],
                  retries=2,
                  expectedPages=1):
    """"
 Write Radio Buffer Commands look like this.
 While the formatting of this command seems correct, reads of usb status
 afterwards should be setting tx indicator and length fields.  Instead we're
 getting error fields.

 00    [ 0x01
 01    , 0x00
 02    , 0xA7 # 167, tx.packet
 03    , 0x01 # ?? potential sequence count?
 04    , serial[ 0 ]
 05    , serial[ 1 ]
 06    , serial[ 3 ]
 07    , 0x80 | HighByte( paramCount )
 08    , LowByte( paramCount )
 09    , code == 93 ? 85 : 0 # initialize pump rf!!!?
 10    , maxRetries # sequence count?
 11    , pagesSent > 1 ? 2 : pagesSent # sequence count?
 12    , 0
 13    , code
 14    , CRC8( code[ :15 ] )
 15    , command parameters....
 ??    , CRC8( command parameters )
       ]

 The Pump Packet looks like this:
 7 bytes with parameters on the end
 00     167
 01     serial[ 0 ]
 02     serial[ 1 ]
 03     serial[ 2 ]
 04     commandCode
 05     sequenceNumber or paramCount
 06     [ parameters ]
 06/07  CRC8(packet)

 or:
 167, serial, code, seq/param, params, CRC8(packet)
NB the whole thing is wrapped by encodeDC()

ACK: is:


  >>> FormatCommand( serial='665455', command=141 )
  bytearray( [ 0x01, 0x00, 0xA7, 0x01, 0x66, 0x54, 0x55, 0x80,
               0x00, 0x00, 0x02, 0x01, 0x00, 0x8D, 0x5B, 0x00 ] )
  """

    readable = 0
    code = [
        1,
        0,
        167,
        1,
    ]
    code.extend(list(bytearray(serial.decode('hex'))))
    code.extend([
        0x80 | lib.HighByte(len(params)),
        lib.LowByte(len(params)), command == 93 and 85 or 0, retries,
        expectedPages, 0, command
    ])
    io.info('crc stuff')
    io.info(code)
    code.append(lib.CRC8.compute(code))
    code.extend(params)
    code.append(lib.CRC8.compute(params))
    io.info('\n' + lib.hexdump(bytearray(code)))
    return bytearray(code)
Beispiel #32
0
 def read( self, c ):
   r = self.serial.read( c )
   io.info( 'usb.read.len: %s'   % ( len( r ) ) )
   io.info( 'usb.read.raw: \n%s' % ( lib.hexdump( bytearray( r ) ) ) )
   return r
Beispiel #33
0
 def getData(self):
   data = self.data
   log.info("XXX: READ cur page number:\n%s" % lib.hexdump(data))
   return lib.BangLong(data[0:4])
Beispiel #34
0
 def getData(self):
   data = self.data
   log.debug("READ FIRMWARE HEX:\n%s" % lib.hexdump(data))
   return str(data.split( chr(0x0b) )[0]).strip( )
Beispiel #35
0
 def getData(self):
     data = self.data
     log.info("XXX: READ HISTORY DATA!!:\n%s" % lib.hexdump(data))
     return data
Beispiel #36
0
 def read(self, c):
     r = self.serial.read(c)
     io.info('usb.read.len: %s' % (len(r)))
     io.info('usb.read.raw: \n%s' % (lib.hexdump(bytearray(r))))
     return r
Beispiel #37
0
def FormatCommand( serial='665455', command=141, params=[ ], retries=2, expectedPages=1 ):
  """"
 Write Radio Buffer Commands look like this.
 While the formatting of this command seems correct, reads of usb status
 afterwards should be setting tx indicator and length fields.  Instead we're
 getting error fields.

 00    [ 0x01
 01    , 0x00
 02    , 0xA7 # 167, tx.packet
 03    , 0x01 # ?? potential sequence count?
 04    , serial[ 0 ]
 05    , serial[ 1 ]
 06    , serial[ 3 ]
 07    , 0x80 | HighByte( paramCount )
 08    , LowByte( paramCount )
 09    , code == 93 ? 85 : 0 # initialize pump rf!!!?
 10    , maxRetries # sequence count?
 11    , pagesSent > 1 ? 2 : pagesSent # sequence count?
 12    , 0
 13    , code
 14    , CRC8( code[ :15 ] )
 15    , command parameters....
 ??    , CRC8( command parameters )
       ]

 The Pump Packet looks like this:
 7 bytes with parameters on the end
 00     167
 01     serial[ 0 ]
 02     serial[ 1 ]
 03     serial[ 2 ]
 04     commandCode
 05     sequenceNumber or paramCount
 06     [ parameters ]
 06/07  CRC8(packet)

 or:
 167, serial, code, seq/param, params, CRC8(packet)
NB the whole thing is wrapped by encodeDC()

ACK: is:


  >>> FormatCommand( serial='665455', command=141 )
  bytearray( [ 0x01, 0x00, 0xA7, 0x01, 0x66, 0x54, 0x55, 0x80,
               0x00, 0x00, 0x02, 0x01, 0x00, 0x8D, 0x5B, 0x00 ] )
  """

  readable = 0
  code = [ 1 , 0 , 167 , 1, ] 
  code.extend( list( bytearray( serial.decode('hex') ) ) )
  code.extend( [ 0x80 | lib.HighByte( len( params ) )
         , lib.LowByte( len( params ) )
         , command == 93 and 85 or 0
         , retries
         , expectedPages
         , 0
         , command
         ] )
  io.info( 'crc stuff' )
  io.info( code )
  code.append( lib.CRC8.compute( code ) )
  code.extend( params )
  code.append( lib.CRC8.compute( params ) )
  io.info( '\n' + lib.hexdump( bytearray( code ) ) )
  return bytearray( code )
Beispiel #38
0
 def write( self, string ):
   r = self.serial.write( string )
   io.info( 'usb.write.len: %s\n%s' % ( len( string ),
                                        lib.hexdump( bytearray( string ) ) ) )
   return r
Beispiel #39
0
 def getData(self):
   data = self.data
   log.info("XXX: READ HISTORY DATA!!:\n%s" % lib.hexdump(data))
   return data
Beispiel #40
0
 def readlines( self ):
   r = self.serial.readlines( )
   io.info( 'usb.read.len: %s\n%s' % ( len( r ),
                                       lib.hexdump( bytearray( ''.join( r ) ) ) ) )
   return r
Beispiel #41
0
 def __nak__( self ):
   return '%s:raw:%s' % ( self.reason( ), lib.hexdump( self.head ) )
Beispiel #42
0
 def getData(self):
     data = self.data
     rate = lib.BangInt(data[2:4]) / 40.0
     duration = lib.BangInt(data[4:6])
     log.info("READ temporary basal:\n%s" % lib.hexdump(data))
     return {'rate': rate, 'duration': duration}
Beispiel #43
0
 def getData(self):
     data = self.data
     log.debug("READ FIRMWARE HEX:\n%s" % lib.hexdump(data))
     return str(data.split(chr(0x0b))[0]).strip()
Beispiel #44
0
 def hexdump( self ):
   return lib.hexdump( bytearray( self.code ) )
Beispiel #45
0
 def getData(self):
   data = self.data
   log.info("READ remaining insulin:\n%s" % lib.hexdump(data))
   return lib.BangInt(data[0:2])/10.0
Beispiel #46
0
def hex_dump_data(data):
  """My library has a convenient hexdumper, YMMV."""
  print lib.hexdump(bytearray(data))
Beispiel #47
0
 def getData(self):
     data = self.data
     log.info("READ remaining insulin:\n%s" % lib.hexdump(data))
     return lib.BangInt(data[0:2]) / 10.0
Beispiel #48
0
 def getData(self):
   data = self.data
   rate = lib.BangInt(data[2:4])/40.0
   duration = lib.BangInt(data[4:6])
   log.info("READ temporary basal:\n%s" % lib.hexdump(data))
   return { 'rate': rate, 'duration': duration }
Beispiel #49
0
 def getData(self):
   data = self.data
   log.info("READ contrast:\n%s" % lib.hexdump(data))
   return data
Beispiel #50
0
def hex_dump_data(data):
    """My library has a convenient hexdumper, YMMV."""
    print lib.hexdump(bytearray(data))
Beispiel #51
0
 def write(self, string):
     r = self.serial.write(string)
     io.info('usb.write.len: %s\n%s' %
             (len(string), lib.hexdump(bytearray(string))))
     return r