Shop Learn P1 Docs P2 Docs 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)

12346»

Comments

  • jrullanjrullan Posts: 107
    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: 17
    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: 17
    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.

Sign In or Register to comment.