Example #1
0
    def FormatCommand(serial='206525', command=141, params=[]):
        """"
   00    [ 1
   01    , 0
   02    , 167
   03    , 1
   04    , serial[ 0 ]
   05    , serial[ 1 ]
   06    , serial[ 3 ]
   07    , 0x80 | HighByte( paramCount )
   08    , LowByte( paramCount )
   09    , code == 93 ? 85 : 0
   10    , maxRetries
   11    , pagesSent > 1 ? 2 : pagesSent
   12    , 0
   14    , code
   15    , CRC8( code[ :15 ] )
   16    , command parameters....
   ??    , CRC8( command parameters )
         ]
    """

        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,
            2  # Retries
            ,
            1  # 2 or <=1 pages?
            ,
            0  # EOH
            ,
            command
        ])
        io.info('crc stuff')
        io.info(code)
        io.info(lib.hexdump(bytearray(code)))
        code.append(lib.CRC8.compute(code))
        #code.append( 0 ) # Command Params
        code.extend(params)  # Command Params
        code.append(lib.CRC8.compute(params))
        return bytearray(code)
Example #2
0
  def FormatCommand( serial='206525', command=141, params=[ ] ):
    """"
   00    [ 1
   01    , 0
   02    , 167
   03    , 1
   04    , serial[ 0 ]
   05    , serial[ 1 ]
   06    , serial[ 3 ]
   07    , 0x80 | HighByte( paramCount )
   08    , LowByte( paramCount )
   09    , code == 93 ? 85 : 0
   10    , maxRetries
   11    , pagesSent > 1 ? 2 : pagesSent
   12    , 0
   14    , code
   15    , CRC8( code[ :15 ] )
   16    , command parameters....
   ??    , CRC8( command parameters )
         ]
    """

    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
           , 2 # Retries
           , 1 # 2 or <=1 pages?
           , 0 # EOH
           , command
           ] )
    io.info( 'crc stuff' )
    io.info( code )
    io.info( lib.hexdump( bytearray( code ) ) )
    code.append( lib.CRC8.compute( code ) )
    #code.append( 0 ) # Command Params
    code.extend( params ) # Command Params
    code.append( lib.CRC8.compute( params ) )
    return bytearray( code )
Example #3
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 )
Example #4
0
if len(raw)==0:
    print("Did you plug your watches? Check the clip!", file=sys.stderr)
    exit(-1)

if args.debug:
    dump = open(os.path.join(tempfile.gettempdir(), "schwinn810.bin"), mode="wb")
    dump.write(raw)

(ee, e1, e2, e3, bcd1, bcd2, bcd3, serial, v1, v2, check1, check2) = struct.unpack("sBBBBBB6s6s7s2x2I", raw)
if check1 != check2:
    print("0x{:X} != 0x{:X}".format(check1, check2))
#    port.close()
#    print("We are reading something wrong. Are you trying to communicate with another device?", file=sys.stderr)
#    exit(-1)
id = "{0:s} {1:s} {2:s} {3:02d} {4:02d} {5:02d} {6:02d} {7:02d} {8:02d}" \
    .format(serial.decode('ascii'), v1.decode('ascii'), ee.decode('ascii'), e1, e2, e3, unpackBCD(bcd1), unpackBCD(bcd2), unpackBCD(bcd3))
print("Found %s" % id)

if args.save:
    pass
else:
    if not reg: port.write(READ_SETTINGS)
    raw = port.read(0x24)

    if args.debug:
        dump.write(raw)

    (female, age, x2, x3,  kg, cm, zone_active, zone1_low,  zone1_high, zone2_low, zone2_high, zone3_low,\
         zone3_high, zone_alarm, x5, x6,  contrast, x8, night_mode, y2,  y3, y4, hr24, y6, y7, y8, z1, z2, check1, check2) = struct.unpack("=28B2I", raw)
    # contrast 8 => 50%
    # x5=alert
Example #5
0
 def cmd_serial(self):
     """Get CAN232 serial number."""
     serial = self._C232.serial()
     return 'CAN232 Serial number: {0}. Error: {1}'.format(
         serial.decode('ISO-8859-1'), self._C232.error)
Example #6
0
 def cmd_serial(self, def_in):
     """Get CAN232 serial number."""
     serial = self._C232.serial()
     return 'CAN232 Serial number: {0}. Error: {1}'.format(serial.decode('ISO-8859-1'), self._C232.error)
Example #7
0
    exit(-1)

if args.debug:
    dump = open(os.path.join(tempfile.gettempdir(), "schwinn810.bin"),
                mode="wb")
    dump.write(raw)

(ee, e1, e2, e3, bcd1, bcd2, bcd3, serial, v1, v2, check1,
 check2) = struct.unpack("sBBBBBB6s6s7s2x2I", raw)
if check1 != check2:
    print("0x{:X} != 0x{:X}".format(check1, check2))
#    port.close()
#    print("We are reading something wrong. Are you trying to communicate with another device?", file=sys.stderr)
#    exit(-1)
id = "{0:s} {1:s} {2:s} {3:02d} {4:02d} {5:02d} {6:02d} {7:02d} {8:02d}" \
    .format(serial.decode('ascii'), v1.decode('ascii'), ee.decode('ascii'), e1, e2, e3, unpackBCD(bcd1), unpackBCD(bcd2), unpackBCD(bcd3))
print("Found %s" % id)

if args.save:
    pass
else:
    if not reg: port.write(READ_SETTINGS)
    raw = port.read(0x24)

    if args.debug:
        dump.write(raw)

    (female, age, x2, x3,  kg, cm, zone_active, zone1_low,  zone1_high, zone2_low, zone2_high, zone3_low,\
         zone3_high, zone_alarm, x5, x6,  contrast, x8, night_mode, y2,  y3, y4, hr24, y6, y7, y8, z1, z2, check1, check2) = struct.unpack("=28B2I", raw)
    # contrast 8 => 50%
    # x5=alert
Example #8
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)