Wireless investigations - page 7 - General Discussion and Assistance - CHDK Forum  

Wireless investigations

  • 71 Replies
  • 22478 Views
*

Online reyalp

  • ******
  • 13347
Re: chdkptp - alternative ptp client
« Reply #60 on: 25 / March / 2021, 20:41:17 »
Advertisements
No PCs were ever registered (never used the Canon PC software). I'm just using the "add a device ..." menu entry without completing that process.
Yeah, I meant the add device step. But my procedure is to add the device fully, and then remove it on windows. So you'll still have a saved entry on the camera, but the PC won't respond.

Quote
Quote
Wireshark might give an idea what stage fails.
The camera answers the init attempt with an "init fail" answer, or at least that's what wireshark seems to be suggesting.
Hmm, chdkptp should notice that and fail, rather than timing out.  I apparently got that response in previous investigations starting the network with eventpeocs https://chdk.setepontos.com/index.php?topic=10724.msg108336#msg108336

edit:
On my sx730 which I hadn't connected to my PC before, I was able to connect chdkptp in the connect screen, without adding it in windows.

I ran most of the non-shooting chdkptp camtests over PTP/IP on elph130. To do this, you need to set up the connection first, and then run something like
Code: [Select]
!require'camtests'.tests:do_test({skip_names={'shoot','reconnect','connect'}})
connect would fail because you need to do the ptp_get_object_handles stuff, and reconnect would fail because you need to restart the connection process on the camera.
You can skip the slow transfer size bugs tests by adding 'xfersizebugs' to skip_names.

All the others all passed repeated runs, which seems positive for PTP/IP being stable enough to use. I also downloaded ~180 MB of photos using imdl without problems.
« Last Edit: 27 / March / 2021, 00:17:34 by reyalp »
Don't forget what the H stands for.

*

Online reyalp

  • ******
  • 13347
Re: Wireless investigations
« Reply #61 on: 29 / March / 2021, 03:19:59 »
I spent some time figuring out what is needed to get a computer to show up in the connect list and allow ptp/ip connections.

I was able to establish a connection from a raspberry pi using a very hacked up version of https://github.com/MoshiBin/ssdpy and a separate http server. I'll post code later.

