Bug in PTP File Upload ? - page 2 - General Discussion and Assistance - CHDK Forum supplierdeeply

Bug in PTP File Upload ?

  • 21 Replies
  • 8301 Views
Re: Bug in PTP File Upload ?
« Reply #10 on: 06 / August / 2011, 16:44:06 »
Advertisements
Can you remember the cause and solution ?

Even though I cannot read German, was it discussed in the forum ?

During the development of ptpCamGui we also had some problems with the upload of script files. Some uploaded test files had  extra characters like described (tested with the A720).

At the moment works all fine.

I guess not because I was using the latest builds from CHDKDE.

*

Offline msl

  • *****
  • 1280
  • A720 IS, SX220 HS 1.01a
    • CHDK-DE links
Re: Bug in PTP File Upload ?
« Reply #11 on: 06 / August / 2011, 17:03:09 »
Can you remember the cause and solution ?
Even though I cannot read German, was it discussed in the forum ?

There was no discussion in the forum. We changed the script files up they worked. But this was not realy a solution. We found no cause.

msl
CHDK-DE:  CHDK-DE links

*

Offline reyalp

  • ******
  • 14117
Re: Bug in PTP File Upload ?
« Reply #12 on: 06 / August / 2011, 17:08:09 »
FWIW my chdkptp client currently uploads > 1kb on every lua command, and often much more. If this were getting corrupted, it definitely wouldn't work. I also routinely upload diskboot.bin without any problems.

a540 + d10.
Don't forget what the H stands for.

Re: Bug in PTP File Upload ?
« Reply #13 on: 06 / August / 2011, 18:14:47 »
I also routinely upload diskboot.bin without any problems.


Yes, the same on my A620.

For an easy life I will just work with the A620 for now.

The A460 problem probably cannot be solved.


*

Offline reyalp

  • ******
  • 14117
Re: Bug in PTP File Upload ?
« Reply #14 on: 26 / November / 2011, 23:38:27 »
Now I seem to be getting this on my a540, my yieldtst.lua will reliably get corrupted.

Doesn't happen diskboot.bin or yieldtst.bas.

Doesn't happen on d10.

Corruption does depend on upload path. This makes me think it's a bug in the file transfer code.

Same corruption happens with a file exactly the same length (509 bytes), with different content (508 'x' followed by a LF.)

Also happens with a 512 byte file, but not a 508 byte file or a 1024 byte file.

Whiskey Tango Foxtrot.

edit:
SC6.BAS seems OK.
Tried different USB ports, with/without hub.

edit:
Exactly the same data sent and returned via ptp message does NOT get corrupted, further indicating it is something unique to the file code.
« Last Edit: 27 / November / 2011, 01:11:25 by reyalp »
Don't forget what the H stands for.

*

Offline reyalp

  • ******
  • 14117
Re: Bug in PTP File Upload ?
« Reply #15 on: 27 / November / 2011, 22:28:14 »
OK, I think I have something.

The bug seems to happen when the filename is not a multiple of 4 bytes.  Upload makes multiple calls to recv_ptp_data, to get the filename length, the filename, and then the data (possibly in multiple calls if it is bigger than the buffer)

It appears that if one call to recv_ptp_data doesn't end on a 4 byte boundary, the next call is (sometimes ?) messed up somehow. What exactly happens isn't entirely clear, but padding the filename with \0s until it is 4 byte aligned appears to resolve the problem. This can be done entirely on the client, since the file calls on the camera end will just ignore the nulls.

An alternate approach would be to read the filename + data up to buf_size data all at, and then parse out the filename etc.

For a complete solution (assuming above is correct) we should also ensure that buffer_size is always divisible by 4, since various do multiple reads in buf_size chunks.

I haven't noticed any problems if the final call to recv_ptp_data reads a non-divisble by 4 size.

edit:
attached a patch against the ptpcam in chdkde which implements these changes. I have actually only tested using chdkptp, but the upload code is identical.

edit:
also included in chdkptp changeset 71 http://trac.assembla.com/chdkptp/changeset/71
« Last Edit: 28 / November / 2011, 00:06:10 by reyalp »
Don't forget what the H stands for.

Re: Bug in PTP File Upload ?
« Reply #16 on: 28 / November / 2011, 06:47:16 »

The bug seems to happen when the filename is not a multiple of 4 bytes. 
Good find.

I wil try it on the A460 again once I have access to that camera.

*

Offline reyalp

  • ******
  • 14117
Re: Bug in PTP File Upload ?
« Reply #17 on: 03 / December / 2011, 20:44:28 »
An alternate approach would be to read the filename + data up to buf_size data all at [once], and then parse out the filename etc.

For a complete solution (assuming above is correct) we should also ensure that buffer_size is always divisible by 4, since various do multiple reads in buf_size chunks.
I've implemented both of these in changests 1450 and 1451. The client side workaround is not needed with these changes.
Don't forget what the H stands for.


*

Offline dvip

  • ****
  • 451
Re: Bug in PTP File Upload ?
« Reply #18 on: 03 / December / 2011, 23:51:48 »
I gave PTP a try for the first time today.
It is nice and I got things working fine with my A590IS.

The only bug I got was this:

------

Line 3570 (File "C:\chdk\ptpCamGui2.0.113\ptpCamGui.exe"):

Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.

------


I am not sure what I was using when I got that.

Other than that... PTP is very nice. Great project!


*

Offline msl

  • *****
  • 1280
  • A720 IS, SX220 HS 1.01a
    • CHDK-DE links
Re: Bug in PTP File Upload ?
« Reply #19 on: 04 / December / 2011, 04:31:05 »
The only bug I got was this:

------

Line 3570 (File "C:\chdk\ptpCamGui2.0.113\ptpCamGui.exe"):

Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.

I've tested the current version with the latest changesets and all works fine. When you get this error message - at program start or with a special function?

Btw - ptpCamGui has only 3325 source code lines. Perhaps the file is broken.

msl
CHDK-DE:  CHDK-DE links

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal