Shop OBEX P1 Docs P2 Docs Learn Events
Visual Studio Code supports P2 development on Windows, Mac, Linux (yes, RPi) - Page 6 — Parallax Forums

Visual Studio Code supports P2 development on Windows, Mac, Linux (yes, RPi)

123468

Comments

  • jrullanjrullan Posts: 167
    edited 2023-01-25 01:44

    @"Stephen Moraco"

    I'm having trouble getting it to load when calling loadp2.

    I have my environmental variable FlexPropPath set to C:\######\flexprop\bin and have set the PATH variable with the additional entry: C:\######\flexprop\bin

    My tasks.json

    {
        // See https://go.microsoft.com/fwlink/?LinkId=733558
        // for the documentation about the tasks.json format
        "version": "2.0.0",
        "tasks": [
            {
                "label": "compileP2",
                "type": "shell",
                "osx": {
                  "command": "/Applications/flexprop/bin/flexspin.mac"
                },
                "windows": {
                  "command": "flexspin.exe"
                },
                "linux": {
                  "command": "/opt/flexprop/bin/flexspin"
                },
                "args": ["-2", "-Wabs-paths", "-Wmax-errors=99", "${fileBasename}"],
                "problemMatcher": {
                  "owner": "Spin2",
                  "fileLocation": ["autoDetect", "${workspaceFolder}"],
                  "pattern": {
                    "regexp": "^(.*):(\\d+):\\s+(warning|error):\\s+(.*)$",
                    "file": 1,
                    "line": 2,
                    "severity": 3,
                    "message": 4
                  }
                },
                "presentation": {
                  "panel": "shared",
                  "focus": true
                },
                "group": {
                  "kind": "build",
                  "isDefault": true
                }
              },
              {
                "label": "compileTopP2",
                "type": "shell",
                "osx": {
                  "command": "/Applications/flexprop/bin/flexspin.mac"
                },
                "windows": {
                  "command": "flexspin.exe"
                },
                "linux": {
                  "command": "/opt/flexprop/bin/flexspin"
                },
                "args": ["-2", "-Wabs-paths", "-Wmax-errors=99", "${config:topLevel}.spin2"],
                "problemMatcher": {
                  "owner": "Spin2",
                  "fileLocation": ["autoDetect", "${workspaceFolder}"],
                  "pattern": {
                    "regexp": "^(.*):(\\d+):\\s+(warning|error):\\s+(.*)$",
                    "file": 1,
                    "line": 2,
                    "severity": 3,
                    "message": 4
                  }
                },
                "presentation": {
                  "panel": "shared",
                  "focus": true
                },
                "group": {
                  "kind": "build",
                  "isDefault": true
                }
              },
              {
                "label": "downloadP2",
                "type": "shell",
                "osx": {
                  "command": "/Applications/flexprop/bin/loadp2.mac",
                  "args": ["-b230400", "${config:topLevel}.binary", "-t"]
                },
                "windows": {
                  "command": "loadp2.exe",
                  "args": ["-b230400", "${config:topLevel}.binary", "-t"]
                },
                "linux": {
                  "command": "/opt/flexprop/bin/loadp2",
                  "args": ["-b230400", "${config:topLevel}.binary", "-t", "-p/dev/ttyUSB0"]
                },
                "problemMatcher": [],
                "presentation": {
                  "panel": "shared",
                  "focus": true
                },
                "group": {
                  "kind": "test",
                  "isDefault": true
                },
                "dependsOn": ["compileTopP2"]
              },
              {
                "label": "flashP2",
                "type": "shell",
                "osx": {
                  "command": "/Applications/flexprop/bin/loadp2.mac",
                  "args": ["-b230400", "@0=/Applications/flexprop/board/P2ES_flashloader.bin,@8000+${config:topLevel}.binary", "-t", "-k"]
                },
                "windows": {
                  "command": "loadp2.exe",
                  "args": ["-b230400", "@0=${env:FlexSpinPath}/board/P2ES_flashloader.bin,@8000+${config:topLevel}.binary", "-t", "-k"]
                },
                "linux": {
                  "command": "/opt/flexprop/bin/loadp2",
                  "args": ["-b230400", "@0=/opt/flexprop/board/P2ES_flashloader.bin,@8000+${config:topLevel}.binary", "-t", "-p/dev/ttyUSB0"]
                },
                "problemMatcher": [],
                "presentation": {
                  "panel": "shared",
                  "focus": true
                },
                "group": {
                  "kind": "test",
                  "isDefault": true
                },
                "dependsOn": ["compileTopP2"]
              },
        ]
    }
    

    It stays trying to execute the loadp2 task:

    Is there something wrong in my configuration?

  • Try explicitly specifying the port (i.e. add a -pCOM7 or whatever your board comes up with to the command line). Is a good idea, anyways.

  • @Wuerfel_21 said:
    Try explicitly specifying the port (i.e. add a -pCOM7 or whatever your board comes up with to the command line). Is a good idea, anyways.

    Yes! Thanks @Wuerfel_21!!! That was it.

    This is the modified task in tasks.json:

              {
                "label": "downloadP2",
                "type": "shell",
                "osx": {
                  "command": "/Applications/flexprop/bin/loadp2.mac",
                  "args": ["-b230400", "${config:topLevel}.binary", "-t"]
                },
                "windows": {
                  "command": "loadp2.exe",
                  "args": ["-b230400", "${config:topLevel}.binary", "-t", "-pCOM9"]
                },
                "linux": {
                  "command": "/opt/flexprop/bin/loadp2",
                  "args": ["-b230400", "${config:topLevel}.binary", "-t", "-p/dev/ttyUSB0"]
                },
                "problemMatcher": [],
                "presentation": {
                  "panel": "shared",
                  "focus": true
                },
                "group": {
                  "kind": "test",
                  "isDefault": true
                },
                "dependsOn": ["compileTopP2"]
              },
    

    @"Stephen Moraco" may I suggest that the instructions for Windows in github be modified to account for this?

  • TommieBoyTommieBoy Posts: 26
    edited 2023-02-04 05:30

    I'm very excited about using a single IDE to try multiple programming languages, so thank you for Stephen Moraco and all the folks helping out on this. Hats off to you all.

    I've worked my way through the VS Code - User-wide Defined Tasks and I've hit a road block.

    Here are the details.

    • My project is in C:\VSCode Projects\Hello World
    • My project file contains:

      • main.c
      • settings.json
    • My settings.json looks like

    {
        "topLevel": "main"
     }
    

    It's resulted in the following error when I select CompileTopP2 "Variable ${config:toplevel} can not be resolved because setting 'topLevel' not found.

    Oddly enough I get the same error when I try to DownloadP2 or FlashP2 after I successfully CompileP2.

    Workarounds found:
    #1
    1) I noticed that I didn't have a .vscode folder, so I created one ...\Hello World\.vscode. Apparently it's a requirement but I missed that part.
    2) I moved my settings.json into it.
    This changed my error messages, but I was getting compiler errors.

    #2
    In tasks.json,, around line 50 looks like this...
    "args": ["-2", "-Wabs-paths", "-Wmax-errors=99", "${fileBasename}.spin2"],
    since I'm using a P1 and C, I edited it to
    "args": ["-Wabs-paths", "-Wmax-errors=99", "${fileBasename}.c"],

    Now it appears to work as expected except I don't have a terminal connected to my P1.

    Next
    Tackle the loader.

  • TommieBoyTommieBoy Posts: 26
    edited 2023-02-05 06:25

    I now have VS Code functioning for the P1 and C. My intention is to migrate from SimpleIDE to VS Code, but I don't have a P2 yet so I needed to make some adjustments.
    I also think it's a bad idea to try and learn two new things at the same time.

    I've made some 'temporary' modifications to the tasks.json file. Because I'm only using Windows, and plan to migrate to P2 soon, I limited the changes to only those required.
    I don't have the machines to test OSX and Linux.
    I understand that there is a plan to expand VS Code to the P1. My efforts are crude to what Stephen Moraco does!.

    I also kept the 'label' unchanged. When I select 'CompileP2', I know it will actually compile my P1.
    Here are my changes.

    Under "label": "compileP2", about 11 lines down, find the line
    "args": [ "-2" , "-Wabs-paths", "-Wmax-errors=99", "${fileBasename}. spin2 "], and modify it to
    "args": ["-Wabs-paths", "-Wmax-errors=99", "${fileBasename}. c" ]

    Under "label": "compileTopP2", about 11 lines down, find the line
    "args": [ "-2", "-Wabs-paths", "-Wmax-errors=99", "${config:topLevel}. spin2 "], and modify it to
    "args": ["-Wabs-paths", "-Wmax-errors=99", "${config:topLevel}. c "],

    Under "label": "downloadP2", about 7 lines down, find the 2 lines
    "command": "loadp2.exe",
    "args": ["-b230400", "${config:topLevel}.binary", "-t"] and replace them with

    "command": "proploader.exe",
    "args": ["-pCOM12", "${config:topLevel}.binary", "-t"] <-- don't forget to replace COM12 with your COM port

    Under "label": "flashP2", about 7 lines down, find two lines
    "command": "loadp2.exe",
    "args": ["-b230400", "@0=${env:FlexSpinPath}/board/P2ES_flashloader.bin,@8000+${config:topLevel}.binary", "-t", "-k"] and replace them with

    "command": "proploader.exe",
    "args": ["-pCOM12", "-e", "-r", "${config:topLevel}.binary", "-t"] <-- don't forget to so course replace COM12 with your COM port

    The other loader that I've tried was Payloader by @RossH. It has some nice features but it doesn't currently support WIFI transfers.

  • Ok, so I have downloaded and installed vscode to my Linux Mint laptop and installed the Jason.task folder in my Library folder where I do all of my P2 programming. Now I have several sub folders in this folder, do I have to install task.jason in each folder in the main Library folder or is installing it in the top folder enough?
    Jim

  • Stephen MoracoStephen Moraco Posts: 303
    edited 2023-02-10 05:34

    @RS_Jim said:
    Ok, so I have downloaded and installed vscode to my Linux Mint laptop and installed the Jason.task folder in my Library folder where I do all of my P2 programming. Now I have several sub folders in this folder, do I have to install task.jason in each folder in the main Library folder or is installing it in the top folder enough?
    Jim

    Hmmm..... please follow the instructions for setting up user tasks. Tasks will be set up once for your login. Then for each project with a top-level file, you will also create a {project}/.vscode/settings.json file identifying the top-level file. Starting from the top of the same page all of the instructions you should need for setting up any flavor of OS should be there.

  • Thanks Stephen, there is a lot to digest here so I am going to have to work through it all.
    Jim

  • Stephen MoracoStephen Moraco Posts: 303
    edited 2023-06-10 04:12

    NEWS

    I've just released v1.9.0 of our spin2 extension, which fully supports both P1 and P2.

    I haven't been announcing each of the past updates. Here is the latest:

    v1.9.0
    Minor Semantic updates for P1 and P2 along with new Documentation feature

    • Add documentation generation via keystroke [Ctrl+Alt+d], doc opens on the right side
    • Fix highlight of object constant references in case statement selectors P1 and P2 (#17)
    • Flag "else if" in spin code as illegal / won't compile - P1 and P2 (#18)

    What are we doing?

    In this update, (1) I reorganized the titles of commands provided by this extension to that you can filter on "spin2" to see the full list of all the commands:

    ... and (2) I've added a new generate Object Interface Document command [Ctrl+Alt+d] (Control+Alt+(d)ocument) which opens the generated file to the right of the spin2 or spin file that you are editing:

    If you see any issues with these new features please let us know by filing new issues at our code repo.

    Possible Conflicts with other VSCode Extensions

    Note: This extension replaces the Spin by Entomy vscode extension. While either can be used, our version provides more comprehensive Syntax highlighting (as the former has not been maintained) and this extension adds full Semantic Highlighting, Outlining, and Tab support with InsertModes. The older Spin extension can now be uninstalled with no loss of functionality.

    About this extension

    You can always review the Spin2 Extension ChangeLog from within VSCode or at github for more details.

    Reminder: The Spin2 extension is in the VSCode marketplace. After one has a working install of VSCode then from within the VSCode Extensions panel search for Spin2, install it and you are good to go. Once installed it will automatically notify you of new update availability whenever I publish new updates.

    If you are already using this extension and for some reason, it did not update for you automatically, in VSCode go to your extensions view (SHIFT+CMD+X), and type in spin2. On the left, the info panel for the extension should appear and will indicate that an update has happened or needs to happen. Update it if needed.

    NOTE You may want to double-check that all older versions are removed from your .vscode/extensions folder after installing any new version.

    If you find code that you believe is not highlighting correctly (yes, we will likely find some for a while yet...) then please file an issue at my github repository issues page

    I also point out a number of extensions that make this an even better Spin2/Pasm2 development environment. See: my VSCode repo extensions page

    There is more than just installing the extension as one needs to set up build and run facilities based on the compiler tools one is using and also based on the platform (Windows, Mac, RPi, Linux, etc.) To help us learn how to do this Ken posted a very useful VSCode P2 QuickByte.

    There are also two new platform-specific tasks installation pages:

    For any others refer to the all platform User tasks

    What's next? on the horizon (yes, I'm still working on these...): (1) Finishing certification of this Spin VSCode extension for our P1 against all of the P1 Obex, and (2) fixing things seen in a couple of Spin2 code sets that are not being highlighted correctly. However, the very next item I'm working on is rewriting the semantic highlighting to use a Language Server Process behind the scenes which will allow us to awaken many more features we need.

    Enjoy!

    Stephen

  • @"Stephen Moraco" said:
    NEWS

    I've just released v1.9.0 of our spin2 extension, which fully supports both P1 and P2.

    I haven't been announcing each of the past updates. Here is the latest:

    v1.9.0
    Minor Semantic updates for P1 and P2 along with new Documentation feature

    • Add documentation generation via keystroke [Ctrl+Alt+d], doc opens on the right side
    • Fix highlight of object constant references in case statement selectors P1 and P2 (#17)
    • Flag "else if" in spin code as illegal / won't compile - P1 and P2 (#18)

    What are we doing?

    In this update, (1) I reorganized the titles of commands provided by this extension to that you can filter on "spin2" to see the full list of all the commands:

    ... and (2) I've added a new generate Object Interface Document command [Ctrl+Alt+d] (Control+Alt+(d)ocument) which opens the generated file to the right of the spin2 or spin file that you are editing:

    If you see any issues with these new features please let us know by filing new issues at our code repo.

    Possible Conflicts with other VSCode Extensions

    Note: This extension replaces the Spin by Entomy vscode extension. While either can be used, our version provides more comprehensive Syntax highlighting (as the former has not been maintained) and this extension adds full Semantic Highlighting, Outlining, and Tab support with InsertModes. The older Spin extension can now be uninstalled with no loss of functionality.

    About this extension

    You can always review the Spin2 Extension ChangeLog from within VSCode or at github for more details.

    Reminder: The Spin2 extension is in the VSCode marketplace. After one has a working install of VSCode then from within the VSCode Extensions panel search for Spin2, install it and you are good to go. Once installed it will automatically notify you of new update availability whenever I publish new updates.

    If you are already using this extension and for some reason, it did not update for you automatically, in VSCode go to your extensions view (SHIFT+CMD+X), and type in spin2. On the left, the info panel for the extension should appear and will indicate that an update has happened or needs to happen. Update it if needed.

    NOTE You may want to double-check that all older versions are removed from your .vscode/extensions folder after installing any new version.

    If you find code that you believe is not highlighting correctly (yes, we will likely find some for a while yet...) then please file an issue at my github repository issues page

    I also point out a number of extensions that make this an even better Spin2/Pasm2 development environment. See: my VSCode repo extensions page

    There is more than just installing the extension as one needs to set up build and run facilities based on the compiler tools one is using and also based on the platform (Windows, Mac, RPi, Linux, etc.) To help us learn how to do this Ken posted a very useful VSCode P2 QuickByte.

    There are also two new platform-specific tasks installation pages:

    For any others refer to the all platform User tasks

    What's next? on the horizon (yes, I'm still working on these...): (1) Finishing certification of this Spin VSCode extension for our P1 against all of the P1 Obex, and (2) fixing things seen in a couple of Spin2 code sets that are not being highlighted correctly. However, the very next item I'm working on is rewriting the semantic highlighting to use a Language Server Process behind the scenes which will allow us to awaken many more features we need.

    Enjoy!

    Stephen

    This is great! Thanks Stephen!

  • NEWS

    I've just released v1.9.4 of our spin2 extension, which fully supports both P1 and P2.

    I haven't been announcing each of the past updates. Here is the latest:

    v1.9.4
    New feature: "Show Hovers" support for P2! (p2 pasm and then full P1 coming soon)

    • Hover over User variables, constants, methods, pasm labels, and objects to display pop-up information about the item including comments within the code for the item
    • Hover for Built-in Spin2 methods, variables, constants, and smart-pin constants to display pop-up documentation about the built-in item
    • Adds new Doc-Comment Generation for PUB and PRI methods via keystroke [Ctrl+Alt+c] - Ctrl+Alt+( c )moment.
      • Comment is inserted immediately below the PUB or PRI line.

    What are we doing?

    This is the first of a number of releases. This release introduces the "Show Hovers" support. This is a P2 spin feature. Pasm support is coming as well as P1 support.

    Here's an introduction video (12:30) demonstrating the new Hover features and the PUB/PRI doc generation:

    If you see any issues with these new features please let us know by filing new issues at our code repo.

    Possible Conflicts with other VSCode Extensions

    Note: This extension replaces the Spin by Entomy vscode extension. While either can be used, our version provides more comprehensive Syntax highlighting (as the former has not been maintained) and this extension adds full Semantic Highlighting, Outlining, and Tab support with InsertModes. The older Spin extension can now be uninstalled with no loss of functionality.

    About this extension

    You can always review the Spin2 Extension ChangeLog from within VSCode or at github for more details.

    Reminder: The Spin2 extension is in the VSCode marketplace. After one has a working install of VSCode then from within the VSCode Extensions panel search for Spin2, install it and you are good to go. Once installed it will automatically notify you of new update availability whenever I publish new updates.

    If you are already using this extension and for some reason, it did not update for you automatically, in VSCode go to your extensions view (SHIFT+CMD+X), and type in spin2. On the left, the info panel for the extension should appear and will indicate that an update has happened or needs to happen. Update it if needed.

    NOTE You may want to double-check that all older versions are removed from your .vscode/extensions folder after installing any new version.

    If you find code that you believe is not highlighting correctly (yes, we will likely find some for a while yet...) then please file an issue at my github repository issues page

    I also point out a number of extensions that make this an even better Spin2/Pasm2 development environment. See: my VSCode repo extensions page

    There is more than just installing the extension as one needs to set up build and run facilities based on the compiler tools one is using and also based on the platform (Windows, Mac, RPi, Linux, etc.) To help us learn how to do this Ken posted a very useful VSCode P2 QuickByte.

    There are also two new platform-specific tasks installation pages:

    For any others refer to the all platform User tasks

    What's next? on the horizon (yes, I'm still working on these...): (1) Finishing certification of this Spin VSCode extension for our P1 against all of the P1 Obex, and (2) fixing things seen in a couple of Spin2 code sets that are not being highlighted correctly. However, the very next items I'm working on are a number of small releases (this being the first) followed by adding a new Spin/Spin2 Language Server Process behind the scenes which will allow us to awaken many more features we need.

    Enjoy!

    Stephen

  • Fantastic progress Stephen.

  • Stephen MoracoStephen Moraco Posts: 303
    edited 2023-07-18 01:00

    NEWS

    I've just released v1.9.8 of our spin2 extension, which fully supports both P1 and P2.

    I haven't been announcing each of the past updates. Here is the latest:

    v1.9.7/1.9.8
    Add Signature Help P1 & P2, Awaken Hover support and Documentation Generation features for P1!
    This release brings our P1 support into feature parity with the P2 feature set and also includes minor fixes for the P2 side of things.

    • P1: When typing user and built-in method calls Signature Help will describe parameters needed, with meaning, as they are typed
    • P1: Now supports hovering over User variables, constants, methods, pasm labels, and objects to display pop-up information about the item including comments within the code for the item
    • P1: Now supports hover for Built-in Spin methods, variables, and constants to display pop-up documentation about the built-in item
    • P1: Adds new Doc-Comment Generation for PUB and PRI methods via keystroke [Ctrl+Alt+c] - Ctrl+Alt+( c )moment.
      -- Comment is inserted immediately below the PUB or PRI line.

    • P1: Adds new Object Public interface documentation generation via keystroke [Ctrl+Alt+d] - Ctrl+Alt+( d )ocument. Doc opens on the right side of the editor window

    • P1 and P2: when user methods don't have parameter documentation the signature help now works and it reminds us how to generate the missing documentation.
    • P2 Hover information is now shown for debug display window names.
    • P2 Improve hover pop-up content for SEND(), RECV() method pointers

    What are we doing?

    This is the next of a number of releases. This release introduces the "Signature Help" support for P1 and P2.

    Here's an introduction video (6:20) demonstrating the new Signature Help features and the PUB/PRI doc generation:

    If you see any issues with these new features please let us know by filing new issues at our code repo.

    Possible Conflicts with other VSCode Extensions

    Note: This extension replaces the Spin by Entomy vscode extension. While either can be used, our version provides more comprehensive Syntax highlighting (as the former has not been maintained) and this extension adds full Semantic Highlighting, Outlining, and Tab support with InsertModes. The older Spin extension can now be uninstalled with no loss of functionality.

    The Extension Document This v0.8.2 currently also occasionally intercepts the Ctrl+Alt+D keystroke which we use to generate documentation and our extension then doesn't get the request. I've filed an issue with that extensions' maintainer so maybe this will be fixed in the future. Meanwhile, you can either disable the Document This extension, or when you see the warning pop up from the document this extension you can usually just click in your editor window again and then press Ctrl+Alt+d again and it will work after one or more tries.

    About this extension

    You can always review the Spin2 Extension ChangeLog from within VSCode or at github for more details.

    Reminder: The Spin2 extension is in the VSCode marketplace. After one has a working install of VSCode then from within the VSCode Extensions panel search for Spin2, install it and you are good to go. Once installed it will automatically notify you of new update availability whenever I publish new updates.

    If you are already using this extension and for some reason, it did not update for you automatically, in VSCode go to your extensions view (SHIFT+CMD+X), and type in spin2. On the left, the info panel for the extension should appear and will indicate that an update has happened or needs to happen. Update it if needed.

    NOTE You may want to double-check that all older versions are removed from your .vscode/extensions folder after installing any new version.

    If you find code that you believe is not highlighting correctly (yes, we will likely find some for a while yet...) then please file an issue at my github repository issues page

    I also point out a number of extensions that make this an even better Spin2/Pasm2 development environment. See: my VSCode repo extensions page

    There is more than just installing the extension as one needs to set up build and run facilities based on the compiler tools one is using and also based on the platform (Windows, Mac, RPi, Linux, etc.) To help us learn how to do this Ken posted a very useful VSCode P2 QuickByte.

    There are also two new platform-specific tasks installation pages:

    For any others refer to the all platform User tasks

    What's next? on the horizon (yes, I'm still working on these...): (1) Finishing certification of this Spin VSCode extension for our P1 against all of the P1 Obex, and (2) fixing things seen in a couple of Spin2 code sets that are not being highlighted correctly. However, the very next items I'm working on are a number of small releases (this being the first) followed by adding a new Spin/Spin2 Language Server Process behind the scenes which will allow us to awaken many more features we need.

    Enjoy!

    Stephen

  • I've just installed VSC on a new computer and noticed that there is a global tasks.json file and a local (per project) settings.json file, now. I totally agree that this is a good idea.
    Supporting both PNut and FlexProp as compiler is also nice.

    Download & Debug – [w/PNut only]

    However, I wonder why nobody thought about using both simultanously, FlexProp as compiler and PNut as debug display. It should work, I think.

  • @ManAtWork said:

    Download & Debug – [w/PNut only]

    However, I wonder why nobody thought about using both simultaneously, FlexProp as compiler and PNut as debug display. It should work, I think.

    Good question!

    It's actually very easy. The hard part is coming up with the key assignments for one of the two compilers. To accomplish this the tasks file is good to go, but the keybindings need to change.

    The keybindings files (I provide two for windows: one for FlexSpin and the other for PNut) are identical except for the names of the steps being invoked.

    The tasks file already supports both. Just concatenate the two keybindings files (fix the syntax - fix the square bracket placement, insert/remove comma's as needed) then change the key assignments so that each key assignment is unique to a single task run. Then you can invoke either compiler at will.

    Does this make sense? and does this help? And may I ask one thing? If you do this, can you please share your keybindings file back to us? ;-)

    Stephen

  • Yes this makes sense, thanks. I think I've already had something working but I had some problems with the json syntax and strange error messages.

    It will take some time as I'm trying out a new board with new code and new libraries. I'll be back when I have sorted it out.

  • ManAtWorkManAtWork Posts: 2,125
    edited 2023-07-24 17:10

    Ok, it seems to work! :) First, I've added some definitions to the settings.json file:

    {
        "topLevel": "XY_main",
        "topExtension": "spin2",
        "baudRate": "2000000",
        "libraryPath": "C:/flexprop/library",
        "defines": "",
    }
    

    This allows me to add some project specific parameters locally and keep the global tasks.json file unchanged. Some of my projects have a C file as topLevel so I want that project specific instead of hardcoded to ".spin2". Then I've changed the compileToP2 task to

        {
          "label": "compileTopP2",
          "type": "shell",
          "osx": {
            "command": "/Applications/flexprop/bin/flexspin.mac"
          },
          "windows": {
            "command": "flexspin.exe"
          },
          "linux": {
            "command": "/opt/flexprop/bin/flexspin"
          },
          "args": ["-2", "-g", "-L${config:libraryPath}", "${config:defines}", 
                   "-D_BAUD=${config:baudRate}"
                   "-Wabs-paths", "-Wmax-errors=99", 
                   "${config:topLevel}.${config:topExtension}"],
          "problemMatcher": {
            "owner": "Spin2",
            "fileLocation": ["autoDetect", "${workspaceFolder}"],
            "pattern": {
              "regexp": "^(.*):(\\d+):\\s+(warning|error):\\s+(.*)$",
              "file": 1,
              "line": 2,
              "severity": 3,
              "message": 4
            }
          },
          "presentation": {
            "panel": "dedicated",
            "focus": false,
            "showReuseMessage": false,
            "clear": true
          },
          "group": {
            "kind": "build",
            "isDefault": true
          }
        },
    

    and added two more tasks:

        {
          "label": "downloadP2only",
          "type": "shell",
          "args": [
              "-b${config:baudRate}",
              "${config:topLevel}.binary",
          ],
          "osx": {
              "command": "loadp2.mac",
          },
          "windows": {
              "command": "loadp2.exe",
          },
          "linux": {
              "command": "loadp2",
              "args": [
                  "-b${config:baudRate}",
                  "${config:topLevel}.binary",
                  "-p/dev/ttyUSB0"
              ],
          },
          "problemMatcher": [],
          "presentation": {
              "panel": "new",
              "focus": true
          },
          "dependsOn": [
              "compileTopP2"
          ]
        },
        {
          "label": "debugPNut2",
          "type": "shell",
          "args": [
            "-debug",
            "3",
            "${config:baudRate}",
          ],
          "windows": {
              "command": "pnut.exe",
          },
          "problemMatcher": [],
          "presentation": {
              "panel": "new",
              "focus": true
          },
          "dependsOn": [
              "downloadP2only"
          ]
        }
    

    DownloadP2only downloads the binary with loadp2 without opening a terminal. Instead, PNut is launched thereafter in -debug mode. Then I've added this to the keybindings:

      {
          "key": "F9",
          "command": "workbench.action.tasks.runTask",
          "args": "debugPNut2"
        },
    

    This is not consistent with the Propeller tool keymap. I've just used F9 for "load to RAM and debug" because it was still available. Maybe someone with better json skills could come up with a compile+download to RAM task that has a selectable debug option.

    Next, I have to figure out how to generate printf based output that is compatible with the graphical debug windows of PNut, for example the SCOPE window.

    The fact that I want to used mixed languages disables me from using PNut as compiler. And there is still no "download binary and debug" option for PNut. The seperate execution of loadp2 and PNut creates a small delay so the first "cog0..." output during program launch is lost. I think that doesn't matter much as I can always insert delays before the important output starts.

    Edit: loadP2 seems to work with autodetect but PNut needs a hardwired COM port number otherwise it doesn't work.

  • Yipeee! In Spin2 it works on the first go.

    Shouldn't be too hard to do the same in C with printf().

  • Looks like I have goofed up somewhere in configuring VSC, I keep getting this when trying to compile the top object.
    Variable ${config:topLevel} can not be resolved because setting 'topLevel' not found. Has anyone else had this happen?

    Thanks.

  • @"frank freedman" said:
    ...I keep getting this when trying to compile the top object.
    Variable ${config:topLevel} can not be resolved because setting 'topLevel' not found. Has anyone else had this happen?

    Frank, is it possible you missed setting up the three line settings.json file? See Adding our notion of Top-level file for tasks to use

    Stephen

  • Got it working sort of. Sort of because it was brute force and not figuring out why yet. Copied a working workspace, swapping in the spin contents and setting the name in the settings.json..
    Got a bit to learn for VSC. Thanks for a great tool!

  • Stephen MoracoStephen Moraco Posts: 303
    edited 2023-08-01 23:22

    NEWS

    After many months of thinking this couldn't be done in VSCode, I found an extension that demonstrated how it could be. So after a bit of work... ;-)

    I've just released v1.9.12 of our spin2 extension, which fully supports both P1 and P2.

    v1.9.12
    **Feature Updates (P1 and P2) **

    • P1 & P2: Adds editor background coloring per section à la Parallax Propeller Tool (disabled by default, enable in settings, requires the use of the new background color-supporting themes)
    • Adds two new color themes which are better suited to colorized backgrounds
    • Adds new Light theme for non-colored background use which compliments the Dark theme already present

    What are we doing?

    This is the next of a number of releases. This release introduces the "Spin/Spin2 Code Block Coloring" support for P1 and P2.

    For help with enabling this new feature see Spin2/Pasm2 Editor Background Coloring for VSCode

    If you see any issues with these new features please let us know by filing new issues at our code repo.

    Possible Conflicts with other VSCode Extensions

    Note: This extension replaces the Spin by Entomy vscode extension. While either can be used, our version provides more comprehensive Syntax highlighting (as the former has not been maintained) and this extension adds full Semantic Highlighting, Outlining, and Tab support with InsertModes. The older Spin extension can now be uninstalled with no loss of functionality.

    The Extension Document This v0.8.2 currently also occasionally intercepts the Ctrl+Alt+D keystroke which we use to generate documentation and our extension then doesn't get the request. I've filed an issue with that extensions' maintainer so maybe this will be fixed in the future. Meanwhile, you can either disable the "Document This" extension or when you see the warning pop up from the document this extension you can usually just click in your editor window again and then press Ctrl+Alt+d again and it will work after one or more tries.

    About this extension

    You can always review the Spin2 Extension ChangeLog from within VSCode or at github for more details.

    Reminder: The Spin2 extension is in the VSCode marketplace. After one has a working install of VSCode then from within the VSCode Extensions panel search for Spin2, install it and you are good to go. Once installed it will automatically notify you of new update availability whenever I publish new updates.

    If you are already using this extension and for some reason, it did not update for you automatically, in VSCode go to your extensions view (SHIFT+CMD+X), and type in spin2. On the left, the info panel for the extension should appear and will indicate that an update has happened or needs to happen. Update it if needed.

    NOTE You may want to double-check that all older versions are removed from your .vscode/extensions folder after installing any new version.

    If you find code that you believe is not highlighting correctly (yes, we will likely find some for a while yet...) then please file an issue at my github repository issues page

    I also point out a number of extensions that make this an even better Spin2/Pasm2 development environment. See: my VSCode repo extensions page

    There is more than just installing the extension as one needs to set up build and run facilities based on the compiler tools one is using and also based on the platform (Windows, Mac, RPi, Linux, etc.) To help us learn how to do this Ken posted a very useful VSCode P2 QuickByte.

    There are also three platform-specific tasks installation pages:

    What's next? on the horizon (yes, I'm still working on these...): (1) Finishing certification of this Spin VSCode extension for our P1 against all of the P1 Obex, and (2) fixing things seen in a couple of Spin2 code sets that are not being highlighted correctly. However, the very next items I'm working on are a number of small releases (this being one of a couple) followed by adding a new Spin/Spin2 Language Server Process behind the scenes which will allow us to awaken many more features we need.

    Enjoy!

    Stephen

  • I"m smiling at making some progress so thought I should share. ;-)

    No new release for you all but I reached an exciting (hopefully not only to me?) milestone today with the re-implementation of this VSCode extension as a Spin/Spin2 Langauge Server.

    My day ended with all smiles as I have the first feature working in the new environment. The Spin1 and Spin2 outline view is now being displayed correctly with information returned by the external language server process. It's interactive of course so as one is typing in the file the outline view updates as one would expect.

    After awakening a lot of new infrastructure code and after weeks of studying other people's implementations I've finally reached critical mass in my understanding of how to do this. It's really fun to see the entire mechanism working! So pardon the interruption but I had to share! ;-)

    Next, I'm porting over each working feature to the new environment one by one. So this will take some time (think weeks.)

    This new environment also provides for adding rich regression testing for each of the features as I add them.

    My current plan is to release this replacing the existing extension when I reach feature parity with the existing extension. You will see this new version arriving with very little fanfare other than a new v2.0.0 version number and an announcement of the release in this forum as usual.

    Thanks for your attention!

    Stephen

  • Brilliant!

    This opens up a lot of other IDEs, not just Visual Code, Spin support in full blown Visual Studio, Eclipse and lot of others.

    I am smiling with you!

    Mike

  • I just wanted to test my flash chip and ran into a very strange problem. I've never used 'F11' before because I'm debugging code and run it from RAM all the time. But now I did and it doesn't work no matter what I do. My tasks.json looks like this:

    {
          "label": "flashP2",
          "type": "shell",
          "osx": {
            "command": "/Applications/flexprop/bin/loadp2.mac",
            "args": ["-b${config:baudRate}", "@0=/Applications/flexprop/board/P2ES_flashloader.bin,@8000+${config:topLevel}.binary", "-t", "-k"]
          },
          "windows": {
            "command": "loadp2.exe",
            "args": ["-b${config:baudRate}", "@0=${env:FlexPropPath}/board/P2ES_flashloader.bin,@8000+${config:topLevel}.binary", "-t", "-k"]
          },
          "linux": {
            "command": "/opt/flexprop/bin/loadp2",
            "args": ["-b${config:baudRate}", "@0=/opt/flexprop/board/P2ES_flashloader.bin,@8000+${config:topLevel}.binary", "-t", "-p/dev/ttyUSB0"]
          },
          "problemMatcher": [],
          "presentation": {
            "panel": "dedicated",
            "focus": false,
            "showReuseMessage": false,
            "clear": true
          },
          "group": {
            "kind": "test",
            "isDefault": true
          },
          "dependsOn": ["compileTopP2"]
    },
    

    And it throws this error message:

    =C:\flexprop\bin/board/P2ES_flashloader.bin: Invalid argument
    Could not open =C:\flexprop\bin/board/P2ES_flashloader.bin   
    

    As the "=" sign is included in the filename I tried out @0${env:FlexPropPath} instead of @0=${env:FlexPropPath}, but now it says

    :\flexprop\bin/board/P2ES_flashloader.bin: Invalid argument
    Could not open :\flexprop\bin/board/P2ES_flashloader.bin   
    

    Things get even weirder if I hardcode the path like this: @0P2ES_flashloader.bin,@8000+... Now the command isn't executed at all but VSC says

    ParserError: 
    Line |
       1 |  loadp2.exe -b2000000 @0P2ES_flashloader.bin,@8000+QB_main.binary -t - …
         |                       ~~~~~~~~~~~~~~~~~~
         | The splatting operator '@' cannot be used to reference variables in an expression. '@0P2ES_flashloader' can be used only as an argument to a command. To
         | reference variables in an expression use '$0P2ES_flashloader'.
    

    So the "@" seems to confuse the json script parser or the shell. Has nobody ever tried this before?

  • @ManAtWork said:

    Things get even weirder if I hardcode the path like this: @0P2ES_flashloader.bin,@8000+... Now the command isn't executed at all but VSC says

    ParserError: 
    Line |
       1 |  loadp2.exe -b2000000 @0P2ES_flashloader.bin,@8000+QB_main.binary -t - …
         |                       ~~~~~~~~~~~~~~~~~~
         | The splatting operator '@' cannot be used to reference variables in an expression. '@0P2ES_flashloader' can be used only as an argument to a command. To
         | reference variables in an expression use '$0P2ES_flashloader'.
    

    So the "@" seems to confuse the json script parser or the shell. Has nobody ever tried this before?

    this seems to be a powershell thing: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_splatting?view=powershell-7.3

    try putting is in quotes like:

    loadp2.exe -b2000000 '@0P2ES_flashloader.bin,@8000+QB_main.binary' -t - …
    
  • I think someone had this exact issue before. Change your default shell to bash or cmd, choosing powershell causes this to happen.

  • @rosco_pc said:
    this seems to be a powershell thing: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_splatting?view=powershell-7.3
    try putting is in quotes like:

    loadp2.exe -b2000000 '@0P2ES_flashloader.bin,@8000+QB_main.binary' -t - …
    

    Ok thanks, adding single quotes helped and now the command line is executed.
    "'@0=${env:FlexPropPath}/board/P2ES_flashloader.bin,@8000+${config:topLevel}.binary'"

    But now I get garbled characters in the terminal and the flash isn't programmed correctly. I think this was an issue with the autobaud not working in P2ES_flashloader. I'll try different baud settings tomorrow.

  • I"m smiling at making significant progress so here's another share. ;-)

    No new release for you all but I reached a major milestone today with the re-implementation of this VSCode extension as a Spin/Spin2 Langauge Server.

    As of now, I have reached feature parity with the current extension (less a bit of testing). All Spin1 and Spin2 features are now in place.

    This week I'm adding the returning of the hover and signature information from included files into your editing session of the current file. After that is in place and I'm satisfied with my testing then I'll be releasing this. At this point, I might be able to release this new v2.0.0 version with the announcement of the release in this forum by the end of this week or the middle of next.

    Wish me luck! More news soon!

    Thanks for your attention!

    Stephen

Sign In or Register to comment.