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

Not working with D300 #31

Open
mochihisa opened this issue Apr 11, 2021 · 8 comments
Open

Not working with D300 #31

mochihisa opened this issue Apr 11, 2021 · 8 comments

Comments

@mochihisa
Copy link

I tried to use it on my D300, but it did not work.

[0000]  INFO usb: found: 04b0:041a
[0000]  INFO main: started  
[0002]  WARN lv: workerLV: failed to start live view: the camera is not ready  
[0003]  WARN lv: frameCaptor: failed to decode header  
  • I heard the shutter open.
  • localhost:42839/view was not displayed.
  • After changing the F-stop on localhost:42839 and disconnecting the connection, I checked the settings of the main unit and found that the value had been changed.

The environment in which it was run is as follows.

OS : Ubuntu 20.10
Version : v1.2.0

@puhitaku
Copy link
Owner

Hi,

The shutter won't open if "the camera is not ready" error happens except you change the F value. I'd like to ask you to confirm that it opened after you changed it manually.

On the other hand, I pushed the experimental fix of this problem. Can you build this branch and run it with debug output enabled? mtplvcap -debug mtp,server

@puhitaku
Copy link
Owner

ping @mochihisa

@mochihisa
Copy link
Author

I'm sorry for the late reply. I don't have time right now, so I'll reply later.

@mochihisa
Copy link
Author

I'm getting different output than before. Is there any possibility?

[0000]  INFO usb: found: 04b0:041a
[0000] ERROR mtp: fatal error LIBUSB_ERROR_IO; closing connection.
[0000] FATAL mtp: failed to detect MTP devices: could not open 04b0:041a: mtp: no MTP extensions in ''

@puhitaku
Copy link
Owner

@mochihisa Sorry for inactivity,
It looks like the camera is not responding in an earlier stage than the original error message (failed to decode header). no MTP extensions in '' indicates many types of fundamental problems like interfered USB communication, broken USB cables, etc. Please checkout the master branch and see if the problem persists or not.

@mochihisa
Copy link
Author

I'm sorry, I'll be late in replying due to periodic exams.

@mochihisa
Copy link
Author

Sorry for the late reply.
The same result was obtained using the master branch. It seems that the cable is not damaged because it can be used for photo transfer.

@yanorei32
Copy link

yanorei32 commented Apr 12, 2022

I found 4 problems with D300.

  1. Failed to parse 64-byte style header.
  2. Failed to set f-value (showup an error message).
  3. Failed to set ISO (w/o error message)
  4. Showup invalid resolution.

Environment

Nikon D300 firmware A: 1.01, B: 1.00
libusb 1.0.25-3
go 1.18 linux/amd64
Arch Linux 5.17.1-arch1-1

Issue: Failed to parse 64-byte style header.

Log (Release 1.5.0 and 3bc52d4 are showed same logs):

$ ./mtplvcap -debug mtp,server
[0000]  INFO usb: found: 05ac:821f
[0000]  INFO usb: found: 04b0:041a
[0000]  WARN mtp: detected more than 1 device
[0000]  INFO mtp: opening the detected Nikon DSLR: 04b0:041a
[0000]  INFO main: started
[0000] DEBUG lv: manufacturer = NIKON, product = NIKON DSC D300, serialnumber = 000002014808
[0000] DEBUG lv: model matched: D300
[0001] DEBUG lv: current recording media: SDRAM
[0002]  WARN lv: workerLV: failed to start live view: the camera is not ready
[0003]  WARN lv: frameCaptor: failed to decode header
[0004]  WARN lv: frameCaptor: failed to decode header
[0005]  WARN lv: frameCaptor: failed to decode header

When I change the header size 64 to 96, 128, 192, 256, 384 (mtp/nikon.go), the resolution and frame rate were displayed correctly on localhost:42389 and "failed to decode header" is not show up.
But the image remained broken.

I dumped the raw byte array to binary file for debugging.

source code diff
diff --git a/mtp/server.go b/mtp/server.go
index 1bb11ba..e89892a 100644
--- a/mtp/server.go
+++ b/mtp/server.go
@@ -8,6 +8,7 @@ import (
        "encoding/json"
        "fmt"
        "io"
+       "io/ioutil"
        "net/http"
        "strconv"
        "sync"
@@ -778,6 +779,7 @@ func (s *LVServer) getLiveViewImgInner() (LiveView, error) {
        }

        raw := buf.Bytes()
+       _ = ioutil.WriteFile("debug", raw, 0644)

        lvr := liveViewRaw{}
        err = binary.Read(bytes.NewReader(raw[8:hs]), binary.BigEndian, &lvr)
xxd
0000000 8002 aa01 c010 200b c010 200b 6008 9005
0000010 6001 2001 8c09 9005 ffff ffff 0006 ff00
0000020 0100 0f00 e001 0f0e 0100 ffff ffff ffff
0000030 0000 0000 0000 0000 ffff ffff ffff ffff
0000040 d8ff dbff 8400 0400 0606 0607 0805 0707
0000050 0907 0809 0c0a 0d14 0b0c 0c0b 1219 0f13
0000060 1d14 1f1a 1d1e 1c1a 201c 2e24 2027 2c22

I found SOI marker (ffd8) at 0x40 (64).
And I tried get JPEG file with this script.

dd bs=1 skip=64 if=debug of=debug.jpg

This image is correct.

Download debug.zip

debug

I put some bytes (more than or equal 5) to binary.Read and I got works well, But it is dirty hack.

I think liveViewRaw has ommitable element(s).

I need accurate liveViewRaw struct for 64-byte style header.

diff --git a/mtp/server.go b/mtp/server.go
index 1bb11ba..0760695 100644
--- a/mtp/server.go
+++ b/mtp/server.go
@@ -780,7 +780,7 @@ func (s *LVServer) getLiveViewImgInner() (LiveView, error) {
        raw := buf.Bytes()

        lvr := liveViewRaw{}
-       err = binary.Read(bytes.NewReader(raw[8:hs]), binary.BigEndian, &lvr)
+       err = binary.Read(bytes.NewReader(raw[8:hs+5]), binary.BigEndian, &lvr)
        if err != nil {
                return LiveView{}, fmt.Errorf("failed to decode header")
        }

Issue: Failed to set f-value (showup an error message):

I tried to change f-number but I got ERROR (1.5.0 and 3bc52d4).

$ ./mtplvcap -debug mtp,server
...
[0010] DEBUG lv: HandleControl: set ISO: 2500
[0011]  WARN lv: frameCaptor: failed to decode header
[0015]  WARN lv: frameCaptor: failed to decode header
[0016] DEBUG lv: HandleControl: set f-number: 10
[0016] ERROR lv: HandleControl: failed to set f-number: failed to set f-number: RetCode a005
[0016] DEBUG lv: current recording media: SDRAM
[0017]  WARN lv: workerLV: failed to start live view: the camera is not ready
[0018]  WARN lv: frameCaptor: failed to decode header

Issue: Failed to set ISO (w/o error message)

ISO value does not affect the image w/o error message. (check on 3bc52d4 + dirtyhack)

Issue: Showup invalid resolution.

D300 reports original camera resolution (4288x2848) but image resolution is 640x426. (check on 3bc52d4 + dirtyhack)
image

Note:

This model's ISO and F-value control does not affect to internal LiveView function's image.
F-number and ISO may be out-of-control in LiveView mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants