Exemplo n.º 1
0
	def create_descriptors(self): #, high_speed=True):

		descriptors = DeviceDescriptorCollection()

		with descriptors.DeviceDescriptor() as d:
			d.idVendor  = VENDOR_ID
			d.idProduct = PRODUCT_ID

			d.iManufacturer = "ShareBrained"
			d.iProduct      = "Tedium X8"
			d.iSerialNumber = "deadbeef"

			d.bNumConfigurations = 1

		with descriptors.ConfigurationDescriptor() as c:
			with c.InterfaceDescriptor() as i:
				i.bInterfaceNumber = 0;

				# OUT descriptor
				# with i.EndpointDescriptor() as e:
				# 	e.bEndpointAddress = self.BULK_ENDPOINT_NUMBER | 0x00
				# 	e.wMaxPacketSize = self.MAX_BULK_PACKET_SIZE

				# IN descriptor
				with i.EndpointDescriptor() as e:
					e.bEndpointAddress = self.BULK_ENDPOINT_NUMBER | 0x80
					e.wMaxPacketSize = self.MAX_BULK_PACKET_SIZE

		return descriptors
Exemplo n.º 2
0
    def create_descriptors(self):
        """ Create the descriptors we want to use for our device. """

        descriptors = DeviceDescriptorCollection()

        #
        # We'll add the major components of the descriptors we we want.
        # The collection we build here will be necessary to create a standard endpoint.
        #

        # We'll need a device descriptor...
        with descriptors.DeviceDescriptor() as d:
            d.idVendor = VENDOR_ID
            d.idProduct = PRODUCT_ID

            d.iManufacturer = "GSG"
            d.iProduct = "Amalthea receiver"
            d.iSerialNumber = "no serial"

            d.bNumConfigurations = 1

        # ... and a description of the USB configuration we'll provide.
        with descriptors.ConfigurationDescriptor() as c:

            with c.InterfaceDescriptor() as i:
                i.bInterfaceNumber = 0

                with i.EndpointDescriptor() as e:
                    e.bEndpointAddress = 0x80 | BULK_ENDPOINT_NUMBER
                    e.wMaxPacketSize = MAX_BULK_PACKET_SIZE

        return descriptors
Exemplo n.º 3
0
    def create_descriptors(self):
        """ Create the descriptors we want to use for our device. """

        descriptors = DeviceDescriptorCollection()

        #
        # We'll add the major components of the descriptors we we want.
        # The collection we build here will be necessary to create a standard endpoint.
        #

        # We'll need a device descriptor...
        with descriptors.DeviceDescriptor() as d:
            d.idVendor           = 0x16d0
            d.idProduct          = 0xf3b

            d.iManufacturer      = "LUNA"
            d.iProduct           = "Fancy USB-Controlled LEDs"
            d.iSerialNumber      = "1234"

            d.bNumConfigurations = 1


        # ... and a description of the USB configuration we'll provide.
        with descriptors.ConfigurationDescriptor() as c:

            with c.InterfaceDescriptor() as i:
                i.bInterfaceNumber = 0

                with i.EndpointDescriptor() as e:
                    e.bEndpointAddress = 0x01
                    e.wMaxPacketSize   = 64

        return descriptors
Exemplo n.º 4
0
    def create_descriptors(self):
        """ Create the descriptors we want to use for our device. """

        descriptors = DeviceDescriptorCollection()

        #
        # We'll add the major components of the descriptors we we want.
        # The collection we build here will be necessary to create a standard endpoint.
        #

        # We'll need a device descriptor...
        with descriptors.DeviceDescriptor() as d:
            d.idVendor = 0x16d0
            d.idProduct = 0x05a5

            d.iManufacturer = "LUNA"
            d.iProduct = "Integrated Logic Analyzer"
            d.iSerialNumber = "no serial"

            d.bNumConfigurations = 1

        # ... and a description of the USB configuration we'll provide.
        with descriptors.ConfigurationDescriptor() as c:

            with c.InterfaceDescriptor() as i:
                i.bInterfaceNumber = 0

                with i.EndpointDescriptor() as e:
                    e.bEndpointAddress = 0x80 | self.BULK_ENDPOINT_NUMBER
                    e.wMaxPacketSize = self._max_packet_size

        return descriptors
