Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: T3.6 MIDI USB Host - querying "midi1.product"

  1. #1

    T3.6 MIDI USB Host - querying "midi1.product"

    Apologies for what is probably a rudimentary question. I'm using a Teensy 3.6 as a USB host with a MIDI device, I'm attempting to query "midi1.product" but am getting an error when compiling. I'm using the "USBHost_t36/MIDI/InputFunctions" example, and referencing the USBHost_t36.h file.

    Adding the following code to the "myNoteOn" section compiles and works fine:

    Code:
      Serial.println(midi1.idVendor());  
      Serial.println(midi1.idProduct());
    The following code gives an error:

    Code:
      Serial.println(midi1.product());
    The error is "no matching function for call to 'println(const uint8_t*)'"

    The relevant code from the header is:

    Code:
    // All USB device drivers inherit from this base class.
    class USBDriver : public USBHost {
    public:
    	operator bool() {
    		Device_t *dev = *(Device_t * volatile *)&device;
    		return dev != nullptr;
    	}
    	uint16_t idVendor() {
    		Device_t *dev = *(Device_t * volatile *)&device;
    		return (dev != nullptr) ? dev->idVendor : 0;
    	}
    	uint16_t idProduct() {
    		Device_t *dev = *(Device_t * volatile *)&device;
    		return (dev != nullptr) ? dev->idProduct : 0;
    	}
    	const uint8_t *manufacturer() {
    		Device_t *dev = *(Device_t * volatile *)&device;
    		if (dev == nullptr || dev->strbuf == nullptr) return nullptr;
    		return &dev->strbuf->buffer[dev->strbuf->iStrings[strbuf_t::STR_ID_MAN]];
    	}
    	const uint8_t *product() {
    		Device_t *dev = *(Device_t * volatile *)&device;
    		if (dev == nullptr || dev->strbuf == nullptr) return nullptr;
    		return &dev->strbuf->buffer[dev->strbuf->iStrings[strbuf_t::STR_ID_PROD]];
    	}
    	const uint8_t *serialNumber() {
    		Device_t *dev = *(Device_t * volatile *)&device;
    		if (dev == nullptr || dev->strbuf == nullptr) return nullptr;
    		return &dev->strbuf->buffer[dev->strbuf->iStrings[strbuf_t::STR_ID_SERIAL]];
    	}
    I suspect this is because the "*product()" variable is being defined as a constant, and I'm not calling it correctly. Could someone point me in the right direction here?

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,686
    Try this:

    Serial.println((const char *)midi1.product());

  3. #3
    Quote Originally Posted by PaulStoffregen View Post
    Try this:

    Serial.println((const char *)midi1.product());
    Works like a charm, thank you!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •