Files

如何將文件複製到相機?

  • February 27, 2015

我想將韌體更新文件複製到通過 USB 連接的佳能 7D 相機。

在它被thunar++自動掛載後,我嘗試了以下操作thunar-volmangvfs-gphoto2

$ cp eos7d-v205-win/7D000205.FIR /run/user/1000/gvfs/gphoto2\:host\=%5Busb%3A001%2C012%5D/
$ echo $?
0
$ ls /run/user/1000/gvfs/gphoto2\:host\=%5Busb%3A001%2C012%5D/
DCIM  MISC

就這樣進入了黑洞。


我第一次嘗試使用 - 複製它時-粘貼Ctrl文件時會列印以下錯誤消息:c``Ctrl``v

寫入文件時出錯。

-108:沒有這樣的文件或目錄。

你想跳過它嗎?

如果我在那之後再試一次,它就會崩潰:

$ thunar
Segmentation fault (core dumped)
$ echo $?
139

Gphoto 2 shell 有一個未記錄 put的功能,我也嘗試過:

$ sudo umount /run/user/1000/gvfs
$ gphoto2 --shell
gphoto2: {.../eos7d-v205-win} /> help put
Help on "put":

Usage: put [directory/]filename
Description:
       Upload a file

* Arguments in brackets [] are optional

所以這個函式接受一個帶有可選目錄的參數。很奇怪,但應該是可行的。使其發揮作用的一些嘗試:

$ gphoto2 --shell
gphoto2: {.../eos7d-v205-win} /> ls
store_00010001/     
gphoto2: {.../eos7d-v205-win} /> put 7D000205.FIR                       

*** Error ***              
You need to specify a folder starting with /store_xxxxxxxxx/
*** Error (-1: 'Unspecified error') ***
gphoto2: {.../eos7d-v205-win} /> put /store_00010001/7D000205.FIR

*** Error ***              
PTP Access Denied
*** Error (-1: 'Unspecified error') ***
gphoto2: {.../eos7d-v205-win} /> put /store_00010001/MISC/7D000205.FIR

*** Error ***              
PTP Access Denied
*** Error (-1: 'Unspecified error') ***

也許不支持


Digikam 有一個上傳功能,但它只是報告’無法上傳文件“7D000205.FIR”。’ 從 shell 執行它不會產生更多資訊。


man gvfs-copy沒有明確說它不能複製到相機,但我不知道如何:

$ gvfs-copy "file://${HOME}/7D000203.FIR" /run/user/1000/gvfs/gphoto2\:host\=%5Busb%3A004%2C006%5D/
Error copying file file:///[...]/7D000203.FIR: Error writing file: -1: Unspecified error
$ gvfs-copy "file://${HOME}/7D000203.FIR" file:///run/user/1000/gvfs/gphoto2\:host\=%5Busb%3A004%2C006%5D/
Error copying file file:///[...]/7D000203.FIR: Error opening file '/run/user/1000/gvfs/gphoto2:host=[usb:004,006]': No such file or directory
$ gvfs-copy "file://${HOME}/7D000203.FIR" gphoto2://host\=%5Busb%3A004%2C006%5D/
Error copying file file:///[...]/7D000203.FIR: The specified location is not mounted

gphoto2說應該可以將文件上傳到相機:

$ gphoto2 --port usb: --abilities
Abilities for camera             : Canon EOS 7D                                
Serial port support              : no
USB support                      : yes
Capture choices                  :
                                : Image
                                : Preview
Configuration support            : yes
Delete selected files on camera  : yes
Delete all files on camera       : no
File preview (thumbnail) support : yes
File upload support              : yes

gphoto2 手冊說它支持“上傳”文件。它不起作用。嘗試報告為在其他地方工作的命令

$ gphoto2 --upload-file 7D000203.FIR --folder /store_00010001
*** Error ***              
PTP Access Denied
*** Error (-1: 'Unspecified error') ***       

For debugging messages, please use the --debug option.
Debugging messages may help finding a solution to your problem.
If you intend to send any error or debug messages to the gphoto
developer mailing list <gphoto-devel@lists.sourceforge.net>, please run
gphoto2 as follows:

   env LANG=C gphoto2 --debug --debug-logfile=my-logfile.txt --upload-file 7D000203.FIR --folder /store_00010001

Please make sure there is sufficient quoting around the arguments.

嘗試調試命令後,我得到以下相關日誌行:

ptp_usb_getresp [usb.c:434] (0): PTP_OC 0x100c receiving resp failed: PTP Access Denied (0x200f)
put_file_func [library.c:5940](0): 'ptp_sendobjectinfo (params, &storage, &parent, &handle, &oi)' failed: 'PTP Access Denied' (0x200f)
gp_context_error            (0): PTP Access Denied
gp_camera_folder_put_file [gphoto2-camera.c:1248](0): 'gp_filesystem_put_file (camera->fs, folder, filename, type, file, context)' failed: -1
gp_camera_free              (2): Freeing camera...
gp_camera_exit              (2): Exiting camera ('Canon EOS 7D')...
ptp_usb_sendreq             (2): Sending PTP_OC 0x1003 / Close session request...
gp_port_write               (3): Writing 12 = 0xc bytes to port...
gp_port_write               (3): Wrote   12 = 0xc bytes to port: (hexdump of 12 bytes)
0c 00 00 00 01 00 03 10-0c 00 00 00              ............    

每分鐘 WTF太多。在 Arch Linux 中我需要做什麼才能將文件複製到我的相機?

如果相關:我嘗試在 Windows 7 上複製文件,但它失敗了:

您無權創建此項目。

我不確定您是否會喜歡這個答案,但根據我的經驗,使用 PTP 總是會導致較高的 WTF/min。大概是相機本身限制了根文件夾中的寫入,或者同樣有意義的東西。

我建議您使用 CompactFlash 讀卡器,直接安裝文件系統,並使用這種訪問方式將韌體文件複製到卡的根文件夾(例如,mount /dev/sdc1 /mnt/camera然後cp eos7d-v205-win/7D000205.FIR /mnt/camera/)。

我發現讀卡器感覺比 PTP 快得多,大概是因為前者可以從電腦的文件系統預讀功能中受益,而 PTP 則不能,所以我認為它們是值得(而且很小)的費用。

引用自:https://unix.stackexchange.com/questions/118718