import zmq
import os
import sys
#sys.path.insert(0, '../src')
sys.path.insert(0, 'model_sim/src')
import model_wrap
import pdb

pkt = bytearray([0x04, 0xDE, 0xFF, 0xDF, 0xFA, 0x4A, 0x02, 0xF8, 0xBD, 0xBD, 0x46, 0xAF, 0x0B, 0x2B, 0xE4, 0xC5, 0x22, 0xCD, 0x83, 0xD8, 0x0B, 0x3B, 0x49, 0xC2, 0x8B, 0x37, 0xB8, 0xCD, 0x4D, 0x35, 0xA4, 0x60, 0x65, 0x0A, 0xBE, 0xAD, 0xAB, 0xC6, 0x06, 0x29, 0x98, 0x2C, 0x35, 0xB6, 0xB7, 0x3E, 0x6E, 0xB1, 0xCC, 0x3B, 0xA8, 0xB6, 0xCC, 0xA8, 0x9C, 0xD4, 0x1A, 0x80, 0xDB, 0x44, 0xAA, 0x97, 0x18, 0x6C, 0x8D, 0xD9, 0x0A, 0xE1, 0x14, 0x99, 0xDA, 0xD7, 0xE7, 0x3D, 0x9C, 0xEE, 0xE4, 0xCC, 0xCC, 0x5A, 0xCD, 0x83, 0x44, 0x18, 0x25, 0x7A, 0x98, 0x0C, 0xAA, 0x4A, 0xA4, 0x04, 0xB9, 0x95, 0x01, 0xE6, 0x94, 0x97, 0x05, 0x2A, 0xCA, 0x39, 0xE6, 0xDA, 0x59, 0x62, 0x63, 0x74, 0xd9, 0x46])

model_wrap.zmq_connect()

data = bytearray([0xaa, 0xbb, 0xcc, 0xdd])
model_wrap.write_mem(int('0xbfc208ec', 16), data, 4)
data = bytearray(model_wrap.read_mem(int('0xbfc208ec', 16), 4))
print [hex(ord(c)) for c in bytes(data)]

data = bytearray([0xbc, 0xda, 0xba, 0x00])
model_wrap.write_reg(int('0x3408010', 16), data)
data = bytearray(model_wrap.read_reg(int('0x3408010', 16)))
print [hex(ord(c)) for c in bytes(data)]

model_wrap.step_network_pkt(pkt, 1)
(opkt, port, cos) = model_wrap.get_next_pkt()
print "Got pkt back from model len: %d, port: %d, cos: %d" % (len(opkt), port, cos)

