Beispiel #1
0
def get_raw_memory(mmap, number):
    """Return a raw representation of memory @number"""
    offset = get_mem_offset(number)
    if number >= 850:
        size = MEM_LOC_SIZE_B
    else:
        size = MEM_LOC_SIZE_A
    return MemoryMap(mmap[offset:offset + size])
Beispiel #2
0
      u16 bar;
      u16 baz;
      u8 one;
      u8 upper:2,
         twobit:1,
         onebit:1,
         lower:4;
      u8 array[3];
      char str[3];
      bbcd bcdL[2];
    } foo[2];
    u8 tail;
    """
    data = "\xfe\x10\x00\x08\xFF\x23\x01\x02\x03abc\x34\x89"
    data = (data * 2) + "\x12"
    data = MemoryMap(data)

    ast = bitwise_grammar.parse(test)

    # Just for testing, pretty-print the tree
    pp(ast)

    # Mess with it a little
    p = Processor(data, 0)
    obj = p.parse(ast)
    print "Object: %s" % obj
    print obj["foo"][0]["bcdL"]
    print obj["tail"]
    print obj["foo"][0]["bar"]
    obj["foo"][0]["bar"].set_value(255 << 8)
    obj["foo"][0]["twobit"].set_value(0)
Beispiel #3
0
 def get_obj(self):
     self._data = MemoryMap(str(self._data))
     return bitwise.parse(mem_duptone_format, self._data)
Beispiel #4
0
 def get_obj(self):
     self._data = MemoryMap(str(self._data))  # Make sure we're assignable
     return bitwise.parse(self.FORMAT, self._data)
Beispiel #5
0
 def initialize(self):
     """Initialize to sane values"""
     self._data = MemoryMap("".join(["\x00"] * (self.get_obj().size() / 8)))
Beispiel #6
0
 def get_obj(self):
     """Return a bitwise parsed object"""
     self._data = MemoryMap(str(self._data))  # Make sure we're assignable
     return bitwise.parse(MEM_FORMAT, self._data)
Beispiel #7
0
def get_raw_memory(mmap, number):
    offset = get_mem_offset(number)
    return MemoryMap(mmap[offset:offset + MEM_LOC_SIZE])
Beispiel #8
0
 def get_obj(self):
     self._data = MemoryMap(str(self._data))
     return bitwise.parse(self.FORMAT, self._data)
Beispiel #9
0
 def __init__(self, subcmd=0, flen=0, cmd=0x1A):
     self._map = MemoryMap("\x00" * (4 + flen))
     self._map[0] = "\x01\x80" + chr(cmd) + chr(subcmd)
Beispiel #10
0
 def from_frame(self, frame):
     """Construct the frame by copying another frame"""
     self._map = MemoryMap(frame.get_raw())
Beispiel #11
0
 def from_raw(self, data):
     """Construct the frame from raw data"""
     self._map = MemoryMap(data)