Debugging 2 objects with same serial
Ron Czapala
Posts: 2,418
I am using Extended_FDSerial to display debugging info on my PC monitor using pins 31 and 30.
I am also using some other spin objects and would like to display data to the PC monitor.
I tried using the Start method in the top level object only while using TX in both objects.
It didn't work, so I tried putting a Start in the lower level object also.
That didn't work either.
Is there a way to use the same serial connection in a top level and lower level object?
Thanks!
I am also using some other spin objects and would like to display data to the PC monitor.
I tried using the Start method in the top level object only while using TX in both objects.
It didn't work, so I tried putting a Start in the lower level object also.
That didn't work either.
Is there a way to use the same serial connection in a top level and lower level object?
Thanks!
Comments
I will try that.
EDIT - Found Mike Green's explanation
there might be still a problem if methods from different cogs (not diferent objects) start to send. Then the characters get mixed up.
This can be solved through a writebuffer.
With a buffer of 16 bytes
Where cog a only writes to buffer-index 0-7 and cog b writes only to buffer 8-15
The top-object checks for changes and if a byte has changed in the buffer then sends always the complete buffer.
This way the bytes can't get mixed up as each cog writes to his own part of the buffer.
best regards
Stefan
1. Using a serial port from multiple objects but the objects are running on the same cog.
2. Using a serial port from 1 or more objects but from multiple cogs
SeriallMirror will allow 1 and 2 but with 2 the output from the cogs will be interleaved which makes reading the messages harder.
4 port serial also allows 1 and 2 but has the interleaving problem as well.
I have a version of 4 port serial that allows a lock to be used per port so multiple calls to 4 port serial can be used without interleaving between cogs but its not automatic, if you want do use multiple calls from a cog without interleaving you need to wrap the calls with a get/freelock
Thanks for your response. Luckily SerialMirror works for my current need but this information will probably be useful in the future.
I thought about using a USB2SER on a second com port/pin set but SerialMirror was easier.
Thanks again!
http://obex.parallax.com/objects/243/