Technical aspects of multi-camera PTP communication. - page 2 - General Discussion and Assistance - CHDK Forum

Technical aspects of multi-camera PTP communication.

  • 16 Replies
  • 9621 Views
Re: Technical aspects of multi-camera PTP communication.
« Reply #10 on: 25 / January / 2014, 15:23:59 »
Advertisements
Well, I have no problem sending commands to a selected or all cameras, or downloading  files  to the PC from a selected camera or all cameras  .............  sometimes !

At other times I get a message "Protocol error: data expected".

That is because fopen() failed on the camera.

Sometimes it works, other times it does not, with exactly the same files.


Any idea why ?

*

Offline reyalp

  • ******
  • 14125
Re: Technical aspects of multi-camera PTP communication.
« Reply #11 on: 25 / January / 2014, 15:43:39 »
That is because fopen() failed on the camera.
Most common reason I've seen for this is insufficient memory.

If you are downloading while shooting, it's also possible the file doesn't exist yet. It's also possible to run into open file limits, but I would expect this to crash rather than fopen failing.

Or your code doesn't actually generate the right file name, perhaps due to file counter or directory rollover issues.
Don't forget what the H stands for.

Re: Technical aspects of multi-camera PTP communication.
« Reply #12 on: 25 / January / 2014, 15:53:46 »
Hmmm ..... I am not downloading while shooting and the filepath and name is correct, I am displaying it.
For testing, I download the same files every time using the same code.
Sometimes all files download, other times none do.

One of the files is just a few KB in size.

However, the buffer allocation is mweerden's fixed value of 0xc000 which is very large.

If I used your method of allocating buffer size it would mean adding an unwanted structure and support functions.

Buffer size does seem to be main suspect.

*

Offline reyalp

  • ******
  • 14125
Re: Technical aspects of multi-camera PTP communication.
« Reply #13 on: 25 / January / 2014, 17:09:00 »
One of the files is just a few KB in size.
Simply opening a file with fopen creates a ~32kb buffer. You can use open instead, but then you have to manage cached/unchached yourself.

There have also been bugs both in the ptpcam and chdk sides that caused some data to be corrupted, so depending what code you started from, you might be re-encountering one of those.
Don't forget what the H stands for.

Re: Technical aspects of multi-camera PTP communication.
« Reply #14 on: 25 / January / 2014, 17:23:06 »
Simply opening a file with fopen creates a ~32kb buffer.

Oh ..

Quote
You can use open instead

I did consider that.

Quote
but then you have to manage cached/unchached yourself.
I do not know anything about that.

Quote
There have also been bugs both in the ptpcam and chdk sides that caused some data to be corrupted

Yes, but the camera does not get as far as opening the file to send the data.

I just cannot figure-out the random nature of it.

If I repeat the command after getting the error, the camera crashes.

The code does not include your 'anti-hosing' protection.

I will plod on  ............

*

Offline reyalp

  • ******
  • 14125
Re: Technical aspects of multi-camera PTP communication.
« Reply #15 on: 25 / January / 2014, 17:47:59 »
Quote
but then you have to manage cached/unchached yourself.
I do not know anything about that.
I'm sure we've discussed it before, I'll leave it to you to dig up the threads, umalloc vs malloc might help find it.

Quote
Quote
There have also been bugs both in the ptpcam and chdk sides that caused some data to be corrupted

Yes, but the camera does not get as far as opening the file to send the data.
But the file name is also sent as a data transfer.

Recording / displaying the file name on the camera might help prove or disprove this. I know you said you verified the name was OK, but I'm not clear if that was on the cam.
Quote
If I repeat the command after getting the error, the camera crashes.
If an expected data phase is not performed, it will generally hang PTP at least.

Out of memory would also be plausible, if you can't allocate 32k for a file handle, it is very likely something else on the camera will try to malloc and fail soon.

A romlog would help distinguish between these.

Which camera(s) are you testing with?
Don't forget what the H stands for.

Re: Technical aspects of multi-camera PTP communication.
« Reply #16 on: 25 / January / 2014, 18:30:11 »
I display on the camera screen the filename received as temp_data,

The cameras are SX220hs.

I do remember the malloc/umalloc discussion, I asked the question :)

I am getting too old to remember the answer.

 

Related Topics


SimplePortal © 2008-2014, SimplePortal