Exemplo n.º 5
0
    def create_descriptors(self):
        """ Create the descriptors we want to use for our device. """

        descriptors = DeviceDescriptorCollection()

        #
        # We'll add the major components of the descriptors we we want.
        # The collection we build here will be necessary to create a standard endpoint.
        #

        # We'll need a device descriptor...
        with descriptors.DeviceDescriptor() as d:
            d.idVendor = 0x16d0
            d.idProduct = 0xf3b

            d.iManufacturer = "LUNA"
            d.iProduct = "Isochronous IN Test"
            d.iSerialNumber = "no serial"

            d.bNumConfigurations = 1

        # ... and a description of the USB configuration we'll provide.
        with descriptors.ConfigurationDescriptor() as c:

            with c.InterfaceDescriptor() as i:
                i.bInterfaceNumber = 0

                with i.EndpointDescriptor() as e:
                    e.bmAttributes = USBTransferType.ISOCHRONOUS
                    e.bEndpointAddress = 0x80 | self.ISO_ENDPOINT_NUMBER
                    e.wMaxPacketSize = self.TRANSFERS_PER_MICROFRAME | self.MAX_ISO_PACKET_SIZE
                    e.bInterval = 1

        return descriptors
Exemplo n.º 6
0
    def create_descriptors(self):
        descriptors = DeviceDescriptorCollection()
        with descriptors.DeviceDescriptor() as d:
            d.idVendor = self._idVendor
            d.idProduct = self._idProduct

            d.iManufacturer = self._manufacturer_string
            d.iProduct = self._product_string
            d.iSerialNumber = self._serial_number

            d.bNumConfigurations = 1
        with descriptors.ConfigurationDescriptor() as c:
            with c.InterfaceDescriptor() as i:
                i.bInterfaceNumber = 0

                i.bInterfaceClass = 0x03  # HID
                i.bInterfaceSubclass = 0x00  # No SubClass
                i.bInterfaceProtocol = 0x00  # No Protocol

                i.iInterface = 0x00

                hid_header = HIDDescriptor(descriptors)
                if self._hid_report:
                    hid_header.add_report_raw(self._hid_report)
                else:
                    hid_header.add_report_item(HIDPrefix.USAGE_PAGE,
                                               self._usage_page)
                    hid_header.add_report_item(HIDPrefix.USAGE, self._usage)
                    hid_header.add_report_item(HIDPrefix.COLLECTION, 0x01)
                    for (signal, input_range, usage) in self.inputs:
                        hid_header.add_report_item(
                            HIDPrefix.LOGICAL_MIN,
                            *self._int_to_le_bytes(input_range.start))
                        hid_header.add_report_item(
                            HIDPrefix.LOGICAL_MAX,
                            *self._int_to_le_bytes(input_range.stop))
                        hid_header.add_report_item(
                            HIDPrefix.REPORT_SIZE,
                            *self._int_to_le_bytes(signal.shape().width))
                        hid_header.add_report_item(HIDPrefix.REPORT_COUNT,
                                                   0x01),
                        hid_header.add_report_item(HIDPrefix.USAGE, usage)
                        hid_header.add_input_item()
                    hid_header.add_report_item(HIDPrefix.END_COLLECTION)

                i.add_subordinate_descriptor(hid_header)

                with i.EndpointDescriptor() as e:
                    e.bEndpointAddress = 0x80 | self._STATUS_ENDPOINT_NUMBER
                    e.bmAttributes = USBTransferType.INTERRUPT
                    e.wMaxPacketSize = self._max_packet_size
                    e.bInterval = 1

        return descriptors
