From philmoz
Here's a weird one for you.
If I use chdkptp to upload files to the camera (in this case the compiled module files), and the module file length is 5592 bytes, and the filename+path is 24 bytes then the PTP upload crashes the PTP code in the camera. The total data size sent is 5592+24+4 = 5620 bytes.
One byte shorter or longer on the filename and it works fine.
The PTP code gets the correct data_size value but gets the wrong value for fn_len (gets 8 instead of 24).
I've tried using umalloc instead of malloc in the PTP code; but the result is the same.
I've tested this on the
G12, SX40 and
G1X all give the same result.
Any ideas?
I've reproduced this on
a540 and
d10. As expected, it also happens with ptpcam.
PTP hangs because the file error (due to incorrect length) is generated before the data phase is complete.
If we consumed all the rest of the data, it would probably work OK [edit: no, looks like it already does that]. If you fully reset the connection, it's usable again (try to connect once, it will fail, then connect again). I believe this is mostly a deficiency in error handling in the client code.
I don't yet understand why the length is incorrect... chdkptp is definitely putting the right value in the buffer to send.
edit:
This isn't specific to file upload
con> !return con:exec('msg_shell:run()',{libs='msg_shell'})
=true
con> putm exec msg_shell.default_cmd=function(msg) write_usb_msg(msg) end
con 1> !con:write_msg('\24\0\0\0'..string.rep('x',5592+24))
... hangs ...
unexpected return code 0x2ff
con 1> !chdk.reset_device({dev="\\\\.\\libusb0-0002--0x04a9-0x311b",bus="bus-0"})
reset_device: dev \\.\libusb0-0002--0x04a9-0x311b bus bus-0
Device status OK
___> c
con> getm
... returns message, intact ??? ...
con> !con:write_msg('\24\0\0\0'..string.rep('x',5592+25))
... no hang ...
con> getm
... returns message...
con> !con:write_msg('\24\0\0\0'..string.rep('x',5592+23))
... ok ..
con> !con:write_msg('\24\0\0\0'..string.rep('x',5592+24))
... hangs ...
😐:
edit:
the 24 isn't needed,
!con:write_msg(string.rep('x',5592+2😎)
also fails