I'm not convinced there's much value chasing usec elsewhere.
Very probably.
Still pretty challenged by C while trying to get a basic understanding of the no data phase
ptp_chdk_get_version()In
https://app.assembla.com/spaces/chdkptp/subversion/source/HEAD/trunk/chdkptp.c#ln1293static int chdk_camera_api_version(lua_State *L) {
CHDK_CONNECTION_METHOD;
CHDK_ENSURE_CONNECTED;
int major,minor;
api_check_ptp_throw(L,ptp_chdk_get_version(params,&major,&minor));
lua_pushnumber(L,major);
lua_pushnumber(L,minor);
return 2;
}
where does the "params" argument of api_check_ptp_throw come from?
In
https://app.assembla.com/spaces/chdkptp/subversion/source/HEAD/trunk/chdkptp.c#ln811/*
get pointers out of user data in given arg
*/
static void get_connection_data(lua_State *L,int narg, PTPParams **params,PTP_CON_STATE **ptp_cs) {
*params = (PTPParams *)luaL_checkudata(L,narg,CHDK_CONNECTION_META);
*ptp_cs = (PTP_CON_STATE *)((*params)->data);
}
Is the following a correct interpretation?
ptp_cs is defined, in the parameter list, as a pointer to a pointer to a PTP_CON_STATE structure
* 'dereferences' ptp_cs to get the pointer to the PTP_CON_STATE structure.
"data" is an element of the PTPParams struct but it is an element that is declared as a pointer (i.e.
https://app.assembla.com/spaces/chdkptp/subversion/source/HEAD/trunk/ptp.h#ln819 void *data;
)
So, this:
((*params)->data)
is a pointer to a pointer to a PTP_CON_STATE struct.
Now, the "*" of:
(PTP_CON_STATE *)
acts to dereference the pointer to the pointer to the PTP_CON_STATE struct with result that:
(PTP_CON_STATE *)((*params)->data);
is a pointer to a PTP_CON_STATE struct
?
FMI:
ptp_chdk_get_version() (returns '1' if success,otherwise '0')
ptp_transaction() (returns 0x2001 if success)
ptp_usb_sendreq() (if fail return I/O error code otherwise code returned by ptp_write_func())
ptp_write_func() (returns PTP_RC_OK or PTP_ERROR_IO code)
usb_bulk_write() (return value returned by _usb_transfer_sync())
_usb_transfer_sync() (returns _usb_setup_async() error number or bytes
transferred)
_usb_setup_async() (returns error number or '0' on success)
From _usb_transfer_sync() , usb_submit_async() repeatedly called until all
bytes sent :-
usb_submit_async() (returns '0' on success or Windows error number
converted to libusb's own error number)
usb_reap_async() (returns bytes transferred or Windows error number
converted to libusb's own error number)
I don't see anything obvious in chdkptp that would depend on whether the size was >= 18*512. The chdkptp code does *not* break writes in to 512 byte chunks. It does send the null packet when the total is a multiples of 512. This logic is unchanged from ptpcam.