Thoughts on String variable debugging in ViewPort
Hanno
Posts: 1,130
Currently most people are using variants of FullDuplexSerial to interface with a terminal. At the lowest level, this means they're bit-banging one byte at a time to/from the terminal- in their main cog. Correct me if I'm wrong, but I don't think this makes it easy/convenient to create nice interfaces for passing longs, floats, strings around... It also completely ties up your IO channel- you can only share 1 channel of text information.
ViewPort's architecture is different. One cog is dedicated to sharing global memory with the PC program. Up to now it shared "longs", and arrays of longs (which could represent streaming video or sampled measurements). I recently added the ability to share arrays which contain null-terminated strings. To transmit a string, your program needs to copy a string to such an array. Transmitting floats or integers in hex/binary formats just means ViewPort has to decode the value as that.
You can share any number of strings- and you can easily switch within ViewPort to the string you want to watch. You can also share any number of other things- video, IO measurements, variables....
I'm working on a clean way to let your program "prompt" for input: string, float, int, hex, binary... vp.getStr would cause your spin code to wait until a string was entered inside of ViewPort. vp.getInt for integers entered in any format ...
Here's some things you could do:
vp.sendStr(&DebugStr,"This is a debug string- select the Debug channel to view these strings")
vp.sendStr(&UIStr,"This is a user interface string- please type your name")
vp.getStr(&Name) 'program pauses here until user has entered a string, which will be assigned to Name
vp.sendStr(&UIStr,"How old are you")
vp.getInt(&Age) 'user can type a number in hex, binary... it'll be assigned to age
vp.sendStr(&UIStr,"In 5 yours you will be:")
vp.sendInt(Age+5)
Here's a screenshot of ViewPort's debugger with a small terminal window on the bottom right. The "text" tab has a full-sized terminal.
What do you think?
Hanno
ViewPort's architecture is different. One cog is dedicated to sharing global memory with the PC program. Up to now it shared "longs", and arrays of longs (which could represent streaming video or sampled measurements). I recently added the ability to share arrays which contain null-terminated strings. To transmit a string, your program needs to copy a string to such an array. Transmitting floats or integers in hex/binary formats just means ViewPort has to decode the value as that.
You can share any number of strings- and you can easily switch within ViewPort to the string you want to watch. You can also share any number of other things- video, IO measurements, variables....
I'm working on a clean way to let your program "prompt" for input: string, float, int, hex, binary... vp.getStr would cause your spin code to wait until a string was entered inside of ViewPort. vp.getInt for integers entered in any format ...
Here's some things you could do:
vp.sendStr(&DebugStr,"This is a debug string- select the Debug channel to view these strings")
vp.sendStr(&UIStr,"This is a user interface string- please type your name")
vp.getStr(&Name) 'program pauses here until user has entered a string, which will be assigned to Name
vp.sendStr(&UIStr,"How old are you")
vp.getInt(&Age) 'user can type a number in hex, binary... it'll be assigned to age
vp.sendStr(&UIStr,"In 5 yours you will be:")
vp.sendInt(Age+5)
Here's a screenshot of ViewPort's debugger with a small terminal window on the bottom right. The "text" tab has a full-sized terminal.
What do you think?
Hanno
Comments
ViewPort will support a "string variable type" which you can use in spin and view/change using ViewPort. Just like you can view/change integers you'll be able to view/change strings.
ViewPort will also have a built in terminal that interfaces easily with existing terminal spin code. The conduit object will provide a replacement for the "tx" and "rx" commands that are the backbone for sending/receiving anything else. So, integrating any existing terminal code will be easy- just replace the tx and rx functions with the vp equivalents...
So, you still lose one cog to handle serial IO (used to be FullSerial, now Conduit). You can send/receive text using the existing terminal functions. AND you get all the goodness of ViewPort- debugger, view/change variables, view io state....
Hanno
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
JMH - Electronics: Engineer - Programming: Professional
Here it's documentation:
(installs as ViewPort v4.1F)
Some new goodies:
- support for Propeller float type
- support for Propeller string type
- new terminal, see tutorial #16
- improved OpenCV, better interface, runs continuously (even while other tabs are up), and lets you use either a webcam, a propeller frame grabber, an avi file, or images...)
- lots of fixes
Download v4.1F
This version expires mid-Feb. I hope to release the final by then! No known issues- if you encounter something strange please tell me about it!
Hanno