PropBasic & Viewport
FriedV
Posts: 77
After several trial & error attempts, I'm stuck:
Using PropBasic I compiled the following to spin code:
Then I edited the Spin code adding the conduit object
and adding two vp.config lines:
org without value
and several
JMP/DJNZ without #
Running Viewport and loading the propeller works partially,
I can watch the counter var in Viewport, but the Propeller does not execute the program,
and the red interface led stays on.
What to do?
Thx, Friedrich
Using PropBasic I compiled the following to spin code:
' ---------------------------------------------------------------------- ' File...... Counter.pbas ' Author.... fgvissel 15.09.2011 ' ---------------------------------------------------------------------- ' ----- Device Settings ------------------------------------------------ DEVICE P8X32A, XTAL1, PLL16X XIN 5_000_000 ' ----- Conditional Compilation Symbols -------------------------------- ' ----- Constants ------------------------------------------------------ ' ----- IO Pins -------------------------------------------------------- Leds Pin 3..0 Low ' ----- Shared (HUB) Variables (Byte, Word, Long) ---------------------- counter HUB long = 0 ' ----- User Data (DATA, WDATA, LDATA, FILE) --------------------------- ' ----- TASK Definitions ----------------------------------------------- ' ----- Local Variables (LONG only) ------------------------------------ locCounter VAR long delta VAR long target VAR long ' ----- SUB and FUNC Definitions --------------------------------------- PROGRAM Start Start: ' setup code Main: rdlong 0, delta delta = delta >> 2 target = cnt +delta do rdlong counter, locCounter locCounter = locCounter + 1 wrlong counter, locCounter Leds = locCounter if loccounter = 16 then loccounter = 1 wrlong counter, loccounter endif waitcnt target, delta loop GOTO Main ENDProgram works fine on Propeller chip, showing counter on the 4 leds.
Then I edited the Spin code adding the conduit object
and adding two vp.config lines:
'{$BST PATH C:\Work\Propeller\PBasic\Stingray} '' *** COMPILED WITH PropBasic VERSION 00.01.14 July 26, 2011 *** '' ---------------------------------------------------------------------- '' File...... Counter.pbas '' Author.... fgvissel 15.09.2011 '' ---------------------------------------------------------------------- '' ----- Device Settings ------------------------------------------------ CON ' DEVICE P8X32A, XTAL1, PLL16X _ClkMode = XTAL1 + PLL16X _XInFreq = 5000000 ' XIN 5_000_000 '' ----- Conditional Compilation Symbols -------------------------------- '' ----- Constants ------------------------------------------------------ '' ----- IO Pins -------------------------------------------------------- ' Leds Pin 3..0 Low ' Leds Pin 3..0 Low '' ----- Shared (HUB) Variables (Byte, Word, Long) ---------------------- ' HUB LONG counter ' counter HUB long = 0 '' ----- User Data (DATA, WDATA, LDATA, FILE) --------------------------- '' ----- TASK Definitions ----------------------------------------------- '' ----- Local Variables (LONG only) ------------------------------------ ' locCounter VAR long ' locCounter VAR long ' delta VAR long ' delta VAR long ' target VAR long ' target VAR long '' ----- SUB and FUNC Definitions --------------------------------------- VAR long frame[400] OBJ vp : "Conduit" ' Declare ViewPort conduit PUB __Program vp.config(string("var:counter")) vp.share(@counter,@counter) 'PROGRAM Start CogInit(0, @__Init, @__DATASTART) DAT org 0 __Init __RAM mov dira,__InitDirA mov outa,__InitOutA jmp #Start Start 'Start: '' setup code Main 'Main: mov __temp1,#0 ' rdlong 0, delta rdlong delta,__temp1 ' delta = delta >> 2 shr delta,#2 mov target,cnt ' target = cnt +delta adds target,delta __DO_1 ' do mov __temp1,par ' rdlong counter, locCounter rdlong locCounter,__temp1 ' locCounter = locCounter + 1 adds locCounter,#1 mov __temp1,par ' wrlong counter, locCounter wrlong locCounter,__temp1 cmps locCounter,#16 WZ, WC ' if loccounter = 16 then IF_NE jmp #__ELSE_1 mov locCounter,#1 ' loccounter = 1 mov __temp1,par ' wrlong counter, loccounter wrlong locCounter,__temp1 __ELSE_1 ' endif __ENDIF_1 waitcnt target,delta ' waitcnt target, delta jmp #__DO_1 ' loop __LOOP_1 jmp #Main 'GOTO Main mov __temp1,#0 'END waitpne __temp1,__temp1 '' ----- SUB and FUNC Code ---------------------------------------------- '' ----- TASK Code ------------------------------------------------------ '' ---------------------------------------------------------------------- '********************************************************************** __InitDirA LONG %00000000_00000000_00000000_00001111 __InitOutA LONG %00000000_00000000_00000000_00000000 Leds LONG 15 << 0 _FREQ LONG 80000000 __remainder __temp1 RES 1 __temp2 RES 1 __temp3 RES 1 __temp4 RES 1 __temp5 RES 1 __param1 RES 1 __param2 RES 1 __param3 RES 1 __param4 RES 1 __paramcnt RES 1 locCounter RES 1 delta RES 1 target RES 1 FIT 492 CON LSBFIRST = 0 MSBFIRST = 1 MSBPRE = 0 LSBPRE = 1 MSBPOST = 2 LSBPOST = 3 counter_ofs = 0 DAT __DATASTART counter LONG 0When compiling the code, it flags warnings in the conduit.spin:
org without value
and several
JMP/DJNZ without #
Running Viewport and loading the propeller works partially,
I can watch the counter var in Viewport, but the Propeller does not execute the program,
and the red interface led stays on.
What to do?
Thx, Friedrich
Comments
I was not able to compile your PropBasic code because of invalid characters...
Bean
The Leds Pin 3..0 Low is compiled to
The spin compiler output are only warnings, not errors, perhaps you disabled them.
I tried again to load the edited spin file into viewport, and now all seems to be fine.
What worries me a bit is invalid character error your getting with the PropBasic Compiler.
I use win7 on a MacBook with the German Keyboard and environment, perhaps this is the reason.
Thanks Bean for looking into this. Is there anything I should do to make PropBasic work better with ViewPort?
Hanno
One problem is that I have to use BST to compile PropBasic code to a .spin file. Then switch to Viewport and reload the .spin file with every source code change.
Another problem is that Viewport doesn't seem to like the spaces in the .spin file. I'm not sure why, but it shows vertical lines.
See attached screen image and .spin file
Bean
The vertical bars in Viewport are AFAIK only a visual help to show indentation.
Fried
Bean- Yes, the vertical lines are a "feature". ViewPort places the vertical lines at every tab stop up to the first text- works great for properly indented spin code, not ideal on indented comments.
12Blocks recognizes when the underlying file was changed by another process and then prompts the user "File has changed, reload file"- I could do the same thing for ViewPort. That way you could use other tools to edit PropBasic, compile to spin- and tab to ViewPort to debug- all without file browsing.
Even smoother would be to edit PropBasic in ViewPort and press "Run" to compile to spin and upload. That already works for Catalina C and Basic for the BS2 chips. Looks like I'll need to read up on how to compile PropBasic
Hanno
Hanno,
PropBasic.exe "full path to pbas file" /switches
Switches:
/Q = Quiet (No screen output)
/P = Pause on warning or error (used to debug compiler)
/B = Brief output (does not show source code)
/O = "Output_Directory" Specifies a diffrent directory for output files
/V = Returns Version number as exit code (exit immediately)
/NC = No Code (Does NOT include the BASIC code in the output file)
The path to to pbas file MUST be in quotes.
The files invalid.txt and reserved.txt must be in the same directory as propbasic.exe
The compiler will create a .spin file in the same directory as the source file (unless the /O switch is used).
The compiler will create a .err file in the same directory as the source file (unless the /O switch is used). This tell you where the errors/warnings have occured.
Code that writes to error file when an error occurs:
Code that writes to error file when a warning occurs:
Hanno, Let me know if you need any more info.
Bean
Am busy with kids today but should get this into VP tomorrow. Thanks for including your error code- that helps immensely for parsing.
I hope to:
- include PropBasic configuration options in program preferences to let users specify where PropBasic is installed and what flags to use.
- use syntax highlighting for BASIC- I'll look at your .txt files for inspiration of additional keywords to highlight
- turn off vertical lines while editing BASIC
- compile to spin, compile to bytecode, find prop, load prop all in one step- with appropriate error handling at each step
- "view spin code"
- navigate and highlight syntax errors
- include some tutorials showcasing ease of PropBasic and visual debugging of ViewPort
- allow users to develop basic code and then debug resulting spin code with breakpoint/line by line stepping.
Am I missing anything?
Hanno
That would be great to have PropBasic supported in ViewPort.
One issue is that PropBasic uses COG RAM for variables. So they only can be "seen" by viewport by writing the values to HUB RAM. But I don't think there is anything that can be done about that.
I am also willing to modify PropBasic to support Viewport also. It would be cool to be able to use "WATCH varName", and "BREAK" in PropBasic.
With the speed of PropBasic I bet some good demos of using the "video from propeller" could be done (game of life comes to mind).
Bean
Bean
Hanno
ps- Yes, please add at least a "WATCH" keyword to easily monitor variables (and arrays?)
How do you envision "BREAK" working?
That looks good, but don't call it "pbasic" that is what Parallax uses for the basic stamps. IOW PropBasic is not pbasic. I would call it either "basic" or "propbasic".
BREAK would be for break-points. What would I have to do to implement that on my end ? Single stepping might be alot harder, but break-points would be nice.
I think I'll have to have some kind of "sync" or "update" command to transfer the variable values to HUB ram (and get values changed in viewport). I would be harder to update variables "on the fly".
Bean
Thanks! Sorry for the name mixup- I'll make sure it's called "PropBasic" everywhere. For Catalina C and Spin users can single step and set breakpoints at run time- ie they can let code run to a point, set another breakpoint and run again- just like in Visual Studio. An intermediate solution could involve what I think you're suggesting- having the user add "break" statements into their code where the program pauses until it receives some command from ViewPort. I think a "sync" command to update variables is fine "for now". At some point I/we could look into adding some of conduit's functionality into your "interpreter" to allow both full breakpoints/stepping and full ViewPort monitor/view variables. But let's do this one step at a time
Hanno
ViewPort v4.63 now has support for PropBasic including:
+ include PropBasic configuration options in program preferences to let users specify where PropBasic is installed and what flags to use.
+ can configure vertical lines on/off
+ use syntax highlighting for PropBasic
+ compile to spin, compile to bytecode, find prop, load prop all in one step- with appropriate error handling at each step
+ compiled propbasic "spin" files are left in source directory- can view/edit/run those
+ navigate and highlight syntax errors- both PropBasic and Spin
+ include some tutorials showcasing ease of PropBasic and visual debugging of ViewPort
+ allow users to develop basic code and then debug resulting spin code with breakpoint/line by line stepping.
+ if source file changed by other editor, ViewPort will ask if want to reload
Attached is updated guide. Download the latest ViewPort beta from here:
http://hannoware.com/viewport/beta.php
I'd love feedback!
Hanno
thanks very much for your efforts. If you want me to beta test any of the combo PropBasic/Viewport versions,
I'd be glad to do so.
Here is the "syntax" file I use with Edit3+ (BTW I like this editor very much because of it's very flexible
user interface configuration)
Fried
Seems my phpbb forum software broke itself- I'm working with hosting provider to get it fixed.
In the mean time, you can download v4.63 here: http://hannoware.com/viewport/viewport463.exe
Thanks Fried for the highlighting help, I'll make good use of it.
Hanno
Hanno
will viewport compile LMM code properly, or will you have to still sue bst for that?
thanks for adding propbasic, you just sold another copy of viewport
I'm looking into it...
Bean
Bean- sounds like PropBasics isn't closing an included file?
ViewPort uses the HomeSpun spin compiler- should produce same code as BST.
Hanno
I can't get anything to compile. It keeps saying "File Not Found".
Does the {0} return the complete path to the *.pbas file ? PropBasic.exe needs the complete path.
I have attached the compiler (without the BST modifications). That should work.
[edit] see later posts for latest version...
Bean
Yes, {0} provides the complete path to the *.pbas file.
I placed your "PropBasic.exe" file into "C:/Program Files/PropBasic/PropBasic.exe", loaded "29_PropBasic.pbas" in ViewPort and pressed "Run".
If it can't find "PropBasic" it should tell you to install it/edit settings.
Hanno
If I compile it and place the .spin file in the same directory it ViewPort will load it.
But if I change the .pbas file and press "RUN" Viewport loads the old .spin file. I assume that the compiler is terminating without compiling.
Would it be possible to not hide the window that PropBasic.exe is running in ?
Bean
Make sure you don't have 29_PropBasic.spin already in that directory.
Viewport may be just loading the file that is already there.
Bean
I didn't have the two .TXT file in the directory with PropBasic.exe
Bean
Until now I've been using your "PropBasicBST" file- that hasn't had any issues. What's the difference between those two?
I'm running the compiler in a process- not trivial to show both standard out and error due to threading issues, but I'll work on it.
Hanno
See my previous post. I had forgotten to put the two .TXT files in the same directory "Reserved.txt" and "invalid.txt".
The version 1.15 doesn't have the BST hooks. I'm not sure what these are as BradC modifies it.
With the version 1.15 that I just posted you can run this program:
Bean