MultiCogSerialDebug object
Peter Verkaik
Posts: 3,956
I wrote a MultiCogSerialDebug object, derived from SerialMirror, that uses
my Format object to print formatted messages.
There is only one print function, cprintf, that does the formatting and printing.
It acts as printf with one argument, but takes an additional boolean parameter, more, that allows
to print compound messages. While more == true, other COGs are prohibited from printing.
The attached picture shows the debug output for the test program.
regards peter
Post Edited (Peter Verkaik) : 12/17/2007 6:20:53 PM GMT
my Format object to print formatted messages.
There is only one print function, cprintf, that does the formatting and printing.
It acts as printf with one argument, but takes an additional boolean parameter, more, that allows
to print compound messages. While more == true, other COGs are prohibited from printing.
The attached picture shows the debug output for the test program.
regards peter
Post Edited (Peter Verkaik) : 12/17/2007 6:20:53 PM GMT
spin
16K
Comments
I had a look. Do you realise there'll be an instance of printbuf for every reference to this object. I don't think it will cause any problems as is, but you could think about moving printbuf to the DAT section for the same reason that all the other variables are in the DAT section.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The normal (messy) way:
The Propeller Tool way:
I made extensive use of this feature in my PropTCP stuff. I didn't know this was possible until I stumbled onto a post where someone posted some example code that utilized this ingenious feature.
Harrison
Thanks for that pointer. It was in VAR because previous there was no lock.
Now that cprintf is the only print function and there is a lock, it can be moved
to DAT.
I also realized that the lock in method rxcheck is not required as there should
be only one cog that must handle incoming messages.
I have put a new version in the object exchange. And attached it here also.
regards peter
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Any news on when the IDE will include the debug window?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheers,
Simon
www.norfolkhelicopterclub.co.uk
You'll always have as many take-offs as landings, the trick is to be sure you can take-off again ;-)
BTW: I type as I'm thinking, so please don't take any offense at my writing style
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
You've got me curious now - what's #1 !?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheers,
Simon
www.norfolkhelicopterclub.co.uk
You'll always have as many take-offs as landings, the trick is to be sure you can take-off again ;-)
BTW: I type as I'm thinking, so please don't take any offense at my writing style
My main code is
· buf[noparse][[/noparse]0] := $41
· buf[noparse][[/noparse]1] := $42
· buf[noparse][[/noparse]2] := 0
· debug.cprintf(string("1st char is %c\r"),buf[noparse][[/noparse]0],false)
· debug.cprintf(string("2nd char is %c\r"),buf[noparse][[/noparse]1],false)
· debug.cprintf(string("total string is %s\r"),@buf,false)
· debug.cprintf(string("1st char is %c\r"),$41,false)
· debug.cprintf(string("2nd char is %c\r"),$42,false)
The first 2 cprintf calls do not print the characters A and B
and the 3rd cprintf call does not print the string AB.
The last 2 cprintf calls do print the characters A and B.
The first 2 should have done also, as buf[noparse][[/noparse]0] == $41 and buf[noparse][[/noparse]1] == $42
What is going on here?
The picture shows the debug output.
regards peter
Post Edited (Peter Verkaik) : 12/19/2007 3:24:18 PM GMT
The attached test program has main code
· 'send welcome message
· debug.str(string("MultiCogSerialDebug_test3 program"))
· debug.tx(13)
· buf[noparse][[/noparse]0] := $41
· if buf[noparse][[/noparse]0] == $41
··· debug.str(string("1st character loaded correctly"))
··· debug.tx(13)
· debug.str(string("Program finished"))
· debug.tx(13)
· repeat
It uses SerialMirror to display output.
The above outputs
MultiCogSerialDebug_test3 program
Program finished
Apparently buf[noparse][[/noparse]0] does not get $41 assigned.
However, disabling the first debug call,
the output becomes
1st character loaded correctly
Program finished
Could this be a compiler bug?
regards peter
Increasing the atnStack to 5 longs made the error disappear.
regards peter
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.