Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JS] Make sdk.js serialport selection more universal. #3999

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

csaboka21
Copy link

@csaboka21 csaboka21 commented Nov 12, 2024

What's new

  • On windows when using NPM for creating JS project and starting with 'npm start' it will throw this error:
file:///C:/Users/hazic/Documents/temp/NodeTest/my-flip-app/node_modules/@flipperdevices/fz-sdk/sdk.js:95
    let portPath = flippers[0].path;
                               ^

TypeError: Cannot read properties of undefined (reading 'path')
    at Object.upload (file:///C:/Users/hazic/Documents/temp/NodeTest/my-flip-app/node_modules/@flipperdevices/fz-sdk/sdk.js:95:32)
    at async file:///C:/Users/hazic/Documents/temp/NodeTest/my-flip-app/node_modules/@flipperdevices/fz-sdk/sdk.js:175:5

It's clear that it can't find the flipper. The code searching for ports which 'serialNumber' starts with "flip_", but in windows it the port looking like this:

{
    path: 'COM4',
    manufacturer: 'Microsoft',
    serialNumber: '7&359A65E1&0&0000',
    pnpId: 'USB\\VID_0483&PID_5740&MI_00\\7&359A65E1&0&0000',
    locationId: '0001.0000.0000.007.000.000.000.000.000',
    friendlyName: 'Soros USB-eszköz (COM4)',
    vendorId: '0483',
    productId: '5740'
  }

It shows that the serial number is not starting with 'flip_'.
Another problem with the code is that checking for if (!flippers) is useless because when we create the array, a line above it should check for its length instead.

Also, when multiple flippers are connected and found when calling the prompts and assigning it to the port, it is simply not initialized yet. It will be initialized a few lines later.

I think it would be much better if the user has to define the COM port all the time they want to run on the device.

Verification

  • Tried on my Windows PC.

Checklist (For Reviewer)

  • PR has description of feature/bug or link to Confluence/Jira task
  • Description contains actions to verify feature/bugfix
  • I've built this code, uploaded it to the device and verified feature/bugfix

@skotopes
Copy link
Member

skotopes commented Dec 2, 2024

@portasynthinca3 review please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug JS JS Runtime, loader and API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants