Teensy frezees during reading of file if USB drive is removed

Popescu

New member
Hello there!

I am working on a project (sorry in advance, but I'm not allowed to post the code) using a Teensy 4.1 board. On of the main function is to enable the user to read and write data to an USB device connected to the teensy board using the following library: https://github.com/wwatson4506/mscFS. The library works pretty much fine, but I observed the following behavior which I don't really know how to fix: let's say I have a big file on the USB device, and I want to read it buffer by buffer and do some processing. I use an PFsFile object to open the file then use usbFile.read(buffer, bubberLen) to read chunks of data from the file. If I let the board and USB device untouched then the whole process works just fine. My problem happens if I try to remove the USB device during the process because the teensy gets into a freeze state inside the read function and I can't do anything until I reset the board. My first solution was to check every time before a read if the USB device was still attached, but from 20 tries, let's say, I couldn't catch the event I want (maybe just 1 or 2 times) and I still got to the read function and ended up in a freeze. I also found a solution on the web by using a watchdog that automatically resets the board if the "dog" is not "fed" (happens during a freeze), but I would want another suggestion if any of you could help me. If it is possible, I would want that the program to continue its processing, but to let me know somehow if it can't read from the file without freezes or resets. I hope someone had gone through something similar, maybe using the SD card, not the USB, because I think they could have similar behaviors (the USB lib I'm using was built based on the SD card filesystem). Once again sorry for not being able to post code or schematics of the board, but If you are so kind just to advise me then I'll be grateful.
 
That's a thin wrapper over SdFat apparently, so this is probably the behaviour of the SdFat read()?
 
Hello there!

I am working on a project (sorry in advance, but I'm not allowed to post the code) using a Teensy 4.1 board. On of the main function is to enable the user to read and write data to an USB device connected to the teensy board using the following library: https://github.com/wwatson4506/mscFS. The library works pretty much fine, but I observed the following behavior which I don't really know how to fix: let's say I have a big file on the USB device, and I want to read it buffer by buffer and do some processing. I use an PFsFile object to open the file then use usbFile.read(buffer, bubberLen) to read chunks of data from the file. If I let the board and USB device untouched then the whole process works just fine. My problem happens if I try to remove the USB device during the process because the teensy gets into a freeze state inside the read function and I can't do anything until I reset the board. My first solution was to check every time before a read if the USB device was still attached, but from 20 tries, let's say, I couldn't catch the event I want (maybe just 1 or 2 times) and I still got to the read function and ended up in a freeze. I also found a solution on the web by using a watchdog that automatically resets the board if the "dog" is not "fed" (happens during a freeze), but I would want another suggestion if any of you could help me. If it is possible, I would want that the program to continue its processing, but to let me know somehow if it can't read from the file without freezes or resets. I hope someone had gone through something similar, maybe using the SD card, not the USB, because I think they could have similar behaviors (the USB lib I'm using was built based on the SD card filesystem). Once again sorry for not being able to post code or schematics of the board, but If you are so kind just to advise me then I'll be grateful.

Unfortunately mscFS is very outdated and not supported now. I have put that notice in the library README. I know you cannot show the code but can you give us which version of Teensyduino and Arduino you are using? There have been quite a few changes, updates and bug fixes since mscFS. Also can tell us which USB devices you are using? Recent changes were made to allow usage if certain SanDisk USB drives that would hang. MSC is now part of Teensyduino and uses Teensyduino's version of SD and SdFat...
 
Back
Top