CHDKPTP: for some - a sophisticated work

  • 12 Replies
  • 3833 Views
Re: CHDKPTP: for some - a sophisticated work
« Reply #10 on: 13 / February / 2019, 09:37:40 »
Advertisements
In a first attempt to work, end-to-end, through a ptp command it's a little tricky for me "C" wise (especially having just briefly glimpsed the ioctl stuff wondering how that interacts with the usb host controller).

A couple of wonders at the very start:

1.
I can't see where/how (741) ptp.c (https://app.assembla.com/spaces/chdkptp/subversion/source/HEAD/trunk/ptp.c) is aware of (741) https://app.assembla.com/spaces/chdkptp/subversion/source/HEAD/trunk/chdk_headers/core/ptp.h ?

2.
We declare (741) https://app.assembla.com/spaces/chdkptp/subversion/source/HEAD/trunk/chdk_headers/core/ptp.h#ln32
Code: [Select]
enum ptp_chdk_command {
PTP_CHDK_Version = 0,     // return param1 is major version number
                                       // return param2 is minor version number
.
.
};
Having looked at a MS C Enumeration Declarations article, my imagination was that the related assignment would include the enum keyword, something like:

Code: [Select]
enum ptp_chdk_command ptp.Param1;
ptp.Param1 = PTP_CHDK_Version;

Instead we have (741) https://app.assembla.com/spaces/chdkptp/subversion/source/HEAD/trunk/ptp.c#ln2268:
Code: [Select]
ptp.Param1=PTP_CHDK_Version;
Is there an easy way to understand how that works without use of the enum keyword?
 
(struct member Param1 is originally defined here (741) https://app.assembla.com/spaces/chdkptp/subversion/source/HEAD/trunk/ptp.h#ln42 as unit32_t)
« Last Edit: 13 / February / 2019, 13:19:33 by andrew.stephens.754365 »

*

Offline reyalp

  • ******
  • 11706
Re: CHDKPTP: for some - a sophisticated work
« Reply #11 on: 14 / February / 2019, 00:14:47 »
In a first attempt to work, end-to-end, through a ptp command it's a little tricky for me "C" wise (especially having just briefly glimpsed the ioctl stuff wondering how that interacts with the usb host controller).

A couple of wonders at the very start:

1.
I can't see where/how (741) ptp.c (https://app.assembla.com/spaces/chdkptp/subversion/source/HEAD/trunk/ptp.c) is aware of (741) https://app.assembla.com/spaces/chdkptp/subversion/source/HEAD/trunk/chdk_headers/core/ptp.h ?
chdkptp/ptp.h includes core/ptp.h, and chdk_headers is added to the include path by default. The reason it's set up this way is that for protocol development, it's convenient to use *one* ptp.h for both CHDK and chdkptp, which can be accomplished by putting the CHDK source root on the include path instead. Putting it under core/ distinguishes it from the unrelated chdkptp/ptp.h

Quote
Is there an easy way to understand how that works without use of the enum keyword?
 
In C, enums are some kind of integer under the hood, and can be assigned to integers or passed to functions that expect integers without complaint.
Don't forget what the H stands for.

Re: CHDKPTP: for some - a sophisticated work
« Reply #12 on: 14 / February / 2019, 04:24:58 »
Thanks. I suspect there will be more of those as this thread develops but will not write them all down in order to improve readability.

 

Related Topics