Any ideas why FILE is not working for me?
jrullan
Posts: 168
in Propeller 2
Hello,
I'm scratching my head trying to get the bytes of a binary file into spin. I'm generating the file in Processing and contains only 32 bytes with numbers 0 through 31. Then I'm trying to consume this file in a spin method but all I get from the bytes in spin is 0.
The attached image shows the input file when it was generated, the same file read through another processing program byte by byte (to validate generation) and the spin program with debug in Pnut. You can see the results of each side by side. Any ideas are welcome!
Thanks.
Code:
I'm scratching my head trying to get the bytes of a binary file into spin. I'm generating the file in Processing and contains only 32 bytes with numbers 0 through 31. Then I'm trying to consume this file in a spin method but all I get from the bytes in spin is 0.
The attached image shows the input file when it was generated, the same file read through another processing program byte by byte (to validate generation) and the spin program with debug in Pnut. You can see the results of each side by side. Any ideas are welcome!
Thanks.
Code:
CON _clkfreq = 160_000_000 PUB main() | i, b repeat i from 0 to 31 b := byte[tree][i] debug(udec(b)) DAT tree FILE "tree.p2"
Comments
Wow! Thank you very much @ozpropdev!
It worked!!!!
It only worked in Pnut. The same code in Propeller Tool 2.4.1 does not seem to load the file.
Any ideas why?
IIRC it will be in the next release (end of December?)
Oh yes I know that. I meant that in Propeller Tool it doesnt seem to be reading any file. The previous code was an example of loading the file, but the real application is reading a bitmap to display in a led matrix. And it works when I load the file with Pnut into the P2, but when loading it with Prop Tool it doesnt. It seems to me that something about the compiler in Pnut vs Prop Tool is the responsible for loading the file in the DAT block.
My project has 10 FILE directives and all load Ok.