Exemplo n.º 7
0
    def create_descriptors(self):

        descriptors = DeviceDescriptorCollection()

        with descriptors.DeviceDescriptor() as d:
            d.idVendor = VENDOR_ID
            d.idProduct = PRODUCT_ID

            d.iManufacturer = "ShareBrained"
            d.iProduct = "Tedium X8"
            d.iSerialNumber = "deadbeef"

            d.bNumConfigurations = 1

        with descriptors.ConfigurationDescriptor() as c:

            with c.InterfaceDescriptor() as i:
                i.bInterfaceNumber = 0

                with i.EndpointDescriptor() as e:
                    e.bEndpointAddress = USBDirection.IN.to_endpoint_address(
                        INTERRUPT_ENDPOINT_NUMBER)
                    e.wMaxPacketSize = MAX_INTERRUPT_PACKET_SIZE
                    e.bmAttributes = USBTransferType.INTERRUPT

                    # Request that we be polled once ber microseconds (2 ^ 3 microframes).
                    e.bInterval = 4

            with c.InterfaceDescriptor() as i:
                i.bInterfaceNumber = 1
                i.bAlternateSetting = 0

            with c.InterfaceDescriptor() as i:
                i.bInterfaceNumber = 1
                i.bAlternateSetting = 1

                with i.EndpointDescriptor() as e:
                    e.bEndpointAddress = USBDirection.IN.to_endpoint_address(
                        ISO_ENDPOINT_NUMBER)
                    e.wMaxPacketSize = (
                        TRANSFERS_PER_MICROFRAME << 11) | MAX_ISO_PACKET_SIZE
                    e.bmAttributes = USBTransferType.ISOCHRONOUS

                    e.bInterval = 1

                # with i.EndpointDescriptor() as e:
                # 	e.bEndpointAddress = USBDirection.OUT.to_endpoint_address(ISO_ENDPOINT_NUMBER)
                # 	e.wMaxPacketSize   = (TRANSFERS_PER_MICROFRAME << 11) | MAX_ISO_PACKET_SIZE
                # 	e.bmAttributes     = USBTransferType.ISOCHRONOUS

                # 	e.bInterval        = 1

        return descriptors
Exemplo n.º 8
0
    def provision_dut(self, dut):
        self.descriptors = descriptors = DeviceDescriptorCollection()

        with descriptors.DeviceDescriptor() as d:
            d.idVendor = 0x16d0
            d.idProduct = 0xf3b

            d.iManufacturer = "LUNA"
            d.iProduct = "Test Device"
            d.iSerialNumber = "1234"

            d.bNumConfigurations = 1

        with descriptors.ConfigurationDescriptor() as c:

            with c.InterfaceDescriptor() as i:
                i.bInterfaceNumber = 0

                with i.EndpointDescriptor() as e:
                    e.bEndpointAddress = 0x01
                    e.wMaxPacketSize = 512

                with i.EndpointDescriptor() as e:
                    e.bEndpointAddress = 0x81
                    e.wMaxPacketSize = 512

        dut.add_standard_control_endpoint(descriptors)
Exemplo n.º 9
0
    def provision_dut(self, dut):
        self.descriptors = descriptors = DeviceDescriptorCollection()

        with descriptors.DeviceDescriptor() as d:
            d.idVendor  = 0x16d0
            d.idProduct = 0x0f3b
            d.iManufacturer = "ShareBrained"
            d.iProduct      = "Tedium X8"
            d.iSerialNumber = "deadbeef"
            d.bNumConfigurations = 1

        with descriptors.ConfigurationDescriptor() as c:

            with c.InterfaceDescriptor() as i:
                i.bInterfaceNumber = 0

                with i.EndpointDescriptor() as e:
                    e.bEndpointAddress = USBDirection.IN.to_endpoint_address(1)
                    e.wMaxPacketSize   = 64
                    e.bmAttributes     = USBTransferType.INTERRUPT
                    e.bInterval        = 4

            with c.InterfaceDescriptor() as i:
                i.bInterfaceNumber = 1
                i.bAlternateSetting = 0

            with c.InterfaceDescriptor() as i:
                i.bInterfaceNumber = 1
                i.bAlternateSetting = 1

                with i.EndpointDescriptor() as e:
                    e.bEndpointAddress = USBDirection.IN.to_endpoint_address(2)
                    e.wMaxPacketSize   = (1 << 11) | 24
                    e.bmAttributes     = USBTransferType.ISOCHRONOUS
                    e.bInterval        = 1

            with c.InterfaceDescriptor() as i:
                i.bInterfaceNumber = 2
                i.bAlternateSetting = 0

            with c.InterfaceDescriptor() as i:
                i.bInterfaceNumber = 2
                i.bAlternateSetting = 1

                with i.EndpointDescriptor() as e:
                    e.bEndpointAddress = USBDirection.OUT.to_endpoint_address(3)
                    e.wMaxPacketSize   = (1 << 11) | 24
                    e.bmAttributes     = USBTransferType.ISOCHRONOUS
                    e.bInterval        = 1

            # TODO: Force the number of interfaces to "2", as two of the interfaces have multiple
            # alternate settings, and the USB protocol library doesn't seem to care about this.
            from usb_protocol.types.descriptors import StandardDescriptorNumbers
            assert(c._type_counts[StandardDescriptorNumbers.INTERFACE]) == 5
            c._type_counts[StandardDescriptorNumbers.INTERFACE] = 3
            assert(c._type_counts[StandardDescriptorNumbers.INTERFACE]) == 3

        dut.add_standard_control_endpoint(descriptors)
Exemplo n.º 10
0
    def create_descriptors(self):
        """ Create the descriptors we want to use for our device. """

        descriptors = DeviceDescriptorCollection()

        #
        # We'll add the major components of the descriptors we we want.
        # The collection we build here will be necessary to create a standard endpoint.
        #

        # We'll need a device descriptor...
        with descriptors.DeviceDescriptor() as d:
            d.idVendor           = 0x16d0
            d.idProduct          = 0xf3b

            d.iManufacturer      = "LUNA"
            d.iProduct           = "Status interrupt mechanism"
            d.iSerialNumber      = "1234"

            d.bNumConfigurations = 1


        # ... and a description of the USB configuration we'll provide.
        with descriptors.ConfigurationDescriptor() as c:

            with c.InterfaceDescriptor() as i:
                i.bInterfaceNumber = 0

                # Single in endpoint, EP1/IN.
                with i.EndpointDescriptor() as e:
                    e.bEndpointAddress = 0x81
                    e.wMaxPacketSize   = 64
                    e.bmAttributes     = USBTransferType.INTERRUPT

                    # Request that we be polled once ber microseconds (2 ^ 3 microframes).
                    e.bInterval        = 4


        return descriptors
Exemplo n.º 11
0
Arquivo: acm.py Projeto: yhetti/luna
    def create_descriptors(self):
        """ Creates the descriptors that describe our serial topology. """

        descriptors = DeviceDescriptorCollection()

        # Create a device descriptor with our user parameters...
        with descriptors.DeviceDescriptor() as d:
            d.idVendor = self._idVendor
            d.idProduct = self._idProduct

            d.iManufacturer = self._manufacturer_string
            d.iProduct = self._product_string
            d.iSerialNumber = self._serial_number

            d.bNumConfigurations = 1

        # ... and then describe our CDC-ACM setup.
        with descriptors.ConfigurationDescriptor() as c:

            # First, we'll describe the Communication Interface, which contains most
            # of our description; but also an endpoint that does effectively nothing in
            # our case, since we don't have interrupts we want to send up to the host.
            with c.InterfaceDescriptor() as i:
                i.bInterfaceNumber = 0

                i.bInterfaceClass = 0x02  # CDC
                i.bInterfaceSubclass = 0x02  # ACM
                i.bInterfaceProtocol = 0x01  # AT commands / UART

                # Provide the default CDC version.
                i.add_subordinate_descriptor(cdc.HeaderDescriptorEmitter())

                # ... specify our interface associations ...
                union = cdc.UnionFunctionalDescriptorEmitter()
                union.bControlInterface = 0
                union.bSubordinateInterface0 = 1
                i.add_subordinate_descriptor(union)

                # ... and specify the interface that'll carry our data...
                call_management = cdc.CallManagementFunctionalDescriptorEmitter(
                )
                call_management.bDataInterface = 1
                i.add_subordinate_descriptor(call_management)

                # CDC communications endpoint
                with i.EndpointDescriptor() as e:
                    e.bEndpointAddress = 0x80 | self._STATUS_ENDPOINT_NUMBER
                    e.bmAttributes = 0x03
                    e.wMaxPacketSize = self._max_packet_size
                    e.bInterval = 11

            # Finally, we'll describe the communications interface, which just has the
            # endpoints for our data in and out.
            with c.InterfaceDescriptor() as i:
                i.bInterfaceNumber = 1
                i.bInterfaceClass = 0x0a  # CDC data
                i.bInterfaceSubclass = 0x00
                i.bInterfaceProtocol = 0x00

                # Data IN to host (tx, from our side)
                with i.EndpointDescriptor() as e:
                    e.bEndpointAddress = 0x80 | self._DATA_ENDPOINT_NUMBER
                    e.wMaxPacketSize = self._max_packet_size

                # Data OUT from host (rx, from our side)
                with i.EndpointDescriptor() as e:
                    e.bEndpointAddress = self._DATA_ENDPOINT_NUMBER
                    e.wMaxPacketSize = self._max_packet_size

        return descriptors
