sg-wireless / pymakr-vsc

GNU General Public License v3.0
97 stars 25 forks source link

[BUG] Nothing at all happens when clicking "Sync project" button on M1 Mac #253

Closed VirtualWolf closed 1 year ago

VirtualWolf commented 2 years ago

Describe the bug

I'm able to get Pymakr to connect to my board and bring up a REPL window (though every time I disconnect or reconnect I have to press the Reset button on the board to get it to connect), but clicking the little Sync Project button does nothing whatsoever.

Steps to reproduce

This is starting from total scratch.

  1. Open a new empty window in VS Code, click the "Create project" button under Pymakr's "Projects" section: 1_new_project
  2. Add the serial port under the project: 2_add_serial_port
  3. Click the little lightning icon to connect and the spinner spins but never finishes: 3_connection_spinner
  4. If I click the "Create terminal" icon instead, I get a message tty.usbmodem1234561 / unknown seems to be busy. Do you wish restart it in safe mode? Clicking the "Restart in safe mode" button does nothing, but manually pressing the reset button on the board itself then causes the terminal window to connect and I'm now at the REPL which works: 4_repl
  5. Add tiny bit of code to main.py and click the "Sync project" button: 6_sync_project

Expected behavior

The project is uploaded and I can see the "Hello world" constantly being printed out every second in the terminal.

Actual behaviour

Absolutely nothing happens, even when looking in the developer console with Pymakr's logs set to debug level.

Environment

Additional context

I came across #242 and have updated the root path setting to be set to / for everything (I don't have any devices that don't have the root path at /):

    "pymakr.devices.config": [

        {
            "match": "manufacturer=.*",
            "field": "rootPath",
            "value": "/"
        }
    ],

But that hasn't made any difference unfortunately.

During step 3 when I initially click the lightning icon to connect but it never finishes, the debug logs show this:

[Extension Host] debug:  PyMakr (11913) > Device: tty.usbmodem1234561 > busy...
console.ts:137 [Extension Host] info:  PyMakr (11913) > Device: tty.usbmodem1234561 > connecting to "tty.usbmodem1234561"...
console.ts:137 [Extension Host] info:  PyMakr (11953) > Device: tty.usbmodem1234561 > Connected.
console.ts:137 [Extension Host] info:  PyMakr (11954) > Device: tty.usbmodem1234561 > Waiting for access...
console.ts:137 [Extension Host] debug:  PyMakr (11954) > stateManager > save pymakr.devices.123456 {connected: true, name: 'tty.usbmodem1234561', id: '123456', config: {…}}
console.ts:137 [Extension Host] debug:  PyMakr (11954) > stateManager > load pymakr.devices.123456 {connected: true, name: 'tty.usbmodem1234561', id: '123456', config: {…}}
console.ts:137 [Extension Host] debug:  PyMakr (11961) > Device: tty.usbmodem1234561 > idle.
console.ts:137 [Extension Host] debug:  PyMakr (11961) > Device: tty.usbmodem1234561 > busy...
console.ts:137 [Extension Host] info:  PyMakr (11961) > Device: tty.usbmodem1234561 > Got access.
console.ts:137 [Extension Host] info:  PyMakr (11961) > Device: tty.usbmodem1234561 > Getting device info.

Then upon pressing the reset button on the board:

[Extension Host] debug:  PyMakr (99785) > stateManager > save pymakr.devices.123456 {connected: false, name: 'tty.usbmodem1234561', id: '123456', config: {…}}
console.ts:137 [Extension Host] debug:  PyMakr (99786) > stateManager > load pymakr.devices.123456 {connected: false, name: 'tty.usbmodem1234561', id: '123456', config: {…}}
console.ts:137 [Extension Host] info:  PyMakr (100786) > Device: tty.usbmodem1234561 > connecting to "tty.usbmodem1234561"...
console.ts:137 [Extension Host] info:  PyMakr (100828) > Device: tty.usbmodem1234561 > Connected.
console.ts:137 [Extension Host] info:  PyMakr (100828) > Device: tty.usbmodem1234561 > Waiting for access...
console.ts:137 [Extension Host] debug:  PyMakr (100828) > stateManager > save pymakr.devices.123456 {connected: true, name: 'tty.usbmodem1234561', id: '123456', config: {…}}
console.ts:137 [Extension Host] debug:  PyMakr (100829) > stateManager > load pymakr.devices.123456 {connected: true, name: 'tty.usbmodem1234561', id: '123456', config: {…}}
console.ts:137 [Extension Host] debug:  PyMakr (100835) > Device: tty.usbmodem1234561 > idle.
console.ts:137 [Extension Host] debug:  PyMakr (100835) > Device: tty.usbmodem1234561 > busy...
console.ts:137 [Extension Host] info:  PyMakr (100835) > Device: tty.usbmodem1234561 > Got access.
console.ts:137 [Extension Host] info:  PyMakr (100835) > Device: tty.usbmodem1234561 > Getting device info.
console.ts:137 [Extension Host] debug:  PyMakr (100835) > Device: tty.usbmodem1234561 > idle.

But the Sync Project and and Download Project buttons do nothing. As well, the "Open device in file explorer" button briefly pops up a little thing at the bottom right saying "Adding device to explorer" and this shows in the debug logs:

[Extension Host] debug:  PyMakr (151257) > filesystemProvider > stat file 
{$mid: 1, external: 'serial://%252fdev%252ftty.usbmodem1234561/', path: '/', scheme: 'serial', authority: '%2Fdev%2Ftty.usbmodem1234561'}
$mid: 1
authority: "%2Fdev%2Ftty.usbmodem1234561"
external: "serial://%252fdev%252ftty.usbmodem1234561/"
path: "/"
scheme: "serial"
[[Prototype]]: Object

But nothing else, I'm not entirely clear on what it's meant to do... :)

sinkers commented 2 years ago

I am having pretty much exactly the same issue as this

jakobrosenberg commented 2 years ago

EDIT: This has been fixed in the upcoming patch. Would love to hear your feedback if you want to try it. You can find it here.

ORIGINAL: Please let me know if this fixes your issue https://github.com/pycom/pymakr-vsc/issues/242#issuecomment-1140751462.

VirtualWolf commented 2 years ago

Please let me know if this fixes your issue https://github.com/pycom/pymakr-vsc/issues/242#issuecomment-1140751462.

Yeah I tried that, no dice I'm afraid!

This has been fixed in the upcoming patch. Would love to hear your feedback if you want to try it. You can find it here.

I just updated to 2.15.0 but it hasn't changed anything there unfortunately. Still absolutely nothing happens when clicking the Sync Project button, and there's nothing in the debug logs in the developer console either.

Is there any extra debug logging that could be added? I'm happy to poke around and gather whatever info would be helpful for you! Pymakr 1.x was fantastic and I'd love to help get 2.x working like 1.x did. 🙂

jakobrosenberg commented 2 years ago

I'm happy to poke around and gather whatever info would be helpful for you

That would be much appreciated.

You can increase debugging level in settings: image

Also, the Output tab might contain more information image

And in your settings, do you have an entry like this?

    "pymakr.devices.configs": [

        {
            "autoConnect": "lastState",
            "name": "",
            "username": "micro",
            "password": "python",
            "hidden": false,
            "rootPath": "/flash",
            "id": "Py73bb20"
        },
        {
            "autoConnect": "lastState",
            "name": "",
            "username": "micro",
            "password": "python",
            "hidden": false,
            "rootPath": "/flash",
            "id": "Py3baa06"
        }
    ]

If so, could you please copy paste it to here.

VirtualWolf commented 2 years ago

Ah yeah, the debug setting is something I stumbled onto in another issue, that's what I've had turned on with all those screenshots in my initial issue. 😄

Screen Shot 2022-06-08 at 20 14 43

I hadn't seen the Output tab before, but it's displaying all the same stuff that the developer console does anyway.

As for the settings.json, yep, it's set like this:

    "pymakr.devices.config": [
        {
            "match": "manufacturer=.*",
            "field": "rootPath",
            "value": "/"
        }
    ],

If I change pymakr.devices.config add an s at the end like in your example, it just says it's an unknown setting.

jakobrosenberg commented 2 years ago

Can you try Pymakr 2.15.x and see if that fixes it?

VirtualWolf commented 2 years ago

Slightly more progress with 2.15.0 in that I get this in the Output tab:

debug: PyMakr (26037) > Device: tty.usbmodem1234561 > busy...

But nothing else. Weirdly, when I clicked the Disconnect icon, at that point I got a little VSCode dialog thing popping up saying it was uploading:

Screen Shot 2022-06-09 at 20 16 15
jakobrosenberg commented 2 years ago

Did the update populate your pymakr.devices.config?

VirtualWolf commented 2 years ago

Yup! It's exactly as pasted in my comment yesterday. 🙂

jakobrosenberg commented 2 years ago

Sorry. I meant pymakr.devices.configs. 2.15.0 should create a new entry.

VirtualWolf commented 2 years ago

Hm, no, it doesn't recognise configs with an s on the end. I deleted all of the pymakr.* entries from settings.json and uninstalled 2.15.0 entirely then reinstalled, and the default examples it recreates are under pymakr.devices.config, and if I change it to configs it's not recognised as an option:

Screen Shot 2022-06-10 at 13 21 37
rand12345 commented 2 years ago

Does anyone have an alternative extension or environment for MicroPython on M1? We have a project on hold here with no functional IDE.

No connection to devices, no terminal session to the devices.

The terminal process "node '/Users/xxx/.vscode/extensions/pycom.pymakr-preview-2.16.4/src/terminal/bin/client.js'" failed to launch (exit code: 1).

image image image image

REPL is operational using screen, device is working just fine. No means in which to upload files, virtually no PyMakr options in VS Code. NodeJS is latest LTS and working.

This is some serious breaking change from older versions of PyMakr!

jakobrosenberg commented 2 years ago

@rand12345 you can still install v1.

@VirtualWolf there was a bug in a dependency that didn't manifest itself in my local environment. I applied a fix, but I don't have any 3rd party devices to test it with. You can try it in v2.16.4.

VirtualWolf commented 2 years ago

I'm afraid it's gone backwards now. 😂 I can't connect at all even after resetting the device, and when clicking the button to open the terminal window, I get The terminal process failed to launch: Path to shell executable "node" does not exist.

Actually Ignore that, turns out it was VSCode itself being weird and a quit and reopen sorted that part out.

Unfortunately I can't actually get it to connect at all (or recognise me clicking disconnect) anymore even after doing the reset dance. When I click the Connect button, the debug logs show this:

[Extension Host] debug:  PyMakr (12251) > Device: tty.usbmodem1234561 > busy...
workbench.desktop.main.js:71 [Extension Host] info:  PyMakr (12252) > Device: tty.usbmodem1234561 > connecting to "tty.usbmodem1234561"...
workbench.desktop.main.js:71 [Extension Host] info:  PyMakr (12292) > Device: tty.usbmodem1234561 > Connected.
workbench.desktop.main.js:71 [Extension Host] info:  PyMakr (12292) > Device: tty.usbmodem1234561 > Waiting for access...

And I get a popup from the extension:

Screen Shot 2022-06-11 at 17 29 11

But that's it. No more response when clicking the disconnect button in the Projects window either (clicking "Restart in safe mode" doesn't work, it eventually times out and says to reset it from the board itself).

One thing I did notice is that the "Output" panel has an option not just for Pymakr, but also the specific device. Is it possible that that's interfering with things, like it's grabbing the connection first and blocking the rest of the extension functionality from working?

jakobrosenberg commented 2 years ago

Thanks for the update @VirtualWolf .

What version are you currently on and would it be possible for us to have a remote session over Discord? My ID is 402846333087776768

As for the the output panel. It just logs the data, it's not able to hijack it.

jakobrosenberg commented 2 years ago

UPDATE: After a session with @VirtualWolf it seems that some 3rd party devices do not work with the micropython-ctl package. The REPL is not detected correctly, leaving the device in a busy state.

I'll provide a follow up when we have more info or a fix.

VirtualWolf commented 2 years ago

We did some more testing and it seems like the root of the problem was the default chunk size and delay between sending chunks that the micropython-ctl library that Pymakr relies on uses. Pymakr 2.18.2 has two new settings you can configure in pymakr.devices.configs for your devices, and the following worked for me with an Unexpected Maker FeatherS2:

"pymakr.devices.configs": [
  {
    "autoConnect": "onLostConnection",
    "name": "FeatherS2",
    "adapterOptions": {
        "chunkDelay": 20,
        "chunkSize": 256
    },
    "rootPath": "/",
    "id": "123456"
  }
]
Josverl commented 2 years ago

do you know what are the defaults are?

jakobrosenberg commented 2 years ago

If I remember correctly they're 3000 and 0 for size and delay.

VirtualWolf commented 2 years ago

Yep: https://github.com/metachris/micropython-ctl/blob/master/src/main.ts#L725-L726

jakobrosenberg commented 1 year ago

I assume this was fixed with the added adapterOptions. If not we can reopen it.

VirtualWolf commented 1 year ago

Ah sorry. Yes indeed, everything's working a treat now, thanks!

Davocrack commented 6 months ago

Hi, I have the same problem with an esp8266, and because I'm new in this world, I have no idea on where or how to put those codes. Can anyone help me? My discord id is davionga#1156

Josverl commented 6 months ago

Hi, I have the same problem with an esp8266, and because I'm new in this world, I have no idea on where or how to put those codes. Can anyone help me? My discord id is davionga#1156

best to create a new issue on this repo , if you want to save typing link to this one.