def __write_read(self, write_fn, read_fn, ep): for data in (utils.get_array_data1(), utils.get_array_data2()): length = len(data) * data.itemsize try: ret = write_fn(ep, data, 1000) except NotImplementedError: return self.assertEqual(ret, length, 'Failed to write data: ' + \ str(data) + \ ', in EP = ' + \ str(ep)) try: ret = read_fn(ep | usb.util.ENDPOINT_IN, length, 1000) except NotImplementedError: return self.assertEqual(ret, data, 'Failed to read data: ' + \ str(data) + \ ', in EP = ' + \ str(ep))
def __write_read(self, write_fn, read_fn, ep): intf = self.backend.get_interface_descriptor(self.dev, 0, 0, 0).bInterfaceNumber for data in (utils.get_array_data1(), utils.get_array_data2()): length = len(data) * data.itemsize try: ret = write_fn(self.handle, ep, intf, data, 1000) except NotImplementedError: return self.assertEqual(ret, length, 'Failed to write data: ' + \ str(data) + \ ', in EP = ' + \ str(ep)) try: ret = read_fn(self.handle, ep | usb.util.ENDPOINT_IN, intf, length, 1000) except NotImplementedError: return self.assertEqual(ret, data, 'Failed to read data: ' + \ str(data) + \ ', in EP = ' + \ str(ep))
def make_data_list(length = 8): return (utils.get_array_data1(length), utils.get_array_data2(length), utils.get_list_data1(length), utils.get_list_data2(length), utils.get_str_data1(length), utils.get_str_data1(length))
def test_ctrl_transfer(self): for data in (utils.get_array_data1(), utils.get_array_data2()): length = len(data) * data.itemsize buff = usb.util.create_buffer(length) ret = self.backend.ctrl_transfer(self.handle, 0x40, devinfo.PICFW_SET_VENDOR_BUFFER, 0, 0, data, 1000) self.assertEqual(ret, length, 'Failed to write data: ' + str(data) + ', ' + str(length) + ' != ' + str(ret)) ret = self.backend.ctrl_transfer(self.handle, 0xC0, devinfo.PICFW_GET_VENDOR_BUFFER, 0, 0, buff, 1000) self.assertEqual(ret, length) self.assertEqual(buff, data, 'Failed to read data: ' + str(data) + ' != ' + str(ret))
def test_ctrl_transfer(self): for data in (utils.get_array_data1(), utils.get_array_data2()): length = len(data) * data.itemsize ret = self.handle.controlMsg( 0x40, devinfo.PICFW_SET_VENDOR_BUFFER, data, 0, 0, 1000) self.assertEqual(ret, length, 'Failed to write data: ' + str(data) + ', ' + str(length) + ' != ' + str(ret)) ret = self.handle.controlMsg( 0xC0, devinfo.PICFW_GET_VENDOR_BUFFER, length, 0, 0, 1000) self.assertEqual(ret, data, 'Failed to read data: ' + str(data) + ' != ' + str(ret))
def __write_read(self, write_fn, read_fn, ep, length = 8): intf = self.backend.get_interface_descriptor(self.dev, 0, 0, 0).bInterfaceNumber for data in (utils.get_array_data1(length), utils.get_array_data2(length)): length = len(data) * data.itemsize try: ret = write_fn(self.handle, ep, intf, data, 1000) except NotImplementedError: return self.assertEqual(ret, length, 'Failed to write data: ' + \ str(data) + \ ', in EP = ' + \ str(ep)) buff = usb.util.create_buffer(length) try: ret = read_fn(self.handle, ep | usb.util.ENDPOINT_IN, intf, buff, 1000) except NotImplementedError: return self.assertEqual(ret, length, str(ret) + ' != ' + str(length)) self.assertEqual(buff, data, 'Failed to read data: ' + \ str(data) + \ ', in EP = ' + \ str(ep)) if utils.is_windows(): time.sleep(0.5)
def test_ctrl_transfer(self): for data in (utils.get_array_data1(), utils.get_array_data2()): length = len(data) * data.itemsize ret = self.backend.ctrl_transfer(self.handle, 0x40, devinfo.CTRL_LOOPBACK_WRITE, 0, 0, data, 1000) self.assertEqual(ret, length, 'Failed to write data: ' + str(data)) ret = self.backend.ctrl_transfer(self.handle, 0xC0, devinfo.CTRL_LOOPBACK_READ, 0, 0, length, 1000) self.assertEqual( ret, data, 'Failed to read data: ' + str(data) + ' != ' + str(ret))
def __write_read(self, write_fn, read_fn, ep_out, ep_in): intf = self.backend.get_interface_descriptor(self.dev, 0, 0, 0).bInterfaceNumber for data in (utils.get_array_data1(), utils.get_array_data2()): ret = write_fn(self.handle, ep_out, intf, data, 1000) self.assertEqual(ret, len(data), 'Failed to write data: ' + \ str(data) + \ ', in EP = ' + \ str(ep_out)) ret = read_fn(self.handle, ep_in, intf, len(data), 1000) self.assertEqual(ret, data, 'Failed to read data: ' + \ str(data) + \ ', in EP = ' + \ str(ep_in))
def test_ctrl_transfer(self): for data in (utils.get_array_data1(), utils.get_array_data2()): length = len(data) * data.itemsize buff = usb.util.create_buffer(length) ret = self.backend.ctrl_transfer(self.handle, 0x40, devinfo.PICFW_SET_VENDOR_BUFFER, 0, 0, data, 1000) self.assertEqual( ret, length, 'Failed to write data: ' + str(data) + ', ' + str(length) + ' != ' + str(ret)) ret = self.backend.ctrl_transfer(self.handle, 0xC0, devinfo.PICFW_GET_VENDOR_BUFFER, 0, 0, buff, 1000) self.assertEqual(ret, length) self.assertEqual( buff, data, 'Failed to read data: ' + str(data) + ' != ' + str(ret))
def test_ctrl_transfer(self): for data in (utils.get_array_data1(), utils.get_array_data2()): ret = self.backend.ctrl_transfer(self.handle, 0x40, devinfo.CTRL_LOOPBACK_WRITE, 0, 0, data, 1000) self.assertEqual(ret, len(data), 'Failed to write data: ' + str(data)) ret = self.backend.ctrl_transfer(self.handle, 0xC0, devinfo.CTRL_LOOPBACK_READ, 0, 0, len(data), 1000) self.assertEqual(ret, data, 'Failed to read data: ' + str(data))
def __write_read(self, write_fn, read_fn, ep, length=8): intf = self.backend.get_interface_descriptor(self.dev, 0, 0, 0).bInterfaceNumber for data in (utils.get_array_data1(length), utils.get_array_data2(length)): length = len(data) * data.itemsize try: ret = write_fn(self.handle, ep, intf, data, 1000) except NotImplementedError: return self.assertEqual(ret, length, 'Failed to write data: ' + \ str(data) + \ ', in EP = ' + \ str(ep)) buff = usb.util.create_buffer(length) try: ret = read_fn(self.handle, ep | usb.util.ENDPOINT_IN, intf, buff, 1000) except NotImplementedError: return self.assertEqual(ret, length, str(ret) + ' != ' + str(length)) self.assertEqual(buff, data, 'Failed to read data: ' + \ str(data) + \ ', in EP = ' + \ str(ep)) if utils.is_windows(): time.sleep(0.5)
# NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR # MODIFICATIONS. # Integration tests import utils import unittest import usb.core import devinfo import usb._interop import usb.util import usb.backend.libusb0 as libusb0 import usb.backend.libusb1 as libusb1 import usb.backend.openusb as openusb data_list = (utils.get_array_data1(), utils.get_array_data2(), utils.get_list_data1(), utils.get_list_data2(), utils.get_str_data1(), utils.get_str_data1()) class DeviceTest(unittest.TestCase): def __init__(self, dev): unittest.TestCase.__init__(self) self.dev = dev def runTest(self): try: self.test_attributes() self.test_timeout() self.test_set_configuration() self.test_set_interface_altsetting()
# NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR # MODIFICATIONS. # Integration tests import utils import unittest import usb.core import devinfo import usb.util import usb.backend.libusb01 as libusb01 import usb.backend.libusb10 as libusb10 import usb.backend.openusb as openusb data_list = (utils.get_array_data1(), utils.get_array_data2(), utils.get_list_data1(), utils.get_list_data2(), utils.get_str_data1(), utils.get_str_data1()) class DeviceTest(unittest.TestCase): def __init__(self, dev): unittest.TestCase.__init__(self) self.dev = dev def runTest(self): try: self.test_attributes() self.test_timeout() self.test_set_configuration()
# MODIFICATIONS. # Integration tests import utils import unittest import usb.core import devinfo import usb._interop import usb.util import usb.backend.libusb0 as libusb0 import usb.backend.libusb1 as libusb1 import usb.backend.openusb as openusb data_list = (utils.get_array_data1(), utils.get_array_data2(), utils.get_list_data1(), utils.get_list_data2(), utils.get_str_data1(), utils.get_str_data1()) class DeviceTest(unittest.TestCase): def __init__(self, dev): unittest.TestCase.__init__(self) self.dev = dev def runTest(self): try: self.test_attributes() self.test_timeout() self.test_set_configuration()