The basic process is UPnP (see http://www.upnp.org/specs/arch/UPnP-arch-DeviceArchitecture-v1.0-20081015.pdf) but the camera expects very specific values. For example, the responding device must include Microsoft-Windows in the server header  ::)

The camera sends UPnP multicast M-SEARCH * looking for upnp:rootdevice

It expects a specific unicast HTTP over UDP response, which includes the URL of an xml file describing the device.

If it receives an acceptable response, it requests the XML file using regular HTTP. If that response and content is acceptable, it shows the system in the menu (using a "friendly name" defined in the XML file) and accepts ptp/ip connections from that system after it's chosen in the menu.

I'm not entirely sure how it decides the ptp/ip connection is from the same system, but it's almost certainly IP or MAC.

The camera also issues multicast DNS queries for "_ptp-init._tcp.local", which I believe are for an entirely separate system intended for Mac (https://developer.apple.com/library/archive/documentation/Networking/Conceptual/dns_discovery_api/Introduction.html). This looks like it could be simpler, and I was able to get https://pypi.org/project/zeroconf/ to generate a response, but wasn't able to guess the parameters needed for it to be accepted. A capture of successful connection would likely be needed to make this work.

edit:
From this https://github.com/gphoto/gphoto2/issues/282 it looks some people have gotten a response with mobile connect option and mDNS with gphoto, but I haven't found a clear description of all the parts yet.
For modern cameras, the mobile mode might be preferable, since many support shooting from the mobile app.
« Last Edit: 29 / March / 2021, 16:42:50 by reyalp »
Don't forget what the H stands for.

*

Online reyalp

  • ******
  • 13347
Re: Wireless investigations
« Reply #62 on: 30 / March / 2021, 02:54:54 »
Here's the python scripts to enable ptpip connections from Linux. They work for me on raspberry pi OS and Ubuntu 20.04 (edit and on windows 10 uses msys2 msys or mingw python).
It's possible they could work on Mac too (confirmed working on MacOS 11)

edit:
2021/04/18 updated version 0.1.1 with improved windows support.


edit:
This also allows gphoto2 to connect over ptpip, like
 gphoto2 --port ptpip:192.168.123.45 -L

From the readme:
ptpip-canon-upnp-helper.py
Responds to UPnP M-SEARCH requests for upnp:rootdevice

ptpip-canon-desc-helper.py
Responds HTTP GET requests with an XML file containing a suitable description
By default, started automatically by ptpip-canon-upnp-helper.py, so you
shouldn't need to run it directly.

Dependencies:
Python 3
pip install ssdpy

To connect from chdkptp (https://app.assembla.com/wiki/show/chdkptp) you must
build chdkptp with PTP/IP support by setting PTPIP_SUPPORT=1 in config.mk

Basic usage:
ptpip-canon-upnp-helper.py LAN_IP_Address

LAN_IP_Address must be an IPv4 address (not hostname) on the computer you
want to connect the camera to, reachable from the wifi network the camera
will connect from.

Basic options:
Use -n to set the name that will appear in the Canon UI. It defaults to the
computer hostname, as returned by socket.gethostname()

Pass -P to ptpip-canon-upnp-helper.py to set the port used for description
requests. Default is 8043

UPnP requests are listened for on UDP port 1900. This is defined on the camera
and cannot be changed.

To provide a persistent ID for your connection ptpip-canon-upnp-helper.py will
create a file named ptpip-canon-helper.uuid in the current directory if it does
not already exist.


To connect a camera, go to the connection menu on the camera, select computer
and "Add a Device..."

If it works, you should see the hostname of your computer (or the name specified
with the -name option) listed on the Canon display.

This process will generate some requests to the scripts, which will show the
requesting IP in standard output, like
INFO:ptpip-upnp-helper:Received qualifying M-SEARCH from ('192.168.123.45', 58981)
192.168.123.45 - - [29/Mar/2021 22:36:47] "GET /ptpip-canon-desc-helper.xml HTTP/1.1" 200 -

Select the name and press set. The camera will go into a screen that says
"Connected to device <name>"

To connect in chdkptp, enter
connect -h=<camera_ip>

To prevent the camera from timing out and closing the connection, use
!con:ptp_get_object_handles()

The screen will go black. To re-enable the screen, enter
=post_levent_to_ui(4482)
for DryOS cameras, or
=post_levent_to_ui(4418)
for VxWorks

File transfers and scripting should work. Switching to shooting mode or
shooting fail on known cameras without additional hacking.

Use control+C to kill the scripts.

Note IPv6 is not supported by these scripts. In my testing, the cameras
only attempted IPv4. However, I have not tested an IPv6-only environment
« Last Edit: 06 / July / 2021, 00:08:28 by reyalp »
Don't forget what the H stands for.

*

Offline srsa_4c

  • ******
  • 4425
Re: Wireless investigations
« Reply #63 on: 30 / March / 2021, 18:47:55 »
Here's the python scripts to enable ptpip connections from Linux.
Thanks for the script. I can finally report success with the sx280 - if I make a connection on camera (with the script running on the PC), the chdkptp connection succeeds.


*

Online reyalp

  • ******
  • 13347
I tried two of my cams. Both use the constants mentioned, although the M10 never goes into blank screen mode (so I could not observe state 3).
Thanks for the report.
con:ptp_get_object_handles() doesn't make the screen go black on M10? Can you switch to rec and shoot over wifi?

The problem on sx710 seems to be related to the same variable the prevents / allows shooting with wifi on g7x (sx710 0x8a3c, g7x 0x8aa8), but the behavior is different between USB and wifi: With USB, clicking half shoot switches to rec, and clears the variable. In wifi, it prompts to cancel the wifi connection. The check for it isn't present on sx280. It's checked in the function that references "_EnrySRec"
Don't forget what the H stands for.

*

Offline srsa_4c

  • ******
  • 4425
the M10 never goes into blank screen mode
False alarm. That camera is just being treated differently for some reason (by the gphoto gvfs module). !con:ptp_get_object_handles() does blank the screen.
Can you switch to rec and shoot over wifi?
Switching works on both cams, but the connection is then dropped immediately.

*

Online reyalp

  • ******
  • 13347
False alarm. That camera is just being treated differently for some reason (by the gphoto gvfs module). !con:ptp_get_object_handles() does blank the screen.
Thanks.
Quote
Switching works on both cams, but the connection is then dropped immediately.
Using chdkptp "rec", with the patched switch_mode_usb? (or unlocking with manual post_levent_to_ui(4482))
Don't forget what the H stands for.

*

Offline srsa_4c

  • ******
  • 4425
Using chdkptp "rec", with the patched switch_mode_usb?
The rec button on GUI, both cams run patched CHDK.


*

Online reyalp

  • ******
  • 13347
Using chdkptp "rec", with the patched switch_mode_usb?
The rec button on GUI, both cams run patched CHDK.
Did you go to the black screens state with !con:ptp_get_object_handles() first?

On may cameras, if you stay in the "connecting" screen on the cam without going to the black screen state, switching to rec works but closes the connection. The connection will also close automatically after a short time (a minute or two, IIRC)

If you go to the black screen state and then use the 4482 event, the connection doesn't close and switching to rec works on elph130 (but shooting fails). On my d6 cams, switching to rec fails: The cam briefly switches to rec and then goes back to play, unless the variable mentioned earlier is poked.
Don't forget what the H stands for.

*

Offline srsa_4c

  • ******
  • 4425
Did you go to the black screens state with !con:ptp_get_object_handles() first?
No.
I retried with the black screen trick. The sx280 seems fully working with that, I'm able to switch play<->rec, shoot. The M10 doesn't fully enter rec mode, shows playback screen but mode list gets populated. *If I half-press, it asks whether I want to disconnect. If I say no, it remains connected and nothing changes, otherwise connection breaks and cam enters real rec mode. Did not look for that variable yet.

edit:
*That happens to match what you described above.

edit2:
Poking the variable (0x8adc, @FC341E6C in m10 101d) resolves the problems, play<->rec switch, shooting works.
« Last Edit: 02 / April / 2021, 17:17:09 by srsa_4c »

 

Related Topics