PTP and USB remote simultaneously with USB_force_active() - Script Writing - CHDK Forum

PTP and USB remote simultaneously with USB_force_active()

  • 24 Replies
  • 14025 Views
PTP and USB remote simultaneously with USB_force_active()
« on: 21 / May / 2015, 13:00:54 »
Advertisements
I'm trying to use a camera with PTP and a USB remote at the same time, but am having trouble. Here is what I do and what happens:

1. Make the PTP connection to the camera
2. Turn usb_force_active on
3. Turn USB remote on
4. Turn off the switch in the 5V line

After step 4, the PTP connection breaks immediately

I think the computer is breaking the connection. Could it be anything else? And has anyone else had this problem?

Camera:       A2500
CHDK version: 1.3.0
OS:           Windows 8.1
PTP Client:   chdkptp
USB driver:   libusb-win32

Thanks!

Re: PTP and USB remote simultaneously with USB_force_active()
« Reply #1 on: 21 / May / 2015, 13:08:39 »
Camera:       A2500
CHDK version: 1.3.0
IIRC,   support for this function was only built-in by default for a couple of camera during the CHDK 1.3.0 release phase.  Support for this function on the A2500 was added at release 3584.  What release level is your A2500 using?

Note that all cameras support this functionality under 1.4.0 so you might want to try downloading and working with the development version.  It's pretty robust at this point as it inches towards becoming the new stable release level.

Are you using a script to set usb_force_active and USB remote on?  Or doing it with the CHDK menus and/or chdkptp commands?
« Last Edit: 21 / May / 2015, 13:17:15 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

Re: PTP and USB remote simultaneously with USB_force_active()
« Reply #2 on: 21 / May / 2015, 14:25:22 »
Josh P,

I tried this http://chdk.setepontos.com/index.php?topic=12343.msg121994#msg121994  with 1.4, on a single camera, pretty recently - that small test worked fine. 

Re: PTP and USB remote simultaneously with USB_force_active()
« Reply #3 on: 21 / May / 2015, 17:58:11 »
I'm using release 4152. usb_force_active() returns as true.

If I turn on the USB remote option on without usb_force_active, the PTP connection breaks immediately (which I believe is expected). However, when I turn the USB remote on with usb_force_active enabled, the connection is fine, and it only breaks when I turn the switch in the 5V line off.

I've been sending the command
=usb_force_active(1)
from the chdk CLI, and then using the chdk menu on the camera to turn on the USB remote. Eventually I'll be doing all of this in a script.

I'll try version 1.4 and see if that changes anything.

Re: PTP and USB remote simultaneously with USB_force_active()
« Reply #4 on: 21 / May / 2015, 19:57:18 »
I'm using release 4152. usb_force_active() returns as true.  If I turn on the USB remote option on without usb_force_active, the PTP connection breaks immediately (which I believe is expected).
So far, so good.

Quote
However, when I turn the USB remote on with usb_force_active enabled, the connection is fine, and it only breaks when I turn the switch in the 5V line off.
Implying that the code used by  usb_force_active()  in the A2500 kbd.c file is not working.  I'll take a look.

Quote
I've been sending the command =usb_force_active(1)  from the chdk CLI, and then using the chdk menu on the camera to turn on the USB remote.
reyalp will probably need to comment on whether this is acceptable or not.   In the meantime,  I'll test on my A1200 (one of the other few cameras that have the function under 1.3.0.

Quote
Eventually I'll be doing all of this in a script
If you have a few minutes,  it would be interesting to see if that works now.  At least until we hear from reyalp later tonight.
Ported :   A1200    SD940   G10    Powershot N    G16

Re: PTP and USB remote simultaneously with USB_force_active()
« Reply #5 on: 21 / May / 2015, 20:14:11 »
However, when I turn the USB remote on with usb_force_active enabled, the connection is fine, and it only breaks when I turn the switch in the 5V line off.
Implying that the code used by  usb_force_active()  in the A2500 kbd.c file is not working.  I'll take a look.
The A2500 is a carbon copy of the A1200 code, which I know works.   And according to comments in the A2500 porting thread the USB remote functionality was tested and reported working.
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline reyalp

  • ******
  • 14125
Re: PTP and USB remote simultaneously with USB_force_active()
« Reply #6 on: 21 / May / 2015, 23:46:02 »
However, when I turn the USB remote on with usb_force_active enabled, the connection is fine, and it only breaks when I turn the switch in the 5V line off.
usb_force_active tricks the canon firmware into thinking the USB power is there, but I'm not surprised the PC host controller notices when it gets cut.

On my D10, if I use usb_force_active, unplug the cable and re-plug it, I get an IO error the next time I try to do something in chdkptp, but I can reconnect.

I'm not sure if this is the same behavior I posted about in the development thread http://chdk.setepontos.com/index.php?topic=11779.msg115815#msg115815 I thought there was a window of time where it just worked, but I don't remember exactly what I tested.

Note if you are using the GUI, it polls to check the available cameras and connection status, so it will notice almost immediately if the USB connection dies. You set gui_dev_check_interval=0 to disable this polling.

edit:
As I understand it, the main purpose of usb_force_active is to keep the camera from freaking out. Normally, if you switch to rec under PTP control and then disconnect, and then reconnect the cable, the camera will go back to play mode.
« Last Edit: 21 / May / 2015, 23:49:03 by reyalp »
Don't forget what the H stands for.

Re: PTP and USB remote simultaneously with USB_force_active()
« Reply #7 on: 22 / May / 2015, 00:00:50 »
usb_force_active tricks the canon firmware into thinking the USB power is there, but I'm not surprised the PC host controller notices when it gets cut.  On my D10, if I use usb_force_active, unplug the cable and re-plug it, I get an IO error the next time I try to do something in chdkptp, but I can reconnect.
I'm confused.  How would the PC host controller know that the +5V line into the camera was "cut" or "opened"? Unless it monitors current flow on the V+ pin (which seems unlikely) there is no way for it to know.   And the D+ and D- lines don't change (i.e. are not opened or cut) so things should just proceed as normal.

Quote
Note if you are using the GUI, it polls to check the available cameras and connection status, so it will notice almost immediately if the USB connection dies. You set gui_dev_check_interval=0 to disable this polling.
Again - why would the USB connection die?  The camera should never notice the +5V being connected or disconnected (due to the hack in kbd.c) and the D+ and D- lines are still intact.  (Unless you actually disconnect the complete cable that is).

Unless there is actual hardware that sense the USB +5V pin and acts independently of where we hooked the firmware in kbd.c   In which case the hack would not work at all.


Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline reyalp

  • ******
  • 14125
Re: PTP and USB remote simultaneously with USB_force_active()
« Reply #8 on: 22 / May / 2015, 00:48:47 »
And the D+ and D- lines don't change (i.e. are not opened or cut) so things should just proceed as normal.
Do we know they aren't connected to the +5 in any way? I know next to nothing about the USB at the electrical level.

Quote
Again - why would the USB connection die?
What I meant is *if* the USB connection dies for whatever reason, it will be immediately apparent in the GUI, while in the CLI you won't notice until you actually try to do something.
Don't forget what the H stands for.

Re: PTP and USB remote simultaneously with USB_force_active()
« Reply #9 on: 22 / May / 2015, 02:49:20 »
How would the PC host controller know that the +5V line into the camera was "cut" or "opened"? Unless it monitors current flow on the V+ pin (which seems unlikely) there is no way for it to know.

I once read about a USB configuration descriptor (bMaxPower --> Maximum Power Consumption in 2mA units). Could that infer the host controller monitors/limits the current supplied? (and if 0 power monitored, cause it to stop data supply)

Edit:
the description also referred to - failing any operation it could not perform without external power.

Could a powered hub solve the problem?

« Last Edit: 22 / May / 2015, 03:38:08 by andrew.stephens.754365 »

 

Related Topics


SimplePortal © 2008-2014, SimplePortal