-
• #2
Thanks - that looks interesting. I'll have a look and see if I can reproduce it.
I can't see anything immediately wrong in
fs.statSync
- it's possible it's actually an issue with Date. -
• #3
Just tried to reproduce syncStat problem in a different way. Typed commands in terminal window:
- reset()
- require("fs").readdir()
- require("fs").syncStat("Juergen1_data.bin")
There is no response from Espruino, so I - closed connection
- clicked connect button and got an empty list, no COM port available anymore
- wrote these lines and about a minute later, a Com port is available
- tried to connect and got Connection failed
- unplugged Espruino Board from USB
- plugged Espruino Board
- now connect worked fine
- syncStat worked fine
Hmmm, whats that ? So tried again: - reset()
- require("fs").readdir()
- require("fs").statSync("Juergen1_data.bin")
- Espruino hangs again
- reset()
-
• #4
What's in
"Juergen1_data.bin"
? I don't think you ever said.I just tried this on an Espruino board with 1v79 from the website and it seems to work, so maybe my file
Juergen1_data.bin
is different somehow.Having said that, I found that if
readFile
failed and sentundefined
toJSON.parse
it could cause you pretty major problems. -
• #5
Nope, now it's breaking!
As you say, doing a
readdir
just before is enough to kill it. Butreaddir
followed by areadFile
is fine.>require("fs").readFile("Juergen1_data.bin") ="Hello World" >require("fs").statSync("Juergen1_data.bin") ={ "size": 11, "dir": false, "mtime": { "ms": 1328054400000 } } >require("fs").readdir() =[ "Juergen.json", "Juergen1_ctrl.json", "Juerget1_data.bin", "Juergen1_data.bin", "Juerget1_data.bin~" ] >require("fs").statSync("Juergen1_data.bin")
Looks like this is something else dodgy in the SPI/Filesystem interface code :(
running this prints "..." on screen, so variable startAt is corrupted
uncommented first console.log and it works fine:
Also had problems sometimes by using fs.statSync from terminal window. Connection to com-port was lost, and I had to reset and restart everything.
IMHO, this could be a problem around memory management for fs.statSync.
Using 1v80 on Espruino Board
Data returned from readFile is this: