Is there an easy way to have MIDI only, without serial?
amowry opened this issue · 4 comments
This library is great! I was wondering if there's a way to to turn off serial in order to make fully class-compliant devices, similar to the way Teensy works? Thanks!
Hi @amowry ,
removing the default Serial port could take from some minutes to some days of work, depending on the board you are targeting 🙂
We currently leave the CDC endpoint always on since it's the only way to upload a new sketch without pressing the reset button.
Okay, thanks—I did end up finding a way to remove the CDC by modifying the core files (I’m using a standalone 32u4). Assuming CDC is removed, should the library create a class-compliant device?
This patch should be enough to get rid of CDC on 32u4 and obtain a compliant MIDIUSB device
--- a/cores/arduino/USBCore.cpp
+++ b/cores/arduino/USBCore.cpp
@@ -331,10 +333,6 @@ int USB_Send(uint8_t ep, const void* d, int len)
uint16_t _initEndpoints[USB_ENDPOINTS] =
{
0, // Control Endpoint
-
- EP_TYPE_INTERRUPT_IN, // CDC_ENDPOINT_ACM
- EP_TYPE_BULK_OUT, // CDC_ENDPOINT_OUT
- EP_TYPE_BULK_IN, // CDC_ENDPOINT_IN
// Following endpoints are automatically initialized to 0
};
@@ -382,9 +380,6 @@ bool ClassInterfaceRequest(USBSetup& setup)
{
uint8_t i = setup.wIndex;
- if (CDC_ACM_INTERFACE == i)
- return CDC_Setup(setup);
-
#ifdef PLUGGABLE_USB_ENABLED
return PluggableUSB().setup(setup);
#endif
@@ -473,8 +468,6 @@ static uint8_t SendInterfaces()
{
uint8_t interfaces = 0;
- CDC_GetInterface(&interfaces);
-
#ifdef PLUGGABLE_USB_ENABLED
PluggableUSB().getInterface(&interfaces);
#endif
@@ -862,8 +855,8 @@ bool USBDevice_::wakeupHost()
return false;
}
-PluggableUSB_::PluggableUSB_() : lastIf(CDC_ACM_INTERFACE + CDC_INTERFACE_COUNT),
- lastEp(CDC_FIRST_ENDPOINT + CDC_ENPOINT_COUNT),
+PluggableUSB_::PluggableUSB_() : lastIf(0),
+ lastEp(0),
rootNode(NULL), totalEP(USB_ENDPOINTS)
{
// EmptyThe resulting descriptor is
sudo lsusb -vvv -d2341:8036
Bus 001 Device 060: ID 2341:8036 Arduino SA Leonardo (CDC ACM, HID)
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 239 Miscellaneous Device
bDeviceSubClass 2
bDeviceProtocol 1 Interface Association
bMaxPacketSize0 64
idVendor 0x2341 Arduino SA
idProduct 0x8036 Leonardo (CDC ACM, HID)
bcdDevice 1.00
iManufacturer 1 Arduino LLC
iProduct 2 Arduino Leonardo
iSerial 3 MIDI
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 0x006d
bNumInterfaces 2
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xa0
(Bus Powered)
Remote Wakeup
MaxPower 500mA
Interface Association:
bLength 8
bDescriptorType 11
bFirstInterface 0
bInterfaceCount 2
bFunctionClass 1 Audio
bFunctionSubClass 1 Control Device
bFunctionProtocol 0
iFunction 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 1 Audio
bInterfaceSubClass 1 Control Device
bInterfaceProtocol 0
iInterface 0
AudioControl Interface Descriptor:
bLength 9
bDescriptorType 36
bDescriptorSubtype 1 (HEADER)
bcdADC 1.00
wTotalLength 0x0009
bInCollection 1
baInterfaceNr(0) 1
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 1 Audio
bInterfaceSubClass 3 MIDI Streaming
bInterfaceProtocol 0
iInterface 0
MIDIStreaming Interface Descriptor:
bLength 7
bDescriptorType 36
bDescriptorSubtype 1 (HEADER)
bcdADC 1.00
wTotalLength 0x0041
MIDIStreaming Interface Descriptor:
bLength 6
bDescriptorType 36
bDescriptorSubtype 2 (MIDI_IN_JACK)
bJackType 1 Embedded
bJackID 1
iJack 0
MIDIStreaming Interface Descriptor:
bLength 6
bDescriptorType 36
bDescriptorSubtype 2 (MIDI_IN_JACK)
bJackType 2 External
bJackID 2
iJack 0
MIDIStreaming Interface Descriptor:
bLength 9
bDescriptorType 36
bDescriptorSubtype 3 (MIDI_OUT_JACK)
bJackType 1 Embedded
bJackID 3
bNrInputPins 1
baSourceID( 0) 2
BaSourcePin( 0) 1
iJack 0
MIDIStreaming Interface Descriptor:
bLength 9
bDescriptorType 36
bDescriptorSubtype 3 (MIDI_OUT_JACK)
bJackType 2 External
bJackID 4
bNrInputPins 1
baSourceID( 0) 1
BaSourcePin( 0) 1
iJack 0
Endpoint Descriptor:
bLength 9
bDescriptorType 5
bEndpointAddress 0x00 EP 0 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
bRefresh 0
bSynchAddress 0
MIDIStreaming Endpoint Descriptor:
bLength 5
bDescriptorType 37
bDescriptorSubtype 1 (GENERAL)
bNumEmbMIDIJack 1
baAssocJackID( 0) 1
Endpoint Descriptor:
bLength 9
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
bRefresh 0
bSynchAddress 0
MIDIStreaming Endpoint Descriptor:
bLength 5
bDescriptorType 37
bDescriptorSubtype 1 (GENERAL)
bNumEmbMIDIJack 1
baAssocJackID( 0) 3
can't get device qualifier: Resource temporarily unavailable
can't get debug descriptor: Resource temporarily unavailable
Device Status: 0x0000
(Bus Powered)
Thank you! Is this for an earlier version of USBCore.cpp? I don't see these lines:
`-PluggableUSB_::PluggableUSB_() : lastIf(CDC_ACM_INTERFACE + CDC_INTERFACE_COUNT),
-
lastEp(CDC_FIRST_ENDPOINT + CDC_ENPOINT_COUNT),`
However, I made the other changes and it seems to have removed CDC. I'm not sure how to tell for sure if it did it correctly ;) For anyone who is interested, the file can be put in the sketch folder, so it will only affect the given sketch.