def getMacAddr() : a = events.Event() a.cmd = 0x43 a.src = JTAGADDR a.setAddr(NETCONTROLADDR) a.data[0] = 0x03 events.sendEvent(a) e = events.readEvent() nonecnt = 0 while e == None: #events.sendEvent(a) e = events.readEvent() nonecnt += 1 ma = [0, 0, 0, 0, 0, 0] lastEvt = None while e != None: lastEvt = e #events.sendEvent(a) e = events.readEvent() nonecnt += 1 print e ma[5] = lastEvt.data[1] >> 8 ma[4] = lastEvt.data[1] & 0xFF ma[3] = lastEvt.data[2] >> 8 ma[2] = lastEvt.data[2] & 0xFF ma[1] = lastEvt.data[3] >> 8 ma[0] = lastEvt.data[3] & 0xFF return ma
def commitData(): """ Commits the current data buffer """ a = events.Event() a.cmd = 103 a.src = JTAGADDR a.setAddr(SYSCONTROLADDR) events.sendEvent(a)
def setMacAddr(addr): """ Sets the mac address The address should be a list of bytes """ a = events.Event() a.cmd = 0x42 a.src = JTAGADDR a.setAddr(NETCONTROLADDR) a.data[0] = 0x03 a.data[1] = addr[5] << 8 | addr[4] a.data[2] = addr[3] << 8 | addr[2] a.data[3] = addr[1] << 8 | addr[0] print a events.sendEvent(a)
def sendDataWords(data): """ Sends 4 16-bit data words to be placed in the TX buffer data[0] becomes event[0] """ a = events.Event() a.cmd = 101 a.src = JTAGADDR a.setAddr(SYSCONTROLADDR) for i, d in enumerate(data): a.data[i] = d events.sendEvent(a)
def readreg(val): a = events.Event() a.cmd = 0x30 a.src = 0x07 a.setAddr(0x4) a.data[0] = 0x00 a.data[1] = val a.data[2] = 0x00 a.data[3] = 0x00 events.sendEvent(a) e = None while e == None: e = events.readEvent() if e == None: events.sendEvent(a) return e
def setIP(addrstr, bcast = False): ipaddr = addrstr.split(".") ip0 = int(ipaddr[0]) ip1 = int(ipaddr[1]) ip2 = int(ipaddr[2]) ip3 = int(ipaddr[3]) a = events.Event() a.cmd = 0x42 a.src = JTAGADDR a.setAddr(NETCONTROLADDR) if bcast: a.data[0] = 0x02 else: a.data[0] = 0x01 a.data[1] = ip0 << 8 | ip1 a.data[2] = ip2 << 8 | ip3 events.sendEvent(a)
def toggleProg(): """ Toggle EPROG """ maskevtlow = events.Event() maskevtlow.cmd = 100 maskevtlow.src = JTAGADDR maskevtlow.setAddr(SYSCONTROLADDR) maskevtlow.data[0] = 0xFFFF maskevtlow.data[1] = 0xFFFF events.sendEvent(maskevtlow) a = events.Event() a.cmd = 102 a.src = JTAGADDR a.setAddr(SYSCONTROLADDR) a.data[0] = 0xFF events.sendEvent(a)
import events m = events.Mask() m.setAddr(3) events.setMask(m) # Dummy read of 0x01234567 a = events.Event() a.cmd = 0x20 a.src = 0x01 a.setAddr(0x2) a.data[0] = 0xFFFF a.data[1] = 0xFFFF a.data[2] = 0x0110 a.data[3] = 0x0800 events.sendEvent(a)
def sendEvent(self, event_name, event): result1 = sendEvent(self._getMessage(event_name), event) result2 = sendEvent('%s.%d' % (event_name, id(self)), event) return [result1, result2]
def sendEvent( self, event_name, event ): result1 = sendEvent( self._getMessage( event_name ), event ) result2 = sendEvent( '%s.%d' % ( event_name, id(self) ), event ) return [result1, result2]