Browse Source

Try to add get settings command

master
squeaky otter 2 months ago
parent
commit
02d57d08f3
5 changed files with 118 additions and 3 deletions
  1. +2
    -2
      .vscode/launch.json
  2. +24
    -1
      src/main.cpp
  3. +35
    -0
      src/nikonDatalink.cpp
  4. +1
    -0
      src/nikonDatalink.h
  5. +56
    -0
      src/nikonPackets.h

+ 2
- 2
.vscode/launch.json View File

@ -9,7 +9,7 @@
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/pikon",
"args": ["-p", "/dev/ttyUSB0", "fire_shutter"],
"args": ["-p", "/dev/ttyUSB0", "get_settings"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
@ -28,7 +28,7 @@
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/pikon",
"args": ["-p", "/dev/ttyUSB0", "fire_shutter"],
"args": ["-p", "/dev/ttyUSB0", "get_settings"],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],


+ 24
- 1
src/main.cpp View File

@ -11,6 +11,7 @@ struct Options {
void identify_camera(Options const &opt);
void focus(Options const &opt);
void fireShutter(Options const &opt);
void getCameraSettings(Options const &opt);
int main(int argc, char **argv) {
CLI::App app("Pikon DataLink");
@ -31,6 +32,9 @@ int main(int argc, char **argv) {
CLI::App *cmdFireShutter = app.add_subcommand("fire_shutter", "fire shutter");
cmdFireShutter->callback([opts]() { fireShutter(*opts); });
CLI::App *cmdGetSettings = app.add_subcommand("get_settings", "get settings");
cmdGetSettings->callback([opts]() { getCameraSettings(*opts); });
app.require_subcommand();
@ -84,4 +88,23 @@ void fireShutter(Options const &opt) {
dl.fireShutter();
dl.endSession();
}
}
void getCameraSettings(Options const &opt) {
NikonDatalink dl(opt.serialPort);
if (opt.debug) {
dl.setLogLevel(LOG_DEBUG);
} else {
dl.setLogLevel(LOG_INFO);
}
dl.startSession();
// should switch baudrate before getting infos
CameraControlGlobals *cameraControls = NULL;
cameraControls = dl.getCameraSettings();
dl.endSession();
}

+ 35
- 0
src/nikonDatalink.cpp View File

@ -662,4 +662,39 @@ void NikonDatalink::fireShutter() {
*/
int NikonDatalink::getSessionError() {
return sessionErr;
}
CameraControlGlobals *NikonDatalink::getCameraSettings() {
// should we do something like CameraFormInit of CameraControl.c
int err, endErr = 0;
CameraControlGlobals *sCCG;
sCCG->valid = false;
sendCommand(kReadDataMode, 0x0000FD21, &(sCCG->locationFD21), 1);
sendCommand(kReadDataMode, 0x0000FD25, &(sCCG->locationFD25), 9);
sendCommand(kReadDataMode, 0x0000FD3A, &(sCCG->locationFD3A), 4);
sendCommand(kReadDataMode, 0x0000FD89, &(sCCG->locationFD89), 1);
sendCommand(kReadDataMode, 0x0000FD8E, &(sCCG->locationFD8E), 3);
sendCommand(kReadDataMode, 0x0000FE20, &(sCCG->locationFE20), 21);
sendCommand(kReadDataMode, 0x0000FE3A, &(sCCG->locationFE3A), 1);
sendCommand(kReadDataMode, 0x0000FE4F, &(sCCG->locationFE4F), 3);
sendCommand(kReadDataMode, 0x0000FD9D, &(sCCG->locationFD9D), 1);
if ((err = getSessionError()) != 0) goto ERROR;
sCCG->valid = true;
return sCCG;
ERROR:
endErr = endSession();
if (err == 0) err = endErr;
// log error somehow
return NULL;
}

+ 1
- 0
src/nikonDatalink.h View File

@ -36,6 +36,7 @@ class NikonDatalink {
void fireShutter();
int getSessionError();
bool switchBaudrate();
CameraControlGlobals *getCameraSettings();
const char *serialPortName;


+ 56
- 0
src/nikonPackets.h View File

@ -138,3 +138,59 @@ typedef struct {
unsigned int byteCount;
} MemoHolderResponse;
#define kMemoHolderResponseSize 4
typedef struct CameraControlGlobals {
unsigned char valid;
unsigned char locationFD21;
unsigned char locationFD25;
unsigned char locationFD26;
unsigned char locationFD27;
unsigned char locationFD28;
unsigned char locationFD29;
unsigned char locationFD2A;
unsigned char locationFD2B;
unsigned char locationFD2C;
unsigned char locationFD2D;
unsigned char locationFD3A;
unsigned char locationFD3B;
unsigned char locationFD3C;
unsigned char locationFD3D;
unsigned char locationFD89;
unsigned char locationFD8E;
unsigned char locationFD8F;
unsigned char locationFD90;
unsigned char locationFD9D;
unsigned char locationFE20;
unsigned char locationFE21;
unsigned char locationFE22;
unsigned char locationFE23;
unsigned char locationFE24;
unsigned char locationFE25;
unsigned char locationFE26;
unsigned char locationFE27;
unsigned char locationFE28;
unsigned char locationFE29;
unsigned char locationFE2A;
unsigned char locationFE2B;
unsigned char locationFE2C;
unsigned char locationFE2D;
unsigned char locationFE2E;
unsigned char locationFE2F;
unsigned char locationFE30;
unsigned char locationFE31;
unsigned char locationFE32;
unsigned char locationFE33;
unsigned char locationFE34;
unsigned char locationFE3A;
unsigned char locationFE4F;
unsigned char locationFE50;
unsigned char locationFE51;
} CameraControlGlobals;

Loading…
Cancel
Save