Shop OBEX P1 Docs P2 Docs Learn Events
FlexProp: a complete programming system for P2 (and P1) - Page 15 — Parallax Forums

FlexProp: a complete programming system for P2 (and P1)

1121315171855

Comments

  • @ersmith said:
    @"Ken Gracey" as Roger said there's a recent fix to loadp2 to work around your issue (which seems to crop up sometimes on P2 Edge boards, I'm not sure why). You'll need loadp2 v046, which I've attached to this message. Not sure how to make this work with VSC, but in FlexProp just replace the flexprop\bin\loadp2.exe with the one from this zip file.

    Thanks Eric - I had to leave my P2 hardware on my desk at the office, but I'll be back in the morning to try this out.

    Ken Gracey

  • While I've not tried to compile/download with the latest loadp2 v046, I've got a Quick Byte in development to show how to use FlexSpin with Visual Studio Code. Take a look and feel free to send me any comments kgracey@parallax.com or post them on the Quick Byte page. Uses lots of work from @"Stephen Moraco" too.

    https://www.parallax.com/visual-studio/

    Great stuff, FlexSpin! A tremendous boost to the P2 community!

    Ken Gracey

  • @"Ken Gracey" It looks like you are using Version 5.0.8. The current version is 5.2.x (5.2.1-beta actually, with 5.2.0 the last "official" build). Eric has made a bunch of changes under the hood since 5.0.8. I know time is precious at your desk, but if possible you might want to upgrade to avoid hitting some of the old bugs. The 5.2.x version is significantly better.

  • Updated FlexSpin to 5.2.0 but I still receive the chksum error, unfortunately. I'll try to round up Eric for a closer look.

    Thank you -

    Ken Gracey

  • @"Ken Gracey" : for the checksum problem you're seeing you need loadp2 v046 (which I posted earlier in the thread). That's the newest version of loadp2, even newer than the one in flexprop 5.2.0.

  • @ersmith said:
    @"Ken Gracey" : for the checksum problem you're seeing you need loadp2 v046 (which I posted earlier in the thread). That's the newest version of loadp2, even newer than the one in flexprop 5.2.0.

    Success!

    Ken Gracey

  • RaymanRayman Posts: 14,738

    Great news! @ersmith Any idea what is that causes this? I don't think I've had this problem on the computers I've used...

  • @Rayman said:
    Great news! @ersmith Any idea what is that causes this? I don't think I've had this problem on the computers I've used...

    I think it's something to do with the serial port on the board rather than on the computer side. But I don't know specifically what's wrong.

  • @"Ken Gracey" I haven't had a chance to go through the VSC setup yet, but I did notice that youmentioned needing an "ANSI compliant terminal program of your choice" for serial debug. loadp2 has a terminal program built in to it, so it should be possible to use that -- just pass the "-t" argument on the loadp2 command line. Or better yet use "-9.", which provides not just a terminal but also a host file server so the P2 can read files from the host.

  • RaymanRayman Posts: 14,738

    Oh, I see. Wonder if Parallax made some change in the FT_Prog eeprom settings in the FT231X device.

  • @ersmith said:
    @"Ken Gracey" I haven't had a chance to go through the VSC setup yet, but I did notice that youmentioned needing an "ANSI compliant terminal program of your choice" for serial debug. loadp2 has a terminal program built in to it, so it should be possible to use that -- just pass the "-t" argument on the loadp2 command line. Or better yet use "-9.", which provides not just a terminal but also a host file server so the P2 can read files from the host.

    Eric, I will certainly make that addition. I think it's a matter of editing the JSON file in VSC as shown:


    "label": "downloadP2",
    "type": "shell",
    "command": "/Applications/Flexprop/bin/loadp2.mac",
    "windows": {
    "command": "C:\Program Files\flexprop\bin\loadp2.exe-9",

    I haven't tried this yet. Is that the way I'd do this? I'm not sure where I'm going yet, but I'm getting there, a little bit at a time.

    Thanks,

    Ken Gracey

  • RaymanRayman Posts: 14,738

    I'd guess you'd need a space before "-9" and then you need another space and then the directory you want to have connected.

  • Here's how I do it (macOS or Linux... You need a slight variation for WIN 10):

    "command": "${HOME}/flexprop/bin/loadp2",
    "args": [
    "-b230400",
    "'${fileBasenameNoExtension}.binary'",
    "-k",
    "-T"
    ]
    

    dgately

  • i have a question to PASM

        rep @done, #0
        drvnot #0
    done
        NOP
    

    here the rep command compiles to 00 02 DC FC = repeate the next #2 instructions forever

        rep @done, #0
    done drvnot #0
    

    compiles to 0 00 DC FC = repeate 0 instructions forever.

    is there a way to get the correct number of instructions #1?

  • @Surac : You've mis-read the binary. The S field is 9 bits, not 8 bits, so 00 02 DC FC has S=0 and D=1, i.e. it means "repeat 1 instruction forever".

  • Ahhhrg. Yes you are right

    Thank you

  • tritoniumtritonium Posts: 543
    edited 2021-03-18 22:51

    Hi @ersmith

    I am having trouble getting flexbasic to display leading zero's using 'print using', of hex and binary numbers.

    a bit of test code-

    'test of string printing
    
    dim as ulong x,y,z
    
    for x=1 to 1000 step 20
        print using "%%%%%%%%%%%%%%%%%%%"; x
        print using "%%%%%%%%%%%%%%%%%%%"; hex$(x)
        print using "%%%%%%%%%%%%%%%%%%%"; bin$(x)  
    next
    
    do
    loop
    

    Decimal works fine, but not hex and binary.

    Dave

  • JRoarkJRoark Posts: 1,215
    edited 2021-03-18 23:28

    Dave;
    X is a ulong so the leading zeros should indeed work. But the values being returned from Hex$ and Bin$ are strings, so try using LPad$ instead.

    Edited to add: you can also specify an optional second parameter in both Hex$ and Bin$ to output additional leading characters and avoid the overhead of LPad$:

    ‘’’
    for x=1 to 1000 step 20
    print using "%%%%%%%%%%%%%%%%%%%"; x
    print hex$(x, 19)
    print bin$(x, 19)
    next

  • @JRoark

    Bi Jove it works.!!!!
    Do you know in all my years of Basic programming I have NEVER come across that Lpad$.
    Also I never ever expected a mere microcontroller (as apposed to a microprocessor) to support half the stuff Eric has squeezed into Flexbasic. Every time I think 'I wonder if I can do this' - sure enough I can!!

    Thanks JRoark and Eric.

    Dave

  • The only place I have ever seen LPad$ (or the companion function RPad$) was in Microsoft BASIC PDS 7.x. I got really attached to it because it was so useful. Eric was gracious and let me sneak it into the STRINGS.BAS library somewhere around V5.0.x. :)

  • Thanks @JRoark for all you've contributed to FlexBasic... you've really done a lot to make it better.

  • I've uploaded FlexProp version 5.3.0 beta to my Patreon page so patrons can get a sneak peek at the new features (and try out the bleeding edge if they want to :)). Changes to the compiler include:

    • Added SimpleSerial object for P1/P2 compatibility
    • Added _lockrel() function for C
    • Added header file with smartpin definitions (not strictly necessary in flexspin, but useful for compatibility with other compilers and Visual Studio)
    • Allowed pin -1 to mean "no pin" in SmartSerial
    • Changed the trivial Spin stub in P1 code to be compatible with openspin (this allows flexspin to be used to make the PropLoader fastloader)
    • Changed handling of ? operator in Spin2 to be compatible with PNut
    • Extended DEBUG() capability to include some backtick features
    • Fixed argv[0] handling in the command line tools
    • Fixed use of FCACHE in inline assembly in LUT and COG functions
    • Fixed BASIC input when 127 (DEL) is read (Unix terminals use this for backspace)
    • Fixed a problem with parsing floating point numbers with 32 bit compilers
    • Fixed use of instructions as operators in DAT section
    • Ignored DEBUG statements completely unless -g is given
    • Really fixed RECV return value

    Changes to the GUI and other tools include:

    • Added syntax highlighting for keywords with just first letter capitalized
    • Fixed saving of compiler output window font
    • Removed dependency on openspin for P1 builds
    • Made PropLoader use ^] to exit instead of ESC
    • Made PropLoader terminal use VT-100 sequences
    • Merged PropLoader with latest from Parallax
    • Updated loadp2
  • @ersmith said:
    I've uploaded FlexProp version 5.3.0 beta to my Patreon page so patrons can get a sneak peek at the new features (and try out the bleeding edge if they want to :)). Changes to the compiler include:

    I just posted the following FlexProp issue in Git.

    While seeing what new DEBUG features for Spin2 are available in FlexProp 5.3.0-beta, I noticed that local variables are NOT initialized when entering a method().



  • So far as I know Spin has never guaranteed that local variables (other than result variables) are initialized to 0.

  • RaymanRayman Posts: 14,738
    edited 2021-03-19 17:48

    I wonder if Chip's Spin2 initializes local variables... I think I saw code once that counted on that...
    Spin1 manual says the return value is initialized to zero but all others are not...
    Spin2 docs don't say anything on this subject...

  • The variables just happen to be zero because Chip's compiler puts the stack in memory that is pre-cleared. Do the test multiple times and this is revealed.

    con _clkfreq = 200_000_000
    pub main()
    aaaa()
    aaaa()
    pub aaaa() | I, J, K
      debug(" No Assignment: ",udec_long(I), udec_long(J), udec_long(K))
      I := 0
      J := 1
      K := 2
      debug("After Assigned: ",udec_long(I), udec_long(J), udec_long(K))
    
  • pik33pik33 Posts: 2,383
    edited 2021-03-19 20:31

    I don't know if it is a good place to report a weird problem but here it is:

    Something (I don't know what) saved my spin2 file in UTF (don't exactly know what version) format and I didn't even know about this until I opened it in FlexProp.

    When I opened the file for edition I got something like this:

    p u b s t a r t ( )

    The FlexProp can compile this weird looking text without any error comment, but reading such thing is hard and editing is not possible.

    The Propeller Tool didn't notice anything. The Windows Notepad also opened the file without a problem.

    I converted the file to raw ASCII, so the problem with it is now gone and FlexProp displays it as it is supposed to be displayed.

  • Propeller Tool saves files as UTF16 when it sees any characters that it thinks don't encode into an 8 bit codepage (not sure which one is actually used. It's not pure ASCII, as it can handle my umlaut-containing name just fine. Hope it's not the default locale-dependant one, haha. Does @"Jeff Martin" know off the top of his head?)

    Anyways, it has been said that PropellerTool will eventually switch to UTF8 for saving, which doesn't cause these kinds of issues.

  • pik33pik33 Posts: 2,383
    edited 2021-03-19 21:19

    So maybe I put some of these non standard character, we have 9 of them here, in the comment (I learned to avoid these in variable names, as my favourite programming tool, Lazarus, doesn't accept anything which is not pure ASCII character) and then the Propeller Tool used UTF16 to save this :)

  • @Wuerfel_21 said:
    The variables just happen to be zero because Chip's compiler puts the stack in memory that is pre-cleared. Do the test multiple times and this is revealed.

    con _clkfreq = 200_000_000
    pub main()
    aaaa()
    aaaa()
    pub aaaa() | I, J, K
      debug(" No Assignment: ",udec_long(I), udec_long(J), udec_long(K))
      I := 0
      J := 1
      K := 2
      debug("After Assigned: ",udec_long(I), udec_long(J), udec_long(K))
    

    Thank you @Wuerfel_21 for the insight as to what is going on internally. I suppose you could exploit this "feature" by doing an increment on the local variable in each invocation to have that variable keep track of how many times you ran that routine. Probably not a good idea in the long term though ;-)

    So the mantra: "Always initialize or assign a value to local variables" is probably the best course of action...

Sign In or Register to comment.