Exemplo n.º 12
0
    def create_descriptors(self):
        """ Creates the descriptors that describe our MIDI topology. """

        descriptors = DeviceDescriptorCollection()

        # Create a device descriptor with our user parameters...
        with descriptors.DeviceDescriptor() as d:
            d.bcdUSB = 2.00
            d.bDeviceClass = 0xEF
            d.bDeviceSubclass = 0x02
            d.bDeviceProtocol = 0x01
            d.idVendor = 0x16d0
            d.idProduct = 0x0f3b

            d.iManufacturer = "N/A"
            d.iProduct = "JT51-Synth"
            d.iSerialNumber = "0001"
            d.bcdDevice = 0.01

            d.bNumConfigurations = 1

        with descriptors.ConfigurationDescriptor() as configDescr:
            interface = midi1.StandardMidiStreamingInterfaceDescriptorEmitter()
            interface.bInterfaceNumber = 0
            interface.bNumEndpoints = 2 if self.with_midi_in else 1
            configDescr.add_subordinate_descriptor(interface)

            streamingInterface = midi1.ClassSpecificMidiStreamingInterfaceDescriptorEmitter(
            )

            if self.with_midi_in:
                outToHostJack = midi1.MidiOutJackDescriptorEmitter()
                outToHostJack.bJackID = 1
                outToHostJack.bJackType = midi1.MidiStreamingJackTypes.EMBEDDED
                outToHostJack.add_source(2)
                streamingInterface.add_subordinate_descriptor(outToHostJack)

                inToDeviceJack = midi1.MidiInJackDescriptorEmitter()
                inToDeviceJack.bJackID = 2
                inToDeviceJack.bJackType = midi1.MidiStreamingJackTypes.EXTERNAL
                streamingInterface.add_subordinate_descriptor(inToDeviceJack)

            inFromHostJack = midi1.MidiInJackDescriptorEmitter()
            inFromHostJack.bJackID = 3
            inFromHostJack.bJackType = midi1.MidiStreamingJackTypes.EMBEDDED
            streamingInterface.add_subordinate_descriptor(inFromHostJack)

            outFromDeviceJack = midi1.MidiOutJackDescriptorEmitter()
            outFromDeviceJack.bJackID = 4
            outFromDeviceJack.bJackType = midi1.MidiStreamingJackTypes.EXTERNAL
            outFromDeviceJack.add_source(3)
            streamingInterface.add_subordinate_descriptor(outFromDeviceJack)

            outEndpoint = midi1.StandardMidiStreamingBulkDataEndpointDescriptorEmitter(
            )
            outEndpoint.bEndpointAddress = USBDirection.OUT.to_endpoint_address(
                1)
            outEndpoint.wMaxPacketSize = self.MAX_PACKET_SIZE
            streamingInterface.add_subordinate_descriptor(outEndpoint)

            outMidiEndpoint = midi1.ClassSpecificMidiStreamingBulkDataEndpointDescriptorEmitter(
            )
            outMidiEndpoint.add_associated_jack(3)
            streamingInterface.add_subordinate_descriptor(outMidiEndpoint)

            if self.with_midi_in:
                inEndpoint = midi1.StandardMidiStreamingDataEndpointDescriptorEmitter(
                )
                inEndpoint.bEndpointAddress = USBDirection.IN.from_endpoint_address(
                    1)
                inEndpoint.wMaxPacketSize = self.MAX_PACKET_SIZE
                streamingInterface.add_subordinate_descriptor(inEndpoint)

                inMidiEndpoint = midi1.ClassSpecificMidiStreamingBulkDataEndpointDescriptorEmitter(
                )
                inMidiEndpoint.add_associated_jack(1)
                streamingInterface.add_subordinate_descriptor(inMidiEndpoint)

            configDescr.add_subordinate_descriptor(streamingInterface)

            if self._use_ila:
                with configDescr.InterfaceDescriptor() as i:
                    i.bInterfaceNumber = 1

                    with i.EndpointDescriptor() as e:
                        e.bEndpointAddress = USBDirection.IN.to_endpoint_address(
                            3)  # EP 3 IN
                        e.wMaxPacketSize = self.MAX_PACKET_SIZE

        return descriptors