Skip to content

Instantly share code, notes, and snippets.

@cfelton
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cfelton/c0928fe18c28286515e5 to your computer and use it in GitHub Desktop.
Save cfelton/c0928fe18c28286515e5 to your computer and use it in GitHub Desktop.
def WriteVidPid(self, vid, pid, addr=0xA0):
try:
vid_lo = vid & 0xFF
vid_hi = (vid >> 8) & 0xFF
pid_lo = pid & 0xFF
pid_hi = (pid >> 8) & 0xFF
ControlBuffer = c_ubyte * 16
d = ControlBuffer()
if addr == 0xA0:
d[0] = 0x00 # Address
d[1] = 0xC0
d[2] = vid_lo
d[3] = vid_hi
d[4] = pid_lo
d[5] = pid_hi
d[6] = 0x01
d[7] = 0x00
d[8] = 0x00
blen = 9
elif addr == 0xA2:
d[0] = 0x00 # Address high
d[1] = 0x00 # Address low
d[2] = 0xC0
d[3] = vid_lo
d[4] = vid_hi
d[5] = pid_lo
d[6] = pid_hi
d[7] = 0x01
d[8] = 0x00
d[9] = 0x00
blen = 10
else:
raise TypeError, "Incorrect EEPROM Address %x" % (addr)
self.usbp_lib.usbpWriteI2C(self.uinfo, addr, d, blen)
except:
self.ulog.error('Exception: Caught in WriteVidPid')
raise StandardError, "Exception Caught in WriteVidPid"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment