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

Command line interface #11

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,24 @@ cmake --build .

The tool fuji_cam_wifi_tool is an interactive shell (based on [linenoise](https://github.com/arangodb/linenoise-ng)) that can be used to send commands to the camera.
At this time it is very limited and mostly undocumented.
Supported commands are `connect`, `shutter`, `stream`, `info`, `set_iso`, `aperture`, `white_balance`, `shutter_speed`.
I suggest to look at the code.

Supported commands are:
```
fcwt> help
Usage:
help|connect|info|shutter|focus-unlock
increment|decrement TARGET
set TARGET VALUE1 [VALUE2]
stream [cv]
TARGET:
iso: takes an integer value (e.g. 200)
f-number: takes a float value (e.g. 3.5)
focus-point: takes a pair of values denoting the focus point coordinates X and Y (e.g. 5 5)
shutter-speed: takes a value of the form N/M or N (e.g. 1/20, 3)
exposure-compensation:
takes a float value (e.g. 1.3)
white-balance|film-simulation|self-timer|flash:
takes an integer value. Value is one of the values in camera properties
```
Mac OS X:
```
./tool/fuji_cam_wifi_tool
Expand Down
2 changes: 2 additions & 0 deletions lib/src/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,8 @@ bool shutter(native_socket const sockfd, native_socket const sockfd2, const char
}

bool current_settings(native_socket sockfd, current_properties& settings) {
if (sockfd <= 0) return false;

auto const msg = generate<status_request_message>();
fuji_send(sockfd, &msg, sizeof(msg));
uint8_t buf[1024];
Expand Down
4 changes: 4 additions & 0 deletions tool/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ cmake_minimum_required(VERSION 2.8.11)

add_subdirectory(linenoise-ng)

execute_process(COMMAND git apply ../linenoise_linebreaks.patch
WORKING_DIRECTORY ../tool/linenoise-ng
ERROR_QUIET)

project(fuji_cam_wifi_tool)
file(GLOB fuji_cam_wifi_tool_sources ${CMAKE_CURRENT_SOURCE_DIR} src/*.cpp)
file(GLOB fuji_cam_wifi_tool_headers ${CMAKE_CURRENT_SOURCE_DIR} src/*.hpp)
Expand Down
26 changes: 26 additions & 0 deletions tool/linenoise_linebreaks.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
diff --git a/src/linenoise.cpp b/src/linenoise.cpp
index 366a94f..df04801 100644
--- a/src/linenoise.cpp
+++ b/src/linenoise.cpp
@@ -1879,7 +1879,7 @@ static int cleanupCtrl(int c) {
}

// break characters that may precede items to be completed
-static const char breakChars[] = " =+-/\\*?\"'`&<>;|@{([])}";
+static const char breakChars[] = "=+/\\*?\"'`&<>;|@{([])}";

// maximum number of completions to display without asking
static const size_t completionCountCutoff = 100;
@@ -2513,9 +2513,9 @@ int InputBuffer::getInputLine(PromptBase& pi) {

// ctrl-I/tab, command completion, needs to be before switch statement
if (c == ctrlChar('I') && completionCallback) {
- if (pos == 0) // SERVER-4967 -- in earlier versions, you could paste
- // previous output
- continue; // back into the shell ... this output may have leading
+ //if (pos == 0) // SERVER-4967 -- in earlier versions, you could paste
+ // // previous output
+ // continue; // back into the shell ... this output may have leading
// tabs.
// This hack (i.e. what the old code did) prevents command completion
// on an empty line but lets users paste text with leading tabs.
Loading