-
• #2
not solution but maybe workaround or thing to check - you can retype the array as Uint8Array in place (they share same memory) and see how that one gets written or check how it compares to 'bad' file you have.
>var d8 = new Uint8Array(d.buffer)
or even check
d.buffer
- that will be probably the same byte array as d8 would be -
• #3
Much better, file length matches the
buffer
-s length. First couple of bytes match. I think all I need is read back on the computer.Thank you!
-
• #4
Yeah, the issue is that
fs.appendFile("log0.txt", d)
(and pretty much any 'write' command) iterates over the given array, assuming each element is a byte (even if you supply aUintXYZArray
). It makes more sense if you think of what you'd want if you supplied just a simple array like[1,2,3,4]
.All you need to do to write is
fs.appendFile("log0.txt", d.buffer)
I'm trying to write 16bit integers to a file, but didn't got the result I was expecting. For example:
\xFF
is 255, ok for one byte.1111
is0100 0101 0111
in binary, andW
is 87 character code,0101 0111
binary. Looks like the lower byte of the 16 bit integer is saved.*
is 42, ok.My question is: Looks like saving typed arrays directly is not supported. Will it be, or what would be the best way to save this data as fast and efficient as possible?
Board is a Pixl running 2v08.188 (and of course shouldn't call a binary file
.txt
)