PropBasic, Viewport and Spin interoperabilty?
pmrobert
Posts: 677
PropBasic and Viewport play together quite nicely, thanks to the authors! I'm trying to add a Spin based ADC driver into some working PropBasic code via the Spin dispatcher technique outlined in the main PropBasic thread. the problem I'm encountering is that while the code compiles it will not successfully load - Viewport gives the error dialog stating "Failed to configure on COM2". If I comment out the Spin dispatch code all is well. I'm obviously missing something very basic. Attached is the non-working PB code with the Spin dispatch code active, the generated code and the driver referenced in the dispatcher.
Attachment not found.
Max1270_Ray.spin
Attachment not found.
Max1270_Ray.spin
Comments
Thanks
I wasn't able to compile because I'm missing some files: "wheelsignal", "decoder" and "inj_1"
However, I think I've found the problem- you call
Coginit(1,@__Init, @__DATASTART) in your "spinstart" method. Cog 0 runs the main spin program. Before calling your SpinStart method, PropBasic starts the conduit object- which then runs in Cog 1. You then overwrite that cog with your method- so ViewPort isn't able to connect!
Let me know how you go- either change to the "cognew" call or load into a different cog.
Hanno
vptest.pbas
I got it!
In order to use ViewPort, the Conduit object must be running in a cog. If you don't start it, overwrite it, or conflict with the pins it uses (30,31)- then ViewPort won't be able to communicate with the Propeller.
You're not starting it!
The vptest.spin has 2 spin methods- "__Program" and "SpinStart". Since "SpinStart" is first, it will execute- but it never calls "__Program"- so vp_config never gets called.
Fixing the vptest.spin is easy, either move the "__Program" method to the top, or call "__Program" from "SpinStart".
I haven't been able to move things around in the "pbas" file to get the PropBasic compiler to do the right thing. Ideally, the PropBasic compiler should ensure that user code is always placed below PropBasic intialization code...
Hanno
-Mike