예제 #1
0
 def __init__(self, device, ep):
     self.end_point = ep
     picross.pic_set_interrupt()
     self.interface = picross.usbdevice(device, 0)
     self.bulk_pipe = picross.bulk_out_pipe(self.end_point, 512)
     self.interface.add_bulk_out(self.bulk_pipe)
     self.interface.start_pipes()
     self.interface.control_out(0x40, 0xb1, 0, 0, '')
     time.sleep(4)
예제 #2
0
    def query(s):
        print 'querying', s
        ez = picross.usbdevice(s, 0)

        if opts.len > 0:
            r = ez.control_in(0x40 | 0x80, opts.req, opts.val, opts.idx,
                              opts.len)
            print ' '.join(['%x' % ord(x) for x in r])

        else:
            ez.control(0x40, opts.req, opts.val, opts.idx)
예제 #3
0
 def __init__(self, usbname, agent):
     self.__usbname = usbname
     self.__device = picross.usbdevice(usbname, 0)
     self.__agent = agent
     self.__thing = piw.thing()
     piw.tsd_thing(self.__thing)
     self.__instrument = 0
     self.__thing.set_slow_timer_handler(utils.notify(self.__poll))
     self.__counter = itertools.cycle([1] + [0] * 20)
     self.__kbd = None
     self.__thing.timer_slow(1000)
예제 #4
0
 def __poll(self):
     if not self.__device:
         self.__device = picross.usbdevice(self.__usbname,0)
     basecfg = self.bs_config_read()
     instcfg = self.inst_config_read()
     if self.__counter.next():
         print 'basecfg: %s' % ''.join(map(lambda x:hex(ord(x))[2:].zfill(2),basecfg))
         print 'instcfg: %s' % ''.join(map(lambda x:hex(ord(x))[2:].zfill(2),instcfg))
     inst = ord(instcfg[0])
     if inst==self.__instrument:
         return
     self.__instrument = inst
     if inst:
         self.__kbd = self.__agent.create(self.__instrument,self.__usbname,self.__device)
예제 #5
0
파일: ezload.py 프로젝트: shamharoth/EigenD
def download(device, filename):
    code = resource.file_open(filename,'r').read()
    ez = picross.usbdevice(device, 0)
    ez_reset(ez)

    for line in code.splitlines():
        len,offset,type = int(line[1:3], 16), int(line[3:7], 16), int(line[7:9], 16)

        if type == ihx_eof:
            break

        if type != 0:
            raise RuntimeError('unexpected ihx record type %d' % type)

        hex = line[9:]
        bytes = [int(hex[x:x+2],16) for x in range(0,len*2,2)]
        ez_poke(ez, offset, ''.join(map(chr,bytes)))

    ez_run(ez)
예제 #6
0
 def __init__(self):
     self.dev = picross.usbdevice(picross.find(0xbeca, 0x0100), 0)
     self.dev.control(0x40, 0xb1, 0, 0)
예제 #7
0
파일: agentd.py 프로젝트: shamharoth/EigenD
 def __detect_instrument(self, usbname):
     if not self.__instrument and usbname:
         device = picross.usbdevice(usbname, 0)
         instcfg = device.control_in(0x40 | 0x80, 0xc6, 0, 0, 64)
         self.__instrument = ord(instcfg[0])
         device.close()
예제 #8
0
def load_firmware(dev, fw):
    device = picross.usbdevice(dev, 0)
    code = decode_mcs(fw)
    load(device, code)
    verify(device, code)
    fpga_reboot(device)