When using FlexGUI 4.0.0 beta, under Win10 and coding in BASIC:
I boiled-down the "Out Of Memory" code to an uber-thin test case. If you copy and run this with the debug window open, after 3-4 loops, you'll get an "Out of Memory" message up the serial channel and the FLIP sort of wanders-off somewhere.
OPTION EXPLICIT
CONST HEAPSIZE = 4096
dim tmp$ as string
dim idx as integer
for idx = 1 to 15
tmp$ = str$(idx) + " :The quick brown fox jumps over the lazy hedgehog"
'_gc_free(tmp$)
'_gc_collect()
'tmp$ = ""
next idx
You can uncomment the _gc_free() and _gc_collect() in any combination and the error still persists. Same goes for setting TMP$="". Putting this code into a SUB doesn't seem to have much effect either.
I'm stumped. @ersmith, your garbage collector just doesn't seem to like me...
Testing on Propeller1/SpinSim...
Maybe "str$()" is the problem?
Even this fails:
let s$=str$(1)
let s$=str$(1)
let s$=str$(1)
let s$=str$(1)
A byte later:
OPTION EXPLICIT
CONST HEAPSIZE = 4096
dim tmp$ as string
dim idx as integer
function itos$(n as integer) as string
if n<0 return "-"+itos$(-n)
if n<10 return chr$(48+n)
return itos$(n/10)+itos$(n mod 10)
end function
for idx = 1 to 15
tmp$ = itos$(idx) + " :The quick brown fox jumps over the lazy hedgehog"
'_gc_free(tmp$)
'_gc_collect()
'tmp$ = ""
print tmp$
next idx
$ fastspin -q cvbbv.bas ; spinsim -b cvbbv.binary
1 :The quick brown fox jumps over the lazy hedgehog
2 :The quick brown fox jumps over the lazy hedgehog
3 :The quick brown fox jumps over the lazy hedgehog
4 :The quick brown fox jumps over the lazy hedgehog
5 :The quick brown fox jumps over the lazy hedgehog
6 :The quick brown fox jumps over the lazy hedgehog
7 :The quick brown fox jumps over the lazy hedgehog
8 :The quick brown fox jumps over the lazy hedgehog
9 :The quick brown fox jumps over the lazy hedgehog
10 :The quick brown fox jumps over the lazy hedgehog
11 :The quick brown fox jumps over the lazy hedgehog
12 :The quick brown fox jumps over the lazy hedgehog
13 :The quick brown fox jumps over the lazy hedgehog
14 :The quick brown fox jumps over the lazy hedgehog
15 :The quick brown fox jumps over the lazy hedgehog
Yes, str$ is broken . It appears that creating a temporary function inside another function can create an infinite loop that prevents garbage collection from happening. I'll have to think about the right solution for that, but for now you can replace the fastspin file include/libsys/strings.bas with the one attached to this message to get str$ working properly again.
When using FlexGUI 4.0.0 beta, under Win10 and coding in BASIC:
@ersmith added the VAL() function when I wasnt looking. Sneaky devil! On the next doc cycle, you might add that to the keywords along with a brief description.
Edited to add: VAL() has some bugs. VAL() doesnt handle anything to the right of the decimal point and it also does not like the presence of a sign at all.
But the basic "VAL()" for unsigned integers works nicely. So it may be that I've stumbled onto one of those "I wasn't actually ready to release that" sort of things... which explains why it's not in the manual yet.
Edited to add: VAL() has some bugs. VAL() doesnt handle anything to the right of the decimal point and it also does not like the presence of a sign at all.
But the basic "VAL()" for unsigned integers works nicely. So it may be that I've stumbled onto one of those "I wasn't actually ready to release that" sort of things... which explains why it's not in the manual yet.
VAL is kind of half-baked so far, yes, although the sign bug is not supposed to happen. I'll fix that.
I'm not sure we want to pull in all of the floating point code for every use of VAL, but on the other hand it would be nice to have val("1234.56") return the correct value. Maybe we need both VAL# and VAL%, and make plain VAL the same as VAL#?
@yeti: the "unexpected COG label" warning seems to be harmless, but it indicates that for some reason the label starting the BASIC data block hasn't been flagged as a HUB label. It should be, so I'll look into it.
When using FlexGUI 4.0.0 beta, under Win10 and coding in BASIC for the FLiP:
@ersmith I haz an error, bigly. This only happens when Options -> Full Optimization is selected, but I thought I'd pass it along just the same. It never happens when Options -> Default Optimization is selected. When I select Options -> No Optimization it doesn't error-out, but the resulting file size exceeds the Prop1's memory so I'm not sure it's relevant.
I'd post the code, but I'm somewhere north of 2000 lines of BASIC and some non-trivial amount of Spin with embedded assembly, so it'd be a slog. That being said, if I must, I'll do a binary divide and conquer to see if I can isolate the offending chunk.
Propeller Spin/PASM Compiler 'FastSpin' (c) 2011-2019 Total Spectrum Software Inc.
Version 4.0.0-beta-317bfbe5 Compiled on: Oct 4 2019
GenTest1.bas
|-vga_hires_textLEAN.spin '<- highly modified version of Chip's vga_hires_text but for 640x480 and 256 char font
|-DS1307RTC.spin '<- modifed version of file of same name from obex but for DS3231 chip
fmt.c
strings.bas '<- ERSmith's temp replacement for the misbehaving distro file
gcptrs.spin
strcpy.c
strlen.c
GenTest1.pasm '<- Generator control w/user interface - top-level module in FlexBASIC
Done.
d:/Flex2Gui/flexgui/GenTest1.pasm:6985: error: fit 496 failed: pc is 535
child process exited abnormally
Finished at Sun Oct 20 19:14:40 2019
I've been away on vacation and am just getting up to speed again. What is the current status of the FastSpin C compiler? It sounds like the entire suite of languages has made great progress in the past few weeks!
I've been away on vacation and am just getting up to speed again. What is the current status of the FastSpin C compiler? It sounds like the entire suite of languages has made great progress in the past few weeks!
Welcome back, David! FastSpin C is in much better shape than it was, but there are still plenty of things that need improvement. My goal for 4.0.0 was to get BASIC stable (which I think has been achieved) and I'm turning to C next. There's a c-testsuite on github that I've started working with and it's already turned up some interesting bugs in the C support.
Sounds good! I'll try some of my code again to see if I run into any problems. I'd still like to get my BASIC interpreter working on P2. It is nothing compared with your BASIC but it does run directly on the P2.
@JRoark : the "fit 496 failed" error when compiling with -O2 is an out of memory problem. The optimizer puts more things into registers, and we've run out of registers. There's no easy fix for this, although one potential work-around on P1 is to eliminate the fcache by adding "--fcache=0" to the command line. That hurts performance though and probably defeats the purpose of using -O2.
FlexGUI contains fastspin, so that's the one you probably want unless you're just looking for command line tools.
This release has many bug fixes. The GUI is mostly unchanged, except I did change the Library Directories... dialog box to allow for multiple library directories to be selected.
The BASIC-side of the Flex house is impressively stable and for the most part well-behaved. The ability to drop-down into assembler, or to call Spin routines from BASIC so simply is a huge benefit to me. If anyone lurking has been “on-the-fence” about trying this, you owe it to yourself to try it.
Thanks, @JRoark. Someone noticed a bug in the dialog that switches between P1 and P2, so I've uploaded a slightly revised version 4.0.0b that fixes it. If you're not switching between the platforms you won't need to re-download.
"flexgui.zip" is the GUI and has everything you need to develop programs for P1 or P2. If you want just the command line tools you can download spin2cpp.zip and/or fastspin.zip. Spin2cpp is the general tool for converting Spin, BASIC, and C to C++ or PASM. fastspin is a simplified command line tool for compiling executable binaries.
When using FlexGUI 4.0.1, under Win10 and coding in BASIC for the FLiP:
I was reading the doc for the command line switches for PropLoader here: https://github.com/parallaxinc/PropLoader, and it seems that FlexGUI uses a "-k" option when calling PropLoader that isn't defined. What does "-k" do? Here is what the doc says:
PropLoader v1.0-43 (2018-12-01 13:55:21 g7445ae2)
usage: proploader [options] [<file>]
options:
-b <type> select target board and subtype (default is 'default:default')
-c display numeric message codes
-D var=value define a board configuration variable
-e program eeprom (and halt, unless combined with -r)
-f <file> write a file to the SD card
-i <ip-addr> IP address of the Parallax Wi-Fi module
-I <path> add a directory to the include path
-n <name> set the name of a Parallax Wi-Fi module
-p <port> serial port
-P show all serial ports
-r run program after downloading (useful with -e)
-R reset the Propeller
-s do a serial download
-t enter terminal mode after the load is complete
-T enter pst-compatible terminal mode after the load is complete
-v enable verbose debugging output
-W show all discovered wifi modules
-? display a usage message and exit
file: binary file to load (.elf or .binary)
-k means to prompt the user before exiting; it acts to "k"eep the terminal window open so error messages don't flash by too fast to read. It's something I added to proploader, and I guess I forgot to update the usage() message for it.
@ersmith ... nono ... your version (totalspectrum/PropLoader) has "-k" and "-q" and I think "upstream" (parallaxinc/PropLoader) should adopt both too. The versions have diverged a bit. Both now have commits the other one does not have.
$ git pull
Already up to date.
$ git log --max-count=1
commit 91922307854c6de4ea2774ab4383a2588dc9b822 (HEAD -> master, origin/master, origin/HEAD)
Author: Eric Smith <ersmith@totalspectrum.ca>
Date: Mon Oct 15 13:52:17 2018 -0300
added -k flag to prompt before exit
$ proploader -? | awk 'NR==1 || /-[kq]/'
PropLoader v1.0-41 (2019-07-15 17:52:52 g9192230)
-k prompt before exiting due to an error
-q during terminal display check for exit status from Propeller
How does the -q option work? Does the prop send a character string that causes the terminal emulator to exit?
Yes, the sequence $FF $00 $xx indicates that the terminal emulator should exit with code $xx. That particular sequence is not a legal UTF-8 character, so it should generally be safe in text output. But obviously there are binary applications for which we don't want to treat any sequences specially, so "-q" is not the default.
I think "-q" started to show up in PropGCC's "propeller-load" and turned out to be useful for automating test snippets by the propeller program being able to actively close the terminal routines and is available in "propeller-load", Eric's "PropLoader" version and a not yet accepted PR for "p1load" (it only lacks the "-q" option detection, the terminal stuff already has code for handling that exit). Maybe SpinSim would benefit from it too? Just for compatibility with other loaders? Currently it terminates cleanly when the last cog is shut down which often is [good enough]™.
"propeller-load -?" explains it:
[ -q ] quit on the exit sequence (0xff, 0x00, status)
Sending "255, 0, status" will terminate the terminal and "status" shall be the exit code of the loader.
All: Good input on the -k option. Makes sense! Thank you one and all.
@ersmith This is getting awfully close to being nitpicking, but would you consider adding a "Select All" function to the "Edit" menu in FlexGui? I'm working with some decent size files and it would make things smoother sometimes. And, since you've got the FlexGUI code open anyway, (cough-cough), is there any chance you could also add that same feature to the right mouse button menu as well?
Fair warning: I'm also fixin' to ask you for a pop-up ASCII character chart as well, (and likely in two flavors: Propeller, and traditional ASCII) but I sort of wanted to wait until you were done cussin' me for the first feature request.
I should note that bribes for said modifications may be available. If you'll PM me an address and the name of your favorite imbibement, I'll have a discussion with a certain "jolly old elf" shortly...
When using FlexGUI 4.0.1, under Win10 and coding in BASIC for the FLiP:
@ersmith There seems to be a bug in the floating point comparisons. It appears that the comparison operators are not handling the sign of a floating point number properly. The code:
OPTION EXPLICIT
CONST HEAPSIZE = 4092
dim cnt as single
dim cnt_Min as single
dim cnt_Max as single
cnt = 0.0
cnt_MAX = -999.0 'set our MAX to a very low number initially
cnt_MIN = 999.0 'set our MIN to a very high number initially
for cnt = -20.0 to +20.0 step 2.0
if cnt > cnt_MAX then
cnt_MAX = cnt 'save new maximum value
end if
if cnt < cnt_MIN then
cnt_MIN = cnt 'save new minimum value
end if
print "Cnt: ";cnt, " Min: "; cnt_MIN, " Max: "; cnt_Max
next cnt
Wow, that was a nasty bug @JRoark. Thanks for finding it. The root cause was a typo in the floating point comparison function, which should be fixed now.
I've uploaded version 4.0.2 to the usual places.
As for your GUI changes, I may be able to do a "select all" (I haven't had a chance to look at it yet). An ASCII table seems more like the kind of thing that belongs in an external tool.
When using FlexGUI 4.0.2, under Win10 and coding in BASIC for the FLiP:
@ersmith The "Edit -> Search" feature in FlexGUI seems to have broken. The search dialog comes up normally, and it allows you to specify the text to search, but when you click "Next", it all goes kablooey. This is the error that pops up:
bad command "tag": must be configure, cget, invoke, instate, state, or identify
bad command "tag": must be configure, cget, invoke, instate, state, or identify
while executing
"$w tag ranges hilite"
(procedure "searchrep'next" line 3)
invoked from within
"searchrep'next .toolbar.compileRun"
invoked from within
".sr.bn invoke "
invoked from within
".sr.bn instate !disabled { .sr.bn invoke } "
invoked from within
".sr.bn instate pressed { .sr.bn state !pressed; .sr.bn instate !disabled { .sr.bn invoke } } "
(command bound to event)
That isn't remotely a show stopper, but when you roll-out the next version it would be nice to have the search feature again.
Edited to add:
There also seems to be a "turnaround" bug on the USB port. If, after downloading code, you immediately issue a "PRINT" statement, the first dozen (or more) characters displayed will be garbage. If however, you put a short delay before the PRINT statement (50 mS seems to work really well for me), then it's fine.
This code causes garbage on the USB terminal:
' pauseMS(50) '<- delay is commented out
print "The quick brown fox... (aw phooey... stop me if you've heard this one)"
gives:
Opening file 'D:/Flex2Gui/flexgui/test.binary'
Downloading file to port COM4
1908 bytes sent
Verifying RAM
Download successful!
[ Entering terminal mode. Type ESC or Control-C to exit. ]
ÇÇÇ ÇÇÇÇ Ç Ç ÇÇÇÇÇÇ Ç╪∞φÉbrown fox... (stop me if you've heard this one)
This code works fine every time:
pauseMS(50) '<- 50 mS delay
print "The quick brown fox... (aw phooey... stop me if you've heard this one)"
gives:
Opening file 'D:/Flex2Gui/flexgui/test.binary'
Downloading file to port COM4
2128 bytes sent
Verifying RAM
Download successful!
[ Entering terminal mode. Type ESC or Control-C to exit. ]
The quick brown fox... (stop me if you've heard this one)
The "turnaround" bug is machine-speed dependent. On a very fast machine, it's very evident. On an old clunker-box, I cant replicate it at all.
Comments
I boiled-down the "Out Of Memory" code to an uber-thin test case. If you copy and run this with the debug window open, after 3-4 loops, you'll get an "Out of Memory" message up the serial channel and the FLIP sort of wanders-off somewhere.
You can uncomment the _gc_free() and _gc_collect() in any combination and the error still persists. Same goes for setting TMP$="". Putting this code into a SUB doesn't seem to have much effect either.
I'm stumped. @ersmith, your garbage collector just doesn't seem to like me...
Testing on Propeller1/SpinSim...
Maybe "str$()" is the problem?
Even this fails:
A byte later: No comment!
;-)
Thank you! I'll give those changes a try here.
@JRoark and @yeti:
Yes, str$ is broken . It appears that creating a temporary function inside another function can create an infinite loop that prevents garbage collection from happening. I'll have to think about the right solution for that, but for now you can replace the fastspin file include/libsys/strings.bas with the one attached to this message to get str$ working properly again.
Thanks for your help finding this!
@ersmith added the VAL() function when I wasnt looking. Sneaky devil! On the next doc cycle, you might add that to the keywords along with a brief description.
Edited to add: VAL() has some bugs. VAL() doesnt handle anything to the right of the decimal point and it also does not like the presence of a sign at all. But the basic "VAL()" for unsigned integers works nicely. So it may be that I've stumbled onto one of those "I wasn't actually ready to release that" sort of things... which explains why it's not in the manual yet.
I thought "VAL()", reading input and reading "DATA ..." might be related.
Then I stumbled over: ...where the result looks ok but what tries fastspin to tell my by "warning: : Internal error, unexpected COG label"?
VAL is kind of half-baked so far, yes, although the sign bug is not supposed to happen. I'll fix that.
I'm not sure we want to pull in all of the floating point code for every use of VAL, but on the other hand it would be nice to have val("1234.56") return the correct value. Maybe we need both VAL# and VAL%, and make plain VAL the same as VAL#?
Thanks,
Eric
@ersmith I haz an error, bigly. This only happens when Options -> Full Optimization is selected, but I thought I'd pass it along just the same. It never happens when Options -> Default Optimization is selected. When I select Options -> No Optimization it doesn't error-out, but the resulting file size exceeds the Prop1's memory so I'm not sure it's relevant.
I'd post the code, but I'm somewhere north of 2000 lines of BASIC and some non-trivial amount of Spin with embedded assembly, so it'd be a slog. That being said, if I must, I'll do a binary divide and conquer to see if I can isolate the offending chunk.
Welcome back, David! FastSpin C is in much better shape than it was, but there are still plenty of things that need improvement. My goal for 4.0.0 was to get BASIC stable (which I think has been achieved) and I'm turning to C next. There's a c-testsuite on github that I've started working with and it's already turned up some interesting bugs in the C support.
https://github.com/totalspectrum/flexgui/releases/latest
https://github.com/totalspectrum/spin2cpp/releases/latest
FlexGUI contains fastspin, so that's the one you probably want unless you're just looking for command line tools.
This release has many bug fixes. The GUI is mostly unchanged, except I did change the Library Directories... dialog box to allow for multiple library directories to be selected.
The BASIC-side of the Flex house is impressively stable and for the most part well-behaved. The ability to drop-down into assembler, or to call Spin routines from BASIC so simply is a huge benefit to me. If anyone lurking has been “on-the-fence” about trying this, you owe it to yourself to try it.
Well done, Eric!
***cough*** ...commit time stamps... ***cough***
Inline LMM-PASM may lower the hurdle to start looking at PASM a lot.
Using "stdio" or "stdlib" stuff in Spin and BASIC is fun too!
And not to forget: You can include "fastspin -w" compiled and "wrapped" cog objects in bytecode Spin programs.
!!!
I 2nd this!
👏👏👏 Thanks, Eric! 👏👏👏
https://github.com/totalspectrum/flexgui/releases/latest
https://github.com/totalspectrum/spin2cpp/releases/latest
"flexgui.zip" is the GUI and has everything you need to develop programs for P1 or P2. If you want just the command line tools you can download spin2cpp.zip and/or fastspin.zip. Spin2cpp is the general tool for converting Spin, BASIC, and C to C++ or PASM. fastspin is a simplified command line tool for compiling executable binaries.
I was reading the doc for the command line switches for PropLoader here: https://github.com/parallaxinc/PropLoader, and it seems that FlexGUI uses a "-k" option when calling PropLoader that isn't defined. What does "-k" do? Here is what the doc says:
Yes, the sequence $FF $00 $xx indicates that the terminal emulator should exit with code $xx. That particular sequence is not a legal UTF-8 character, so it should generally be safe in text output. But obviously there are binary applications for which we don't want to treat any sequences specially, so "-q" is not the default.
I think "-q" started to show up in PropGCC's "propeller-load" and turned out to be useful for automating test snippets by the propeller program being able to actively close the terminal routines and is available in "propeller-load", Eric's "PropLoader" version and a not yet accepted PR for "p1load" (it only lacks the "-q" option detection, the terminal stuff already has code for handling that exit). Maybe SpinSim would benefit from it too? Just for compatibility with other loaders? Currently it terminates cleanly when the last cog is shut down which often is [good enough]™.
"propeller-load -?" explains it: Sending "255, 0, status" will terminate the terminal and "status" shall be the exit code of the loader.
@ersmith This is getting awfully close to being nitpicking, but would you consider adding a "Select All" function to the "Edit" menu in FlexGui? I'm working with some decent size files and it would make things smoother sometimes. And, since you've got the FlexGUI code open anyway, (cough-cough), is there any chance you could also add that same feature to the right mouse button menu as well?
Fair warning: I'm also fixin' to ask you for a pop-up ASCII character chart as well, (and likely in two flavors: Propeller, and traditional ASCII) but I sort of wanted to wait until you were done cussin' me for the first feature request.
I should note that bribes for said modifications may be available. If you'll PM me an address and the name of your favorite imbibement, I'll have a discussion with a certain "jolly old elf" shortly...
@ersmith There seems to be a bug in the floating point comparisons. It appears that the comparison operators are not handling the sign of a floating point number properly. The code:
The result:
I'm really surprised that this wasn't found earlier!
I've uploaded version 4.0.2 to the usual places.
As for your GUI changes, I may be able to do a "select all" (I haven't had a chance to look at it yet). An ASCII table seems more like the kind of thing that belongs in an external tool.
@ersmith The "Edit -> Search" feature in FlexGUI seems to have broken. The search dialog comes up normally, and it allows you to specify the text to search, but when you click "Next", it all goes kablooey. This is the error that pops up: That isn't remotely a show stopper, but when you roll-out the next version it would be nice to have the search feature again.
Edited to add:
There also seems to be a "turnaround" bug on the USB port. If, after downloading code, you immediately issue a "PRINT" statement, the first dozen (or more) characters displayed will be garbage. If however, you put a short delay before the PRINT statement (50 mS seems to work really well for me), then it's fine.
This code causes garbage on the USB terminal: This code works fine every time:
The "turnaround" bug is machine-speed dependent. On a very fast machine, it's very evident. On an old clunker-box, I cant replicate it at all.