@KurtE @mjs513 - Was able to duplicate the problem with MTP and the PI writable directory. It shows empty:
View attachment 29329
I'll see if I can figure out what it is...
Edit: Just put it in my Linux machine and checked the properties of the writable directory:
View attachment 29330
You will see that some directories are unreadable. That could be why nothing is showing up...
Thanks for checking but the interesting thing is that it is showing 225K items on disk at 5.9gb. In our case its shows almost nothing used and only 2 folders and the whole disk is free.??? even your MTP shows no folders and no files - its empty
#include <SD.h>
#include <MTP_Teensy.h>
#define CS_SD BUILTIN_SDCARD // Works on T_3.6 and T_4.1
//#define CS_SD 10 // Works on SPI with this CS pin
void setup()
{
// mandatory to begin the MTP session.
MTP.begin();
// Add SD Card
SD.begin(CS_SD);
MTP.addFilesystem(SD, "SD Card");
}
void loop() {
MTP.loop(); //This is mandatory to be placed in the loop code.
}
Which mouse/keyboard? Normal or pro g?@KurtE - Just setup TD1.58B2. I have a library called TeensyMiniOS that I have been playing with for testing. When I added TeensyEXT4V3 to it with TD1.57 I ran out of memory for local variables to the tune of 15k bytes. Recompiling it with TD1.58B2 it was +23K so it is more memory efficient But the mouse no longer works at all Will have to test and figure that out. I think I will also test the RA8876Teensy library. First though will play with MTP.
Edit - This is with a Logitech wireless mouse and keyboard. Moving the mouse sketch shows keypresses and left button shows keypress and release 1, right button 2.
hidclaim_t KeyboardController::claim_collection(USBHIDParser *driver, Device_t *dev, uint32_t topusage)
{
// Lets try to claim a few specific Keyboard related collection/reports
USBHDBGSerial.printf("KeyboardController::claim_collection(%p) Driver:%p(%u %u) Dev:%p Top:%x\n", this, driver,
driver->interfaceSubClass(), driver->interfaceProtocol(), dev, topusage);
// only claim from one physical device
// Lets only claim if this is the same device as claimed Keyboard...
//USBHDBGSerial.printf("\tdev=%p mydevice=%p\n", dev, mydevice);
if (mydevice != NULL && dev != mydevice) return CLAIM_NO;
// We will not claim boot mouse
[COLOR="#FF0000"] if ((driver->interfaceSubClass() == 1) && (driver->interfaceProtocol() == 2)) return CLAIM_NO;
[/COLOR]
// We will claim if BOOT Keyboard.
if (((driver->interfaceSubClass() == 1) && (driver->interfaceProtocol() == 1))
|| (topusage == TOPUSAGE_KEYBOARD))
It reproduced on my K350...
If you get a chance you might try:
Try adding that RED line. May do it cleaner but the idea is that make sure we don't claim any HID reports when driver InterfaceProtocol is MouseCode:hidclaim_t KeyboardController::claim_collection(USBHIDParser *driver, Device_t *dev, uint32_t topusage) { // Lets try to claim a few specific Keyboard related collection/reports USBHDBGSerial.printf("KeyboardController::claim_collection(%p) Driver:%p(%u %u) Dev:%p Top:%x\n", this, driver, driver->interfaceSubClass(), driver->interfaceProtocol(), dev, topusage); // only claim from one physical device // Lets only claim if this is the same device as claimed Keyboard... //USBHDBGSerial.printf("\tdev=%p mydevice=%p\n", dev, mydevice); if (mydevice != NULL && dev != mydevice) return CLAIM_NO; // We will not claim boot mouse [COLOR="#FF0000"] if ((driver->interfaceSubClass() == 1) && (driver->interfaceProtocol() == 2)) return CLAIM_NO; [/COLOR] // We will claim if BOOT Keyboard. if (((driver->interfaceSubClass() == 1) && (driver->interfaceProtocol() == 1)) || (topusage == TOPUSAGE_KEYBOARD))
#include <MTP_Teensy.h>
#include <SD.h>
#define CS_SD BUILTIN_SDCARD // Works on T_3.6 and T_4.1
void setup()
{
uint32_t t1 = millis(); // Setup start time
Serial.begin(9600);
uint32_t t2 = millis(); // Serial ready time
MTP.begin(); // mandatory to begin the MTP session.
uint32_t t3 = millis(); // MTP ready time
delay(5000); // just wait so we can see the print after we start the terminal
Serial.printf("Start = %u ms ; Serial ready = %u ms ; MTP ready = %u ms \n", t1, t2, t3);
// Add SD Card
SD.begin(CS_SD);
}
void loop() {
MTP.loop(); //This is mandatory to be placed in the loop code.
if(Serial.available() && Serial.read() == 'S')
{
MTP.addFilesystem(SD, "SD Card");
Serial.println("Adding Filesystem!");
while(Serial.available()) Serial.read(); // empty input buffer
}
}
...
I have been using the latest version from the repo and TD1.57. I would like to be able to only activate the MTP functionality when the user sends a specific "Switch MTP ON command", which would begin the MTP service and add a file system. However, it seems like if I don't place the MTP.begin() in the start of setup() code and add a filesystem right away, Teensy takes a long time ...
Is this a known issue? Should I change something in my code to make it work? Thank you very much!
void stopLogging() {
Serial.println("\nStopped Logging Data!!!");
write_data = false;
// Closes the data file.
dataFile.close();
Serial.printf("Records written = %d\n", record_count);
MTP.send_DeviceResetEvent();
}