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

V2 control transfer target device #64

Closed

Conversation

joelpurra
Copy link
Contributor

Work-in-progress patches to the future node-uvc-control v2, on master. Fixes Linux issues (primarily) but also compatibility with other cameras (confirmed by some uvcc users). Sorry for mixing issues in one pull request -- submitting this as a draft pull request for testing, and I'd be happy to split to multiple when it's confirmed to work.

Fixes were created to get uvcc working, so testing (unfortunately still manually) is mostly done using the uvcc CLI.

While uvcc v2 is not up to par with node-uvc-control v2, I've also fixed a few more basic uvcc features to get basic uvcc export | uvcc import functionality working. The feature/uvc-control-v2-next branch of uvcc targets the code in this pull request.

git clone "[email protected]:joelpurra/uvcc.git"
cd uvcc

git checkout feature/uvc-control-v2-next
git pull
rm -r node_modules/
npm install

./index.js --verbose ranges
./index.js --verbose export

# NOTE: not all settings can be set if they're in auto-mode -- fix pending.
./index.js --verbose export | ./index.js --verbose import

There are still bugs, both in uvcc (missing functionality, setting values when they're in auto-mode, etcetera) and node-uvc-control (spotted some on the byte-reading level). Tested on macOS and Ubuntu using a Logitech C920 (0x46d/0x82d) with node v12.

What are the results for your camera(s)? Any major issues? Please show some output for verification, along with the camera vendor/product ids.


Note: similar/backported fixes for Linux are available for node-uvc-control v1.0.2 in a separate branch, but github doesn't let me create pull request against tags.

@nickrobillard
Copy link

Hi. I've tried to use this but I am running into an error. The file ${__dirname}/../node_modules/uvc-control/list-devices.js is included in uvcc/src/usb-device-lister.js but it's missing. Looks like you were changing a file directly in your node_modules dir and may not have added it back to the repo?

Here's what I did:

git clone "[email protected]:joelpurra/uvcc.git"
cd uvcc

git checkout feature/uvc-control-v2-next
git pull
rm -r node_modules/
npm install

./index.js --verbose devices

Error occurs:

Parsed arguments: {
  "_": [],
  "version": false,
  "verbose": true,
  "help": false,
  "$0": "index.js",
  "cmd": "devices"
}
internal/modules/cjs/loader.js:985
  throw err;
  ^

Error: Cannot find module '/[redacted]/uvcc/node_modules/uvc-control/list-devices.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:982:15)
    at Function.Module._load (internal/modules/cjs/loader.js:864:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
    at internal/main/run_main_module.js:18:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

@joelpurra
Copy link
Contributor Author

joelpurra commented Jul 17, 2020

@nickrobillard: I skipped device listing for this preview. It was using a file from the "old" uvc-control v1 which is no longer there.

  • Reimplemented uvcc devices.
  • Made the device address configurable, for those who have more than one camera of the same make.
  • Made device configuration unnecessary for the most common use-case -- having a single UVC camera connected. The device vendor/product ids and address can be auto-detected by uvc-control v2 (it picks the "first" camera), so uvcc no longer requires these values to be configured.

Basically uvcc devices is no longer as important because of the new auto-detection, and uvcc usage is greatly simplified.


Note: all changes were made in uvcc v2, so they are not visible in this pull request.

You can install and test the new code as described in the original pull request information.

- Currently, each `controlTransfer` by setting `bmRequestType` targets the camera _interface_ rather than _device_.
- Using an interface would require claiming it, which is not performed.
- Claiming an interface would kill access for any other process which may be using the camera (including the kernel?).
- This commit targets `controlTransfer` to the _device_ instead.
- There might be better ways to transfer control commands.
- Ported from `uvc-control` v1 to v2.

Fixes makenai#58
Fixes joelpurra/uvcc#2

See

- makenai#58
- joelpurra/uvcc#2
- Fixes typo which affected `CT` control types.

Fixes joelpurra/uvcc#4

See

- joelpurra/uvcc#4
- Possibly related to the previous commit which had a typo affecting camera input terminal (CT) controls.
- There might be other bugs in the control data, should check against UVC v1.5 reference.

Fixes makenai#60

See

- makenai#60
- https://www.usb.org/documents?search=uvc
@joelpurra joelpurra force-pushed the v2-control-transfer-target-device branch 2 times, most recently from c0e37fe to d2ae47e Compare September 1, 2020 12:19
@joelpurra
Copy link
Contributor Author

Closing in favor of #66.

@joelpurra joelpurra closed this Sep 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants