Closed Nic2012 closed 6 years ago
Hi @Nic2012,
I think, the parameters can be changed with CameraWidgets class. https://github.com/TypedProject/ts-gphoto2-driver/blob/master/src/components/CameraWidgets.ts
Honestly, I don't know how it works. But if I look the java version of gphoto2, the configuration should be changed with this peace of code:
const camera = new Camera();
try {
console.log('[GPDRIVER] Camera init');
camera.initialize();
const cfg = new CameraWidgets(camera);
try {
cfg.setValue("/actions/autofocusdrive", true);
cfg.apply();
} finally {
cfg.closeQuietly();
}
} catch (er) {
console.error(er.message);
} finally {
camera.closeQuietly();
}
I thinks a list of actions can be retrieved somewhere :)
Tell if you have any question ! See you Romain
Thanks Romain for the answer, I will try it with a Nikon camera, because I havent installed typescript on my Raspbian Stretch so far, I have tried to run one of the examples at first but I got:
pi@cc:~/node_modules/@typedproject/gphoto2-driver/examples $ node camera.js
module.js:538
throw err;
^
Error: Cannot find module '../src'
at Function.Module._resolveFilename (module.js:536:15)
at Function.Module._load (module.js:466:25)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/pi/node_modules/@typedproject/gphoto2-driver/examples/camera.js:3:38)
But there is no problem with other node modules. Do y have any idea? Best regards, Nic
Ok normal, the src directory isn't embed in the module package (only lib). Examples work if you checkout the project from git ;) or if you replace ../src
by ../lib
or@typedproject/gphoto2-driver
.
See you, Romain
Still doesnt work, sorry:
pi@cc:~/node_modules/@typedproject/gphoto2-driver/examples $ node camera-info.js
module.js:538
throw err;
^
Error: Cannot find module '../lib'
at Function.Module._resolveFilename (module.js:536:15)
at Function.Module._load (module.js:466:25)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/pi/node_modules/@typedproject/gphoto2-driver/examples/camera-info.js:3:38)
pi@cc:~/node_modules/@typedproject/gphoto2-driver/examples $ node camera-info.js
module.js:538
throw err;
^
Error: Cannot find module '@typedproject/gphoto2-driver'
at Function.Module._resolveFilename (module.js:536:15)
at Function.Module._load (module.js:466:25)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/pi/node_modules/@typedproject/gphoto2-driver/examples/camera-info.js:3:38)
Is there any action needed before, is it depending on which folder level I run the script?
Ok the package is available now :)
Ok, the build process isn't done. I'll fix that.
it's fixed :) v1.0.3
Upgraded from npm minutes before.
But cannot really follow y, do I have to run npm build first? If yes where, but I tried:
pi@cc:~/node_modules/@typedproject/gphoto2-driver $ npm run build
> @typedproject/gphoto2-driver@1.0.0 build /home/pi/node_modules/@typedproject/gphoto2-driver
> tsc --project tsconfig.compile.json
sh: 1: tsc: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! @typedproject/gphoto2-driver@1.0.0 build: `tsc --project tsconfig.compile.json`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the @typedproject/gphoto2-driver@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
pi@cc:~/node_modules/@typedproject/gphoto2-driver $ node examples/camera-info.js
module.js:538
throw err;
^
Error: Cannot find module '../src'
at Function.Module._resolveFilename (module.js:536:15)
at Function.Module._load (module.js:466:25)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/pi/node_modules/@typedproject/gphoto2-driver/examples/camera-info.js:3:38)
at Module._compile (module.js:635:30)
I have no typescript modules installed, is that really necessary too?
Hi @Nic2012,
Isn't necessary. I haven't checked the package deployed on npm and his dependencies. Now the package works fine.
Just before install the latest module remove your node_modules then run npm install or yarn install.
See you, Romain
Ok, I can run a script referenced the driver, but the example directory is gone after installing v1.0.6:
pi@cc:~/node_modules/@typedproject/gphoto2-driver $ ls
lib LICENSE node_modules package.json README.md src yarn.lock
I will check later y suggested setter method on CameraWidgets.
Yep I removed the examples in node_modules. Examples shouldn't packaged in npm ;).
You can retrieve the same examples here https://github.com/TypedProject/ts-gphoto2-driver/tree/master/examples
Hey Romain, setValue or getValue methods works fine with a Nikon camera :) Its faster than using original gphoto2 cli. Shortly after setValue its possible to call getValue and returning the new value asap. So I am wondering to call cfg.apply() afterwards. Do y think its really necessary?
What method do I have to call to get same output like from the gphoto2 cli:
gphoto2 --get-config=iso
Label: ISO Speed
Type: RADIO
Current: 250
Choice: 0 50
Choice: 1 60
...
And finally what would be the aquivalent to gohoto2 --list-all-config
?
PS: I found in one example an exception:
node camera.js
Camera => Camera {
gpMethodType: 'gp_camera',
buffer: <Buffer@0x30217b0 70 57 02 03>,
initialized: true,
closed: false }
/home/pi/node_modules/@typedproject/gphoto2-driver/src/driver/utils/GPUtils.ts:15
throw new Error(`${method} returned ${returnValue}: ${errorStr}`);
^
Error: gp_file_save returned -1: Unspecified error
at Object.checkCode (/home/pi/node_modules/@typedproject/gphoto2-driver/src/driver/utils/GPUtils.ts:15:11)
at CameraFile.save (/home/pi/node_modules/@typedproject/gphoto2-driver/src/components/CameraFile.ts:20:12)
at Object.<anonymous> (/home/pi/_gp/camera.js:18:16)
at Module._compile (module.js:635:30)
...
Thank y for y support and this great framework. Best regards, Nic
Hi @Nic2012
1) Shortly after setValue its possible to call getValue and returning the new value asap. I think it's possible yes :). I'll work on ASAP.
2) And finally what would be the equivalent to gphoto2 --list-all-config? I think Camera.getSummary(), Camera.getManual() or Camera.getAbout() give you some info. Otherwise, I can look in the source code of gphoto2 what is the function called from libphoto when --list-all-config is used.
3) I saw this error, and generally the camera is completely blocked for few minutes after that. I don't how I can reproduce the bug and fix that. I thinks it come from N-API or from a bad operation.
See you, Romain
Hum for config list CameraWidgets.getNames() return a list a of widgets name (configuration list). After that, you can use theses method
New version released. Now setValue() call apply() immediately after using setValue method.
Hi Romain, yes, CameraWidgets.getNames() returns all existing keys but without values.
Maybe y could add a "toJson()" method returning a complete cameraWidget by key name formatting like
{
"shutterspeed2": {
"label": "Shutter Speed 2",
"type": "choice",
"value": "1/500",
"choices": [
"1/8000",
...
"30",
"x 200",
"Bulb"
]
},
}
or much better ;) the complete treeview over sections > actions > props
{
"main": {
"type": "section",
"label": "Camera and Driver Configuration",
"children": {
"actions": {
"type": "section",
"label": "Camera Actions",
"children": {
"autofocusdrive": {
"label": "Drive Nikon DSLR Autofocus",
"type": "toggle",
"value": 0
},
Is there any method in API to get the section and then to iterate through it?
Whenever its possible please returning results as json it makes it easier to process it.
Thank y and best regards, Nic
Hello @Nic2012
Great news, v2.0.0 add method to generate configuration as JSON ;) I thinks and I hope you'll be happy :D
See you, Romain
haha :), I am already happy from the beginning of this new node wrapper ;)
only 2 suggestions:
Best regards, Nic
I'll fix that ASAP ;)
If you want help on the code PR are welcome. I can give you access to this repo ;). Tell me if you want to become a contributor.
Sorry, and I have 1 wish :) I found storage-info only in this big block of the getSummary() method, could y integrate a function in cameraWidget to resolve as Json, similar like in gphoto-cli:
gphoto2 --storage-info
[Storage 0]
label=NIKON D70
basedir=/store_00010001
access=2 Read-only with delete
type=4 Removable RAM
fstype=4 Camera layout (DCIM)
totalcapacity=7822432 KB
free=7452704 KB
freeimages=697
It returns an array with an entry for each memory card.
It's possible I think :)
hmm, let me first get more familiar with the library and type script, but I am not experienced with github and PRs.
I have mentioned y work at https://github.com/gphoto/libgphoto2 that Markus Meissner will maybe update the recommended bindings on his side.
Thanks @Nic2012 :D
BTW I would change in readme
Some example are available in the examples directory.
into
Some example are available in the examples directory, when you have cloned or downloaded the full project from github.
Otherwise people could confused when they cannot find it after npm install.
I sent you an invitation to this repo ;).
"thank y" ;) We ll see...how can I handle github
I cannot git clone as mentioned in y guidelines (after replaced username)
git clone https://github.com/YOUR_USERNAME/ts-express-decorators.git
...
remote: Repository not found.
fatal: repository 'https://github.com/....-decorators.git/' not found
yes because, it's the wrong repository url XD.
git checkout https://github.com/TypedProject/ts-gphoto2-driver.git
doesnt work on my PiZero:
git checkout https://github.com/TypedProject/ts-gphoto2-driver.git
fatal: Not a git repository (or any of the parent directories): .git
ok, works. Do I have then git checkout?
git checkout -b master, maybe ^^
I have warned y, first time doing this ;) cd into cloned folder? or rightaway "git checkout -b master"
My bad too. I use Webstorm and his UI to checkout or clone project.
GitKraken is very good to manage your git project with a UI ;)
Normally you have cloned the repo in the current directory. So if you run ls command you'll seen the project (with package.json). By default you are on master branch, but you can run git checkout -b master
to be sure :)
So far I have git on commandline directly on PIZero (Stretch headless) could be fine for the mom. When I have changed e.g. the readme from project how can I commit it to server? or better first by PR?
The right process is:
fix/update_readme
fix: Update readme information
See you Romain
Before y comment I (hopefully) managed it, please check.
Hi, how can i set or get a single config value e.g. shutterspeed, iso...?
Thank you providing us this wrapper.
Best regards, Nic