-
Notifications
You must be signed in to change notification settings - Fork 17
Occasionally stuck in loop during file write #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think I've run into this same issue and at least in my case it appears to be related to the length of the text being written to the SD card. I threw a couple debug statements into the library and it looks to me like the library gets into trouble whenever the writeblocks method has to use the loop to write more than one block. I wrote a little test script that writes records of various lengths to an SD card. If I write 10 records of 1022 bytes (actually 1023 including the \n the script adds at the end) or less the write works fine. Sending 10 records of 1023 bytes corrupts the data but doesn't crash the file system. Sending10 records with more than 1023 bytes crashes the SD file system which requires the SD card to be ejected and reinserted along with a CTRL-D before the test script can be run again.
|
I've stared at the multi-block loop in "writeblocks" but can't see any logic problems but then I'm unfamiliar with the SPI SD card stuff. I went ahead and modified my write routine so that anytime I'm sending more than 1022 bytes I break the write up, basically lifting the logic from the "writeblocks" module and that resolved the issue. That tells me that the problem in the library has to be in the multi-block transaction logic, probably something with the SD "TOKEN_CMD"s. This is my updated write routine that no longer gets stuck during file writes:
|
I threw the same patch logic from filecpy into my test driver and it now successfully writes and reads all combinations of line lengths. |
Run into an error where my watchdog timer has been getting triggered.
I'm working on a minimal example... but I've only seen the error very occasionally (maybe once a day) so it might be tricky.
I'm running something like this
I get this traceback:
Which tells me the code is getting stuck in the _cmd() function due to
while buf[1] != 0xFE:
never being satisfied.Or at least not within a 60s watchdog timeout.
It looks like there is intended to be a timeout on this funciton (_CMD_TIMEOUT)
but it can fail due to the while loop.
relevant part of _cmd() is here:
I'm going to try mimicing the
for _ in range(_CMD_TIMEOUT):
pattern instead of the while loop.Can do a PR if it works.
The text was updated successfully, but these errors were encountered: