I am not an entomologist :)
idbruce
Posts: 6,197
Hi All
I believe I found a bug, can you please help me to identify it?· If I am wrong, I apologize for the inconvenience.
Thanks
Bruce
I believe I found a bug, can you please help me to identify it?· If I am wrong, I apologize for the inconvenience.
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 DAT { Test.txt is a single line text file containing a simple string of numbers eg... 0123456789 } { The Problem: Serial Terminal outputs extra data eg... 01234567895785 } FileData File "Test.txt" OBJ DEBUG : "FullDuplexSerial" VAR Long nCharacterCounter Byte chFileCharacter PUB main nCharacterCounter := 0 DEBUG.start(31, 30, 0, 115_200) waitcnt(clkfreq + cnt) repeat chFileCharacter := FileData[noparse][[/noparse]nCharacterCounter++] if chFileCharacter == 48 {0 Character} DEBUG.tx(chFileCharacter) if chFileCharacter == 49 {1 Character} DEBUG.tx(chFileCharacter) if chFileCharacter == 50 {2 Character} DEBUG.tx(chFileCharacter) if chFileCharacter == 51 {3 Character} DEBUG.tx(chFileCharacter) if chFileCharacter == 52 {4 Character} DEBUG.tx(chFileCharacter) if chFileCharacter == 53 {5 Character} DEBUG.tx(chFileCharacter) if chFileCharacter == 54 {6 Character} DEBUG.tx(chFileCharacter) if chFileCharacter == 55 {7 Character} DEBUG.tx(chFileCharacter) if chFileCharacter == 56 {8 Character} DEBUG.tx(chFileCharacter) if chFileCharacter == 57 {9 Character} DEBUG.tx(chFileCharacter) while chFileCharacter > 0
Thanks
Bruce
Comments
You might be able to add something like a "Str byte 0" right under the filename line to fix it.
Bill
Thanks for the reply, but I know the code stops executing because I can write data to the serial terminal after exiting the loop.
Bruce
Here is some updated code to verify that null has bee found and that the loop is exited.
There's other information that's missing. For example, when do the extra characters appear? Your main method runs in one cog and, when the main method exits, the cog is stopped. FullDuplexSerial runs in its own cog and it takes some time for it to finish sending the information in its transmit buffer.
You mention that you can write data to the serial terminal after exiting the loop. That doesn't help unless you show what changes you make in the code so that happens.
I'm with wjsteele. I think that you don't have a zero byte in your text file and there are some other characters following the end of your "0123456789" string that cause the output of the "5785" and maybe there's a zero byte somewhere after that in the file.
Remember that some text editors use a non-zero specific control code to mark the end of the text file. The Propeller Tool doesn't know about this because the FILE directive might be used to include binary information and the Propeller Tool probably uses the file length information stored in the directory to tell it where the end of the file is. There could be all sorts of junk between the "end of file" control code and the actual end of the file. Your code only recognizes the digit characters and a zero byte. I think you'd see this if you added a couple of lines to display all non-digit characters as two hex digits.
Post Edited (Mike Green) : 7/9/2010 4:27:51 PM GMT
I disagree.· Look at the updated source.
Serial Terminal output now displays:
01234567895785
NULL character, 0, End Of File, has been reached
Hello World
Bruce
Bruce
Here is a compiled binary file.· I assume this is what you want to see.
Bruce
Now, I ran your test code and got the same result as you, so I looked at the memory map and sure enough, the only characters after the 9 and before the null that your code can display are the 5785 that you are getting.
It is because your file is not terminated with a null, period. Our conclusions are exactly what is happening.
Bill
Bill
Okay, I am humbled.· What the heck is a memory map?· And how did you find that?· Very impressive!
I must admit that I assumed you guys were wrong.· I apologize.· Nice find.· The code now works perfectly and I can go forward.
Thanks you Bill for the solution and the responses.
Bruce
P.S. Also thanks to Mike for his response.
I'd say (Mike and) I found it because of our experience, which you shouldn't underestimate. It's why we're on this Forum... to get help and to help others.
Bill
Thats what I thought you meant by the memory map, but I wish I knew how to read that stuff.· I have experience also, but I guess in this case I was outclassed
Bruce
P.S.· I won't underestimate you anymore, or at least I will TRY not to. · Thanks
It is unwise to second guess the likes of Mike. Check out his total posts. He is a god on these forums. [noparse]:)[/noparse]
Bill's not too shabby too [noparse]:)[/noparse]
BTW, your code can be made a lot more compact, viz:
-Phil
It's against my religion to have more than one god, so I proclaim Mike and Phil as Saints [noparse]:)[/noparse]
First off, thanks to everyone and there responses.
Mike, I believe you that it is in there, I just don't own a pair of those xray glasses that you and Bill have.· ·· I just found a pair.· That's pretty cool!· I understand now.· Thanks Mike.
Phil, yes I agree, that is a much simpler loop, but the real file data contains alpha-numeric characters and other symbols, so I must compare.· However, there are places within the file data that contain strings of nothing but numbers where your code snippet will come in handy.· Thanks for the snippet.
hover1, they both look a little mischievous, are you sure they are saints?
mpark, I must also do some other comparisons that do not allow chacter comparison, so I am using decimal comparison for all to be consistent.
Thanks again everyone