示例#1
0
def usb_write(device,endpt,bytes,timeout=TIMEOUT,msg="\t-> "):
    bb_util.debug_bytes(bytes,msg)
    try:
        bb_util.debug2(">bulkwrite")
        device.handle.bulkWrite(endpt, bytes, timeout)
        bb_util.debug2("<bulkwrite")
    except usb.USBError, error:
        bb_util.debug2("<bulkwrite(exc)")
        # ! osx returns an empty error (no errorno) so we justcan't check anything :-(
        if str(error) != "No error" and not (bb_osx.is_osx() and error.errno == None):
            bb_messenging.log("error: "+str(error))
            raise
示例#2
0
def usb_read(device,endpt,size=BUF_SIZE,timeout=TIMEOUT,msg="\t<- "):
    bytes=[]
    try:
        bb_util.debug2(">bulkread")
        bytes=device.handle.bulkRead(endpt, size, timeout)
        bb_util.debug2("<bulkread")
        bb_util.debug_bytes(bytes,msg)
    except usb.USBError, error:
        bb_util.debug2("<bulkread (exc)")
        # ! osx returns an empty error (no errorno) so we justcan't check anything :-(
        if str(error) != "No error" and not (bb_osx.is_osx() and error.errno == None):
            bb_messenging.log("error: "+str(error))
            raise
示例#3
0
def usb_write(device, endpt, bytes, timeout=TIMEOUT, msg="\t-> "):
    bb_util.debug_bytes(bytes, msg)
    try:
        bb_util.debug2(">bulkwrite")
        device.handle.bulkWrite(endpt, bytes, timeout)
        bb_util.debug2("<bulkwrite")
    except usb.USBError, error:
        bb_util.debug2("<bulkwrite(exc)")
        # ! osx returns an empty error (no errorno) so we justcan't check anything :-(
        if str(error) != "No error" and not (bb_osx.is_osx()
                                             and error.errno == None):
            bb_messenging.log("error: " + str(error))
            raise
示例#4
0
def usb_read(device, endpt, size=BUF_SIZE, timeout=TIMEOUT, msg="\t<- "):
    bytes = []
    try:
        bb_util.debug2(">bulkread")
        bytes = device.handle.bulkRead(endpt, size, timeout)
        bb_util.debug2("<bulkread")
        bb_util.debug_bytes(bytes, msg)
    except usb.USBError, error:
        bb_util.debug2("<bulkread (exc)")
        # ! osx returns an empty error (no errorno) so we justcan't check anything :-(
        if str(error) != "No error" and not (bb_osx.is_osx()
                                             and error.errno == None):
            bb_messenging.log("error: " + str(error))
            raise