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

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

1111214161755

Comments

  • There seems to be an issue with _lockrel(x) as it does not find it so I used _lockclr(x).

    Mike

  • @iseries said:
    There seems to be an issue with _lockrel(x) as it does not find it so I used _lockclr(x).

    Mike

    In waht context are you finding that issue?

  • @ersmith said:
    I've posted a .dmg file for Mac users to my Patreon page (https://www.patreon.com/totalspectrum). This is my first time signing a Mac application, and the process took much longer to figure out than I'd expected :( but hopefully this will make things easier for Mac users.

    That link goes to a 404?

  • ersmithersmith Posts: 6,068
    edited 2021-03-10 16:55

    @"Shawn Lowe" said:

    @ersmith said:
    I've posted a .dmg file for Mac users to my Patreon page ( https://www.patreon.com/totalspectrum ). This is my first time signing a Mac application, and the process took much longer to figure out than I'd expected :( but hopefully this will make things easier for Mac users.

    That link goes to a 404?

    The forum software doesn't terminate the URL at ")" :(. Here it is again:

    https://www.patreon.com/totalspectrum

    (It's also in my signature.)

  • @ersmith said:

    The forum software doesn't terminate the URL at ")" :(. Here it is again:

    Well yes, you need to put spaces around it. Alternatively, use an explicit hypelink like this: [Link text](http://example.com/index.html)

  • This is the error I get with locks

    testLock.c:45: error: unknown identifier _lockrel used in function call
    testLock.c:45: error: Unknown symbol _lockrel

    void DoLock(void *par)
    {
        Lock = _locknew();
    
        while (1)
        {
            _locktry(Lock);
            _waitms(1000);
            _lockrel(Lock);
            _waitms(1000);
        }
    }
    

    Mike

  • Ah, I see (or "C"). Thanks, Mike, I will add an alias from _lockrel to _lockclr.

  • JaanDohJaanDoh Posts: 129
    edited 2021-03-12 00:11

    I've just started to use FlexProp and am having a little bit of a problem compiling some code....
    I also have another question too following the code below related to my first problem.

    `
    Class clsJD_Fwk_CoreFlags1
    '
    '
    '-> [Definition] CoreFlags1
    dim _CoreFlags1 as ubyte
    '
    '-> [Definition] CoreFlags1 Structure
    '-> CoreFlags1 Object Structure
    ' bit0 Enabled (0=False/1=True)
    ' bit1 Visible (0=False/1=True)
    ' bit2 reserved
    ' bit3 reserved
    ' bits4 reserved
    ' bits5 reserved
    ' bits6 reserved
    ' bits7 reserved

    function GetEnabled() as byte
    '
    GetEnabled = _CoreFlags1.bitfield(00000_00000)
    '
    end function

    function GetVisible() as byte
    '
    GetVisible = _CoreFlags1.bitfield(00000_00001)
    '
    end function
    `

    When I compile the above I get the following errors

    "D:/MY_PROJECT/flexprop/flexprop/bin/flexspin" -2 -l -D_BAUD=230400 -O1 --fixedreal -I "D:/MY_PROJECT/flexprop/flexprop/include" "E:/MY_PROJECT/Versions/FlexProp-1/clsJD_Fwk_CoreFlags1.bas"
    Propeller Spin/PASM Compiler 'FlexSpin' (c) 2011-2021 Total Spectrum Software Inc.
    Version 5.2.0 Compiled on: Feb 27 2021
    E:/MY_PROJECT/Versions/FlexProp-1/clsJD_Fwk_CoreFlags1.bas:42: error: Unable to determine class type
    E:/MY_PROJECT/Versions/FlexProp-1/clsJD_Fwk_CoreFlags1.bas:42: error: Method reference on non-class _CoreFlags1
    E:/MY_PROJECT/Versions/FlexProp-1/clsJD_Fwk_CoreFlags1.bas:42: error: Expecting object for dereference of bitfield
    E:/MY_PROJECT/Versions/FlexProp-1/clsJD_Fwk_CoreFlags1.bas:50: error: Unable to determine class type
    E:/MY_PROJECT/Versions/FlexProp-1/clsJD_Fwk_CoreFlags1.bas:50: error: Method reference on non-class _CoreFlags1
    E:/MY_PROJECT/Versions/FlexProp-1/clsJD_Fwk_CoreFlags1.bas:50: error: Expecting object for dereference of bitfield

    I can only assume that the reason this is happening is because BITFIELD is not a supported keyword in basic?

    So how should I address this?
    1 - revert to spin ( This works for me as there are no string in this object and I'd like to use FlexProp for its string handling capability - So later I can mix n match the objects? Spin/Spin2/Basic)
    2 - work around it using below scripts
    `
    '-> [Pri] GetByteBit
    PRI GetByteBit(plByteAddr, pbBitPos) | tmpData
    '
    '-> Get Byte Bit
    'Procedure: GetByteBit()
    'Overview: This procedure reads and returns a specific bit in a byte (0-7)
    'Inputs: plByteAddr - The address where the data byte can be found
    ' pbBitPos - Bit position in the data byte
    'Outputs: tmpData - zero or one from the data byte at bit position specified
    '
    '-> Process request
    tmpData := BYTE[plByteAddr]
    RETURN ((tmpData & (1<<pbBitPos)) >> pbBitPos)
    '
    'End Pub

    '-> [Pri] SetByteBit
    PRI SetByteBit(plByteAddr, pbBitPos)
    '
    '-> Set Byte Bit
    'Procedure: SetByteBit()
    'Overview: This procedure sets the bit specified in a data byte (0-7)
    'Inputs: plByteAddr - The address where the data byte can be found
    ' pbBitPos - Bit position in the data byte
    'Outputs: None
    '
    '-> Process request '
    BYTE[plByteAddr] := BYTE[plByteAddr] | (1<<pbBitPos)
    '
    'End Pub

    '-> [Pri] ClrByteBit
    PRI ClrByteBit(plByteAddr, pbBitPos)
    '
    '-> Clear Byte Bit
    'Procedure: ClrByteBit()
    'Overview: This procedure clears the bit specified in a data byte (0-7)
    'Inputs: plByteAddr - The address where the data byte can be found
    ' pbBitPos - Bit position in the data byte
    'Outputs: None
    '
    '-> Process request
    BYTE[plByteAddr] := BYTE[plByteAddr] & (!(1<<pbBitPos))
    '
    'End Pub
    `

    SORRY for the formatting...
    I DID use the forum CODE tag but I think its broke because everything is left aligned..

    EDIT

    Sorry I forgot my second question, which relates to the IDE code formatting...

    Currently if I use ** Sub, Function, End If, If** etc... the code remains black
    But If I use sub, function, end if, if etc... the code then becomes colored blue or whatever color...

    Is there anyway I can change it so it accepts and colors the code keywords Capitalised?

    Thanks.

  • I'm not familiar with the ".bitfield()" notation in BASIC... do you recall which version of BASIC has that?

    I'd probably just use direct bit manipulations, something like:

    const enabledMask = 0x01
    const visibleMask = 0x02
    ...
    Function GetEnabled() as Integer
      return (_CoreFlags1 AND enabledMask) <> 0
    End Function
    Function GetVisible() as Integer
      return (_CoreFlags1 AND visibleMask) <> 0
    End Function
    
  • For your second question, the syntax highlighting is set up in flexprop\src\gui.tcl, in the function setSyntaxHighlightingBasic. To support keywords with just the first letter capitalized you'll have to change the lines like:

        foreach i $keywordslower {
        lappend keywordsupper [string toupper $i]
        }
    

    to

        foreach i $keywordslower {
        lappend keywordsupper [string toupper $i]
        lappend keywordsupper [string totitle $i]
        }
    

    I'll add that to the next release, but it's easy for you to change locally. Depending on how you spell type words like "long" you may want to do the same kind of thing to $typewordsupper and $opwordsupper as well.

  • Thank You for such a prompt resolution.

    I should be able to mange the keywords change easy enough with your example above.
    Sorry I meant (is it called) FlexBasic The basic in the Ide...

    Cheers too for the masks on the bit state function...

  • Hello all,

    Thank you Eric for Flexprop !

    I am using the Propeller tool (v2.5.2) blinky example ('Hello Blinky.spin2') into Flexprop (v5.2). It reports error in the debug functions:

    Line 12:  debug(`term message pos 200 500 size 12 4 textsize 40 rgbi8x)         
    Line 14:  debug(`message 'Hello World!')            'Display "Hello World!" on computer screen
    
    C:/test.spin:12: error: syntax error, unexpected `
    C:/test.spin:14: error: syntax error, unexpected ` 
    
    

    Is this because I am missing the debug() library file? Or just because this is only available on Propeller Tool?
    How can I use the debug() function on Flexprop.

  • Here is an include file I made for use with Visual Code as it has code completion.

    You have the Smart pins definitions built into the compiler and Visual Code can not see them so this include helps to resolve those items.

    Mike

  • @Ramon : FlexProp does not support backticks in debug statements. It should have produced a warning instead of an error though, I'll fix that. But in the meantime you probably want to use the samples that come with FlexProp rather than the ones with Propeller Tool.

    Some regular (non-backtick) debug statements like uhex() and sdec() are available in FlexProp.

  • @iseries said:
    Here is an include file I made for use with Visual Code as it has code completion.

    You have the Smart pins definitions built into the compiler and Visual Code can not see them so this include helps to resolve those items.

    Thanks, Mike, I'll add that to the distribution. What's the purpose of the "Sudo" in the first comment?

    @RossH : Mike's smartpins.h has #defines for all of Chip's standard smartpin symbols. You may want to add this (or something like it) to Catalina.

  • "Sudo", Don't know, lost that brain cell some where. Have been using it now for several weeks.

    Mike

  • roglohrogloh Posts: 5,836
    edited 2021-03-14 03:00

    Hi @ersmith . Do you know why this simple test code example below using RECV wouldn't work when I send serial data? All I get are zeroes back from the serial receiver. I'm using 5.1.0 of your flexspin compiler. Is assigning a variable from RECV known to be working yet?

    OBJ
        f:"ers_fmt"
        serial:"SmartSerial"
    
    PUB test() : ch
        serial.start(115200)
        send:=@serial.tx
        send("test",13,10)    
        RECV:=@serial.rx
        repeat 
            ch := RECV()
            send(" got ",f.hexn(ch, 8))
    

    All I get is zeroes back when I press keys in the terminal...

    ( Entering terminal mode. Press Ctrl-] to exit. )
    test
    got 00000000 got 00000000 got 00000000 got 00000000 got 00000000 got 00000000 got 00000000

    Also if I simplify to this:

        recv:=@serial.rx
        repeat 
            send(" got ",f.hex(RECV()))
    

    I get this error:
    Propeller Spin/PASM Compiler 'FlexSpin' (c) 2011-2021 Total Spectrum Software Inc.
    Version 5.1.0 Compiled on: Mar 13 2021
    testrecv.spin2
    |-ers_fmt.spin2
    |-SmartSerial.spin2
    testrecv.spin2:13: error: Bad number of parameters in call to hex: expected 1 found 0

  • frank freedmanfrank freedman Posts: 1,983
    edited 2021-03-14 03:27

    @ersmith said:

    @iseries said:
    Here is an include file I made for use with Visual Code as it has code completion.

    You have the Smart pins definitions built into the compiler and Visual Code can not see them so this include helps to resolve those items.

    Thanks, Mike, I'll add that to the distribution. What's the purpose of the "Sudo" in the first comment?

    @RossH : Mike's smartpins.h has #defines for all of Chip's standard smartpin symbols. You may want to add this (or something like it) to Catalina.

    Perhaps pseudo (false or not real, renamed in this case? i.e. pseudo-code) rather than sudo (Xnix super user do command)

  • @rogloh : Sorry Roger, I thought I had fixed RECV in 5.1.0, but somehow the fix never made it to the repository :(. It's pushed up there now and will be in the next release.
    Thanks for the bug report.

  • Ken GraceyKen Gracey Posts: 7,395
    edited 2021-03-14 20:41

    Hello @ersmith

    I'm preparing a Quick Byte to show how to use Visual Studio Code and FlexSpin. I have properly configured VSC with the JSON tasks, keymappings, etc. When I compile my sample code I receive this:


    Propeller Spin/PASM Compiler 'FlexSpin' (c) 2011-2021 Total Spectrum Software Inc.
    Version 5.0.8 Compiled on: Jan 24 2021
    01_quadrature_demo.spin2
    |-jm_fullduplexserial.spin2
    |-|-jm_nstr.spin2
    |-jm_ansi.spin2
    01_quadrature_demo.p2asm
    Done.
    Program size is 4772 bytes

    When I compile and download, I receive the following:


    Executing task: & 'C:\Program Files\flexprop\bin\loadp2.exe' -b230400 01_quadrature_demo.binary -t
    ERROR: got incorrect initial chksum: @@ (00 40 40)
    The terminal process "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -Command & 'C:\Program Files\flexprop\bin\loadp2.exe' -b230400 01_quadrature_demo.binary -t" terminated with exit code: 1.
    Press any key to close the terminal.

    I've attached the zip file (some of JonnyMac's code).

    Thanks,

    Ken Gracey

  • RaymanRayman Posts: 14,737
    edited 2021-03-14 20:58

    @"Ken Gracey" I just tried it and it worked (well, it didn't give any errors anyway)... Try this loadp2.

    I attached the binary too. Compiled with FlexProp: Version 5.0.8 Compiled on: Jan 24 2021

  • @Rayman said:
    @"Ken Gracey" I just tried it and it worked (well, it didn't give any errors anyway)... Try this loadp2.

    I attached the binary too. Compiled with FlexProp: Version 5.0.8 Compiled on: Jan 24 2021

    Thanks @Rayman - I replaced my loadp2.exe and still receive the following error about checksum:

    ERROR: got incorrect initial chksum: @@ (00 40 40)

    I'm not sure what the error means - maybe the compiled test and downloaded binary don't match in size or some other value?

    Ken Gracey

  • RaymanRayman Posts: 14,737

    @"Ken Gracey" Does it work with FlexProp? That's a strange error. I'd guess it's a hardware issue... I may have seen something like that before, but was a long time ago. Maybe board needs more power?

  • @Rayman said:
    @"Ken Gracey" Does it work with FlexProp? That's a strange error. I'd guess it's a hardware issue... I may have seen something like that before, but was a long time ago. Maybe board needs more power?

    Same error on FlexProp. There must be something simple and wrong with my setup, especially if it works on yours.

    Ken Gracey

  • RaymanRayman Posts: 14,737
    edited 2021-03-14 22:19

    I was using an eval board with nothing connected to it...

    Hope you figure it out!

  • I think I've seen this message occasionally before myself (on a Mac) but can't really recall what if anything I did to get rid of it. If an SD card is fitted to the P2 board try yanking that out perhaps...? Or yanking the USB cable and replacing and/or replugging it to re-enumate etc.

  • RossHRossH Posts: 5,476

    @ersmith said:

    >

    @RossH : Mike's smartpins.h has #defines for all of Chip's standard smartpin symbols. You may want to add this (or something like it) to Catalina.

    Ah! Thanks. I figured someone would do this eventually. I will look at adding them to Catalina and issue an update.

    Ross.

  • Just looked at the (latest) loadp2 code:

            // every so often we get a 0 byte first before the checksum; if
            // we do, throw it away
            if (buffer[0] == 0 && buffer[2] == '@') {
                buffer[0] = buffer[2];
                rx_timeout((uint8_t *)&buffer[2], 1, 100);
            }
            if (buffer[0] != '@' || buffer[1] != '@') {
                printf("ERROR: got incorrect initial chksum: %c%c%c (%02x %02x %02x)\n", buffer[0], buffer[1], buffer[2], buffer[0], buffer[1], buffer[2]);
                promptexit(1);
            }
    

    It appears that you have been getting a 0 followed by two @'s which doesn't make sense as being possible in the logic above now, so are you using the latest 0.046 version of loadp2 Ken? It looks like Eric has made a recent change in that area to deal with this timeout and checked it into github 3 days ago.

  • ersmithersmith Posts: 6,068
    edited 2021-03-14 23:03

    @"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.

  • RaymanRayman Posts: 14,737
    edited 2021-03-15 00:31

    I'm surprised this is just showing up now, after all this time...
    I don't think I've seen this issue before.
    Did see strange things like this when I had power shorted to ground on a connected board though...
    (I was surprised it did anything at all, but it did... )

Sign In or Register to comment.