wwatson
Well-known member
Maybe that test case is not updated yet...
We changed the MTPD to be MTP object..
Will check it and update the sketch
Thanks I know things were changed but could not find it.
Maybe that test case is not updated yet...
We changed the MTPD to be MTP object..
Will check it and update the sketch
@wwatson Pushed up changes for that sketch
Hi,
this MTP-Thing is looking like a dream!
Just a thought, if not yet implemented: Could you implement something like MtpServer.activate() and MtpServer.sleep()?
The idea is to have a simple means to prevent this server from blocking Teensy and SD-card for tight timing jobs.
What a nightmare, if Windows decides to do a virus scan or just a directory update or whatever....
Christof
Except for the MSC part, for the MTP part, there is NO way Windows can decide to do a virus scan. The protocol does not foresee this.What a nightmare, if Windows decides to do a virus scan or just a directory update or whatever....
You always can unmount/mount teensy in unix and deinstall/install Teensy portable device with the device manager (it does not touched the com line)Not sure there is a way to disconnect/Sleep() and restart/Activate() without a Teensy Restart - but that code isn't something I looked at WRT code/function - just observed in use.
// Restarts the USB link to PC. The PC notices this and has the Teensy
// rebuild the file data base so that new entries get displayed
#define USE_EVENTS 0
void CMRM(void *cmdline) {
#if USE_EVENTS==1
Serial.println("MTP Reset");
mtpd.send_DeviceResetEvent(); // my older MTP code doesn't support events
#else
Serial.println("Reconnect serial port or restart Serial Monitor after USB reset.");
delay(100);
usb_init(); // shuts down USB if already started, then restarts
delay(200);
Serial.begin(9600);
delay(200);
Serial.println("USB disconnected and reconnected to force MTP update");
#endif
}
I solved the problem of forcing the PC to notice changes in the MTP disk by using usb_init() to stop and restart the USB link. This has the disadvantage of breaking the USB Serial comms link, which means that the PC Host program has to reopen the serial link.
...
Thanks, I'll add that option for 'usb_init()' to MakeFiles.ino options menu. I saw something in one of the other test sketches - but wasn't sure I saw it work - and it seemed to be some other mechanism.
LittleFS_RAM lfsRam;
...
lfsRam.begin(4000000l);
...
uint32_t index = MTP.AddFilesystem(lfsRam, "RAM");
MTP.useFileSystemIndexFileStore(index);
...
As you mentioned, a lot of this might be made a lot easier if we were using some form of threads or tasks. So far I have not gone that way with any of the code here as so far there is no standard agreed upon way to do this yet on the Teensy.Some miscellaneous thoughts:
1. It seems that running MTP as a thread or pseudo-thread, might solve a lot of the issues with the host PC timing out. The pseudo-thread could have the MTP Loop function called from an interval timer set up by mtp.begin(). To make sure that the loop function will not absorb too much CPU time it might need to be rewritten to save status and exit when waiting on asynchronous USB or file write operations.
2. For the picture viewer, scaling is something that can be done in the background by the PXP once you have a bitmap in memory. Scaling a VGA-size image to QVGA for the ili9341 takes about 25mSec on a T4.1 at 600mHz. The PXP can also handle the conversion from a YUV bitmap to RGB565 for an iLI9341. For a recent camera project, I used the 1LI9341 as a viewfinder. I was able to make updating the viewfinder a totally background process by starting with the CSI end-of-frame interrupt to begin the scaling in the PXP, then using the PXP_done interrupt to start an asynchronous update of the ILI9341 display. The main problem was figuring out how to keep the CSI and PXP from messing up the image when they were both trying to access EXTMEM. I simply shut down the CSI while the PXP was running---which cut my frame rate from 30FPS to 15.
@@@@@@@@@@@@@@@ NEW Drives @@@@@@@@@@@
## new drive
USB Drive: 0 connected
msc # Partition Table
part,boot,bgnCHS[3],type,endCHS[3],start,length
FAT32: 1,0,0x82,0x3,0x0,0xB,0xFE,0xFF,0xD2,8192,15719443
pt_#0: 2,0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0,0
pt_#0: 3,0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0,0
pt_#0: 4,0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0,0
Try Partition list
PART Type Start Count (MBR Part) Volume Type
1 M 8192 15719443 0 0 Fat32:
@@@@@@@@@@@@@@@ NEW Drives Completed. @@@@@@@@@@@
Found new Volume:0
*MTP_class::send_Event(4004) 30001
*MTP_class::send_Event(4004) 30001
3633 RESP:2001(RSP:OK)l: 12 T:7
@@@@@@@@@@@@@@@ NEW Drives @@@@@@@@@@@
## new drive
USB Drive: 0 connected
msc # Partition Table
part,boot,bgnCHS[3],type,endCHS[3],start,length
pt_#1: 1,0,0xFF,0xFF,0xFF,0x1,0xFF,0xFF,0xFF,1,14328
pt_#0: 2,0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0,0
pt_#0: 3,0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0,0
pt_#0: 4,0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0,0
Try Partition list
PART Type Start Count (MBR Part) Volume Type
1 M 1 14328 0 0 Fat16:
@@@@@@@@@@@@@@@ NEW Drives Completed. @@@@@@@@@@@
//------------------------------------------------------------------------------
/**
* Set FAT12_SUPPORT nonzero to enable use if FAT12 volumes.
* FAT12 has not been well tested and requires additional flash.
*/
#ifndef FAT12_SUPPORT
#define FAT12_SUPPORT 1
#endif // FAT12_SUPPORT
if (!pbs /*|| bpb->fatCount != 2 */|| getLe16(bpb->bytesPerSector) != 512) {
DBG_FAIL_MACRO;
goto fail;
}
// directory start for FAT16 dataStart for FAT32
m_rootDirStart = m_fatStartSector + bpb->fatCount * m_sectorsPerFat;
*** end Interval Timer ***
loop:3634 CMD: 1005(GET_STORAGE_INFO)l: 16 T:6 : 10001
65537 0 name:RAM
3634 RESP:2001(RSP:OK)l: 12 T:6
*** Device HID1 239a:80ae - connected ***
manufacturer: PJRC
product: Teensy 4.1
Serial: 2F057F67D28111299000005002004200
*** Device KB1 239a:80ae - connected ***
manufacturer: PJRC
product: Teensy 4.1
Serial: 2F057F67D28111299000005002004200
*** HID Device Mouse1 239a:80ae - connected ***
manufacturer: PJRC
product: Teensy 4.1
Serial: 2F057F67D28111299000005002004200
PFsVolume::begin(2000d83c, 1)
// FAT type is determined by cluster count
if (clusterCount < 4085) {
m_fatType = 12;
if (!FAT12_SUPPORT) {
DBG_FAIL_MACRO;
goto fail;
}
msc # Partition Table
part,boot,bgnCHS[3],type,endCHS[3],start,length
FAT12: 1,0,0xFF,0xFF,0xFF,0x1,0xFF,0xFF,0xFF,1,14328
pt_#0: 2,0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0,0
pt_#0: 3,0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0,0
pt_#0: 4,0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0,0
Try Partition list
PART Type Start Count (MBR Part) Volume Type
1 M 1 14328 0 0
bytesPerSector:512
sectorsPerCluster:2
reservedSectorCount:1
fatCount:1
rootDirEntryCount:512
totalSectors16:14328
mediaType:248
sectorsPerFat16:28
sectorsPerTrtack:63
headCount:255
hidddenSectors:1
totalSectors32:0
sectorsPerFat32:2687104
fat32Flags:8448
fat32Version:20204
fat32RootCluster:1095639119
fat32FSInfoSector:17741
fat32BackBootSector:8224
physicalDriveNumber:0
extSignature:0
volumeSerialNumber:0
Before sectorsPerCluster
tot sec:14328 shift:1 cluster count: [B]7133 [/B]Fat16:
tot sec:2040 shift:0 cluster count: 2001 Fat12:
Menu Options:
1 - List USB Drives (Step 1)
2 - Select USB Drive
l - List files on disk
e - Erase files on disk
r - reset MTP
h - Menu
*** end Interval Timer ***
loop:3660 CMD: 1005(GET_STORAGE_INFO)l: 16 T:6 : 10001
65537 0 name:RAM
3660 RESP:2001(RSP:OK)l: 12 T:6
*** Device HID1 239a:80f2 - connected ***
manufacturer: Adafruit
product: Feather RP2040
Serial: 463638383513980C
*** Device KB1 239a:80f2 - connected ***
manufacturer: Adafruit
product: Feather RP2040
Serial: 463638383513980C
@@@@@@@@@@@@@@@ NEW Drives @@@@@@@@@@@
## new drive
USB Drive: 0 connected
msc # Partition Table
part,boot,bgnCHS[3],type,endCHS[3],start,length
FAT12: 1,0,0xFF,0xFF,0xFF,0x1,0xFF,0xFF,0xFF,1,14336
pt_#0: 2,0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0,0
pt_#0: 3,0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0,0
pt_#0: 4,0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0,0
Try Partition list
PART Type Start Count (MBR Part Type) Volume Type
1 M 1 14336 0 0 1 Fat12:
@@@@@@@@@@@@@@@ NEW Drives Completed. @@@@@@@@@@@
Found new Volume:0[CODE]
$$USerial:4608
$$USerial:4640
$$USerial:4672
$$USerial:4704
$$USerial:4736
$$USerial:4768
$$USerial:4800
$$USerial:4832
$$USerial:4864