示例#1
0
def parseCompass( filename, watchModules = [] ):
  for io, id, data in parseFileG( filename, watchModules ):
    if io == 0:
      pass
    elif io == 1:
      if id == 0x187: # 3D compass
        print "c\t%d\t%d\t%d" % (sint16(data[0:2]), sint16(data[2:4]), sint16(data[4:6]) )
      if id == 0x387: # 3D accelerometer
        print "a\t%d\t%d\t%d" % (sint16(data[0:2]), sint16(data[2:4]), sint16(data[4:6]) )
      if id == 0x487: # 3D raw compass data
        print "r\t%d\t%d\t%d" % (sint16(data[0:2]), sint16(data[2:4]), sint16(data[4:6]) )
      if id == 0x181:# or id == 0x182:
        e = data[0]|(data[1]<<8)|(data[2]<<16)|(data[3]<<24) 
        print "e\t%x\t%d" % (id, e)
示例#2
0
def can_gen(filename):
    m = {0x284: ('encoders', 'hh'), 0x182: ('steering', 'h')}
    can = parseFileG(filename)
    ret = {}
    for msg in can:
        io_dir, msg_type, data = msg
        if io_dir == 1:
            if msg_type == 0x80:
                yield ret
                ret = {}
            elif msg_type in m:
                name, str_format = m[msg_type]
                val = struct.unpack(str_format,
                                    ''.join([chr(c) for c in data]))
                if len(val) == 1:
                    val = val[0]
                ret[name] = val
示例#3
0
def parseCompass(filename, watchModules=[]):
    for io, id, data in parseFileG(filename, watchModules):
        if io == 0:
            pass
        elif io == 1:
            if id == 0x187:  # 3D compass
                print "c\t%d\t%d\t%d" % (sint16(data[0:2]), sint16(
                    data[2:4]), sint16(data[4:6]))
            if id == 0x387:  # 3D accelerometer
                print "a\t%d\t%d\t%d" % (sint16(data[0:2]), sint16(
                    data[2:4]), sint16(data[4:6]))
            if id == 0x487:  # 3D raw compass data
                print "r\t%d\t%d\t%d" % (sint16(data[0:2]), sint16(
                    data[2:4]), sint16(data[4:6]))
            if id == 0x181:  # or id == 0x182:
                e = data[0] | (data[1] << 8) | (data[2] << 16) | (
                    data[3] << 24)
                print "e\t%x\t%d" % (id, e)
示例#4
0
def can_gen(filename):
    m = {
            0x284: ('encoders', 'hh'),
            0x182: ('steering', 'h')
        }
    can = parseFileG(filename)
    ret = {}
    for msg in can:
        io_dir, msg_type, data = msg
        if io_dir == 1:
            if msg_type == 0x80:
                yield ret
                ret = {}
            elif msg_type in m:
                name, str_format = m[msg_type]
                val = struct.unpack(str_format, ''.join([chr(c) for c in data]))
                if len(val) == 1:
                    val = val[0]
                ret[name] = val