Commit Graph

12449 Commits

Author SHA1 Message Date
axxel
f4e853a6fc ptp2: building with LIBXML2, olympus-wrap.c does need #include "ptp-pack.c" 2024-09-25 11:47:21 +02:00
axxel
5f2f383926 ptp2: remove unused PTPDeviceProperty::value member
The current value of the device property is only stored in the
desc.CurrentValue field.
2024-09-25 11:47:21 +02:00
axxel
8a2c257ce4 ptp2: remove PTPCanon_Propery::proptype member
The proptype (a.k.a. device property code) is already stored in
dpd.DevicePropertyCode member. This patch introduces the
ptp_find_eos_devicepropdesc() function for the commonly repeated for-loop
looking for the DevicePropDesc* in the cache.

This now allows to completely replace PTPCanon_Property with
PTPDevicePropDesc and then drop the canon_props array altogether and use
the generic one.
2024-09-25 11:47:21 +02:00
axxel
d0c91fd99e ptp2: rename ptp_unpack_... functions for Canon events
Make the names more consistent and expressive.
2024-09-25 11:47:21 +02:00
axxel
f91442f5cc ptp2: remove unused PTPCanon_Property members size and data
PTPDeviceProperty data of EOS cameras is not polled but rather pro-actively
sent by the camera via a PropValueChanged event. The unpack function used
to interpret the data and unpack it into the PTPDevicePropDesc struct
but also copied the raw event data block into an extra member (data, size)
of the special special PTPCanon_Property struct. This data is then never
looked at again.

This patch removes those data members and is a first step to completely
eliminate the special PTPCanon_Property struct.
2024-09-25 11:47:21 +02:00
axxel
4b3cd2452d ptp2: fix -Wsign-compare compiler warning in chdk.c 2024-09-25 11:47:21 +02:00
axxel
2c36303fdf ptp_pack.c: harmonize PTP_EC_CANON_EOS_PropValueChanged indentation
Layout this one case block just like the other ones. This is basically a
whitespace only change.
2024-09-25 11:47:21 +02:00
axxel
19a03c3c9e remove 7 unnecessary #include "ptp-pack.c" statements
Move the byte-order-swapping helpers from ptp-pack.c to ptp.h as well as 2
ptp_free_deviceinfo variants and remove all but one ptp-pack.c inclusions.

This speeds up compile time and removes lots of compiler warning
repetitions if one shows up in ptp-pack.c.
2024-09-25 11:47:21 +02:00
axxel
910f0d9f75 introduce helper macros for automatic offset increment after dtoh
The idea is to remove 'manual' offset adjustments:
```
unsigned offset = 0;
unsigned val = dtoh32o(data, offset);
// offset is now 4
```

Also contains some code beautification near the use of dtoh style macros.
2024-09-24 16:44:26 +02:00
axxel
05920762e4 improve API of ptp_unpack_string and ptp_unpack_uint[16|32]_array
Those functions get passed an offset value into the data buffer. This
offset value needed to be updated on the calling side after the call with
internal knowledge of what exactly the unpack function itself was doing.
Now the offset becomes an in/out parameter and in updated internally. This
substantially reduces the complexity of the calling code.

Furthermore, the return value is now an error indicator and the array
length gets set via a pointer.

This further fixes a few places where there was a bug in the bounds
checking or no bounds checking at all.
2024-09-24 16:44:26 +02:00
axxel
db4320a092 ptp2: trivial code cosmetic, mostly whitespace in switch() blocks 2024-09-23 17:29:35 +02:00
axxel
2b24e3716f fix olcsizes table entry for 5Ds
See discussion in #1020 for details.
2024-09-23 17:29:35 +02:00
axxel
e9a88c7974 summary: fix embarrassing bug in recent commit (broke %x output) 2024-09-23 17:29:35 +02:00
axxel
c5a5644035 summary: fix accidental ')' misplacement in recent commit 2024-09-23 14:23:40 +02:00
axxel
baa817cca9 summary: tune table layout of properties some more
e.g.:

Device Property Summary:
Model ID                  (d049 ro u32): 2147484546
Friendly Device Name      (d402 ro str): 'Canon EOS 5DS'
Perceived Device Type     (d407 ro u32): 1
Session Initiator Info    (d406 rw str): 'Unknown Initiator'
2024-09-23 14:23:40 +02:00
axxel
62f50604ab Canon cameras may also use MTP vendor extension codes (0xd4..)
E.g. the 5Ds:

Friendly Device Name      (d402): (ro str) 'Canon EOS 5DS'
Perceived Device Type     (d407): (ro u32) 1
Session Initiator Info    (d406): (rw str) 'Unknown Initiator'
2024-09-23 14:23:40 +02:00
axxel
f5e51fd63b summary: add info about Canon vendor extension properties
They only show up if the camera is in capturemode=on, see #1024.
2024-09-23 14:23:40 +02:00
axxel
95dc8815fd improve logging output for EOS_AutoPowerOff and EOS_ShutterReleaseCounter 2024-09-23 14:23:40 +02:00
axxel
6177718525 ptp_unpack_CANON_changes: fix bug in bounds checking code 2024-09-23 14:23:40 +02:00
axxel
4d6f9b664d ptp_generic_getdevicepropdesc: remove code duplication 2024-09-23 14:23:40 +02:00
axxel
08dca93f53 summary: layout property summary in a more table based look
Also represent type as human readable string instead of hex code and
drop the 0x prefix in the hex-representation of the property id. Example:

```
Device Property Summary:
[...]
SerialNumber      (d1af): (ro str) '153022001713'
Artist            (d1d0): (rw str) ''
Copyright         (d1d1): (rw str) ''
AEB               (d1d9): (rw u16) Enumeration [0,3,5,8,11,13,16,19, ...
LvAfSystem        (d1ba): (ro u32) Enumeration [10,1,5,6,11,12,13,14]...
MovieParam5       (d20d): (rw ???) Enumeration [] value: Undefined
```
2024-09-23 14:23:40 +02:00
axxel
b3aa6fc607 ptp2: shorten 3 overly long EOS property names (remove "Setting" substr) 2024-09-23 14:23:40 +02:00
Hans Ulrich Niedermann
18b910932b m4: fix output alignment in gettext domain check
Increase the field width from 7 to 8 characters just like
the other AM_V_* messages.

Also use MAKE_TIME_DOMAIN shell var everywhere.
2024-09-20 23:46:54 +02:00
Hans Ulrich Niedermann
c9e2eb5e51 ci: Start using silent rules 2024-09-19 21:25:13 +02:00
Hans Ulrich Niedermann
155c4454ee Enable silent build rules by default
Enable silent build rules by default.

You can still use verbose build rules by using any of the following
methods:

  * run `configure` with the `--disable-silent-rules` argument
  * run `make` with the `V=1` argument

This hides the compiler command line which makes debugging users'
problems more difficult. To compensate for that, this prints the
build flags separately, but a lot less frequently:

For each part of the build (`libgphoto2_port.la`, iolibs,
`libgphoto2.la`, camlibs), if something of that part has been
rebuilt, prints the build flags (_CPPFLAGS, _CFLAGS, _LIBADD,
_LDFLAGS) once.

Always prints the environment variables CPPFLAGS CFLAGS LDADD
LIBADD LDFLAGS once, whether they are the defaults the configure
script sets or given on the `make` command line.

Not all make recipes have been converted to be completely silent,
but the majority (especially the Automake standard recipes) are
now silent.
2024-09-19 21:25:13 +02:00
Hans Ulrich Niedermann
257162bb5c Better explanation for gtk-doc related dummy targets 2024-09-19 21:24:58 +02:00
Hans Ulrich Niedermann
8158d7bfeb AC_MSG_RESULT output requires AC_MSG_CHECKING before 2024-09-19 20:02:47 +02:00
axxel
1759368ea2 reduce textual 'noise' in the EOS event debug log entries
This makes the event entries in the log from an EOS more readable by
removing uninteresting information and layout out interesting information
in a more aligned/table based manner for quick visual parsing of the data.

Example excerpt:
```
event 104: EOS prop d1c9 value changed, size  4 (EOS_ContinousAFMode)
           value of d1c9 is 0x00000000 (u32)
event 105: EOS prop d19f value changed, size  4 (EOS_GPSDeviceActive)
           EOS prop d19f is unknown
           value of d19f is 0x00000001 (u32)
[...]
event 111: EOS prop d177 value changed, size 24 (EOS_SmartphoneShowImageConfig)
    0x000: 18 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x010: 00 00 00 00 00 00 00 00
event 112: EOS prop d105 options changed, type 1, count  0 (EOS_AutoExposureMode)
event 113: EOS prop d108 options changed, type 3, count  3 (EOS_FocusMode)
           option[ 0] of d108 is 0x00
           option[ 1] of d108 is 0x02
           option[ 2] of d108 is 0x01
```
2024-09-19 14:21:14 +02:00
axxel
6df6fbb1d8 ptp2: condense EOS OLCInfo related debug output
A full logging excerpt now looks like this
```
event 237: EOS event OLCInfoChanged (size 81, version 0x0b, mask 0x1fff)
    0x00: 49 00 00 00 ff 1f 00 00 01 00 01 01 a0 10 00 a0
    0x10: 01 01 50 20 2c 01 01 00 00 04 01 01 71 00 00 00
    0x20: 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00
    0x30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x40: 00 00 00 00 00 00 00 00 00
event 237: olcmask 0x0001, 2 bytes: 01 00
event 238: olcmask 0x0002, 6 bytes: 01 01 a0 10 00 a0
event 239: olcmask 0x0004, 5 bytes: 01 01 50 20 2c
event 240: olcmask 0x0008, 4 bytes: 01 01 00 00
event 241: olcmask 0x0010, 4 bytes: 04 01 01 71
event 242: olcmask 0x0020, 6 bytes: 00 00 00 00 00 00
event 243: olcmask 0x0040, 8 bytes: 01 00 00 00 00 00 00 00
event 244: olcmask 0x0080, 4 bytes: 00 00 00 00
event 245: olcmask 0x0100, 6 bytes: 00 00 00 00 00 00
event 246: olcmask 0x0200, 5 bytes: 00 00 00 00 00
event 247: olcmask 0x0400, 5 bytes: 00 00 00 00 00
event 248: olcmask 0x0800, 9 bytes: 00 00 00 00 00 00 00 00 00
event 249: mask 0x1000 entry truncated (1 bytes), olcsizes table (8 bytes) wrong?
event 249: olcmask 0x1000, 1 bytes: 00
```

This allows for easy grepping of the log file. See comments for gained
insight into olcmask 0x0010 entries. The user visible strings info strings
of the UNKNOWN events have changed as well, e.g.:
```
UNKNOWN OLCInfo event 0x0010, 4 bytes: 04 02 06 2f
```
It also introduces a convenient ptp_bytes2str() function to render some
bytes into a string for immediate printing/copying.
2024-09-17 13:06:14 +02:00
axxel
a26126ade8 new camera_keep_device_on() function (less noise in debug log)
Instead of calling ptp_canon_eos_keepdeviceon() in e.g.
camera_wait_for_event() directly for every invocation (often twice),
which can lead to dozens of those calls per second, this patch limits the
number to 1 every 10 seconds.

The camera_prepare_capture + ptp_check_eos_events + keepdeviceon block in
camera_lookup_by_property has been removed completely as this function is
only called from within camera_wait_for_event() where those checks have
been made just prior to the call to camera_lookup_by_property.

Furthermore: ptp_check_eos_events() will now only be called inside
camera_wait_for_event if the queue of already transmitted events is
drained first.
2024-09-16 09:55:14 +02:00
axxel
1a02f0f2b5 fix white-space and indentation inconsistencies (third round)
This is basically an amendment to #1015, I just realized that I overlooked
some places due to a too restrictive regex.

(I hope this subject is not getting old already...)

This is a whitespace only change (if you include newlines as whitespace).
2024-09-16 09:50:52 +02:00
axxel
2e17f8e2ec fix a few random compiler warnings
* unused variables
 * implicit enum conversion
 * sigend <-> unsigned comparison
 * left shift negative number

The only warnings left on my setup right now are `-Wstringop-truncation`
from strncpy calls. Those are not trivial to fix. Turns out the code does
regularly not take into account that strncpy may not result in a null
terminated string. Details, see `man string_copying`.
2024-09-16 09:47:32 +02:00
axxel
aa4197e18c fix compiler warnings about potentially truncated strings from snprintf 2024-09-16 09:47:32 +02:00
axxel
33b4f05d06 fix regression introduced in #1002
At least, I found it myself... :-/

5c9d7b2759 (diff-bce068530fdda102b15492a416c91c8d1dd7681b28c7443ad53b0241dfcb0068)
2024-09-16 09:47:32 +02:00
axxel
d480b5630a more replace sprintf(buf) + strdup(buf) pattern with new aprintf()
Overlooked one file during recent commit.
2024-09-16 09:47:32 +02:00
axxel
f41df32817 fix white-space and indentation inconsistencies (second round)
This is basically a continuation of the work from #1002 but her for the
camlibs directory. The purpose was to replace spaces as a means for
indentation with tab characters.

Note: there are some files which are still offending the general
rule but are (mostly) consistent within themselves. I let them be for
the moment. Fixing them would basically replace the whole file.

Also: there are still a ton of whitespace related inconsistencies like
"x=10" vs "x = 10" or "func(10)" vs "func (10)".

This is a whitespace only change (if you include newlines as whitespace).
2024-09-15 10:53:41 +02:00
Sijawusz Pur Rahnama
e68b3ea37b Update CI to FreeBSD 13.3 2024-09-13 15:40:34 +02:00
axxel
efa7874ee4 add missing "event %d" prefix in debug output of OLC version string 2024-09-13 13:49:36 +02:00
axxel
adbfc5c9f1 make evaluation order consistent in equivalent if-statements
seems to have been overlooked here:
cc08c209a5
2024-09-13 13:49:36 +02:00
axxel
0243f08505 replace sprintf(buf) + strdup(buf) pattern with new aprintf()
less code and no worries about corrupting your stack due to buffer overflow
2024-09-13 13:49:36 +02:00
axxel
9c686713ff make ptp_pack/unpack functions take const data pointers where appropriate
This should help in tracking down memory leaks like in the last commit
more easily.
2024-09-13 13:49:36 +02:00
axxel
006e1347fc fix memory leak in _put_Fuji_FocusPoint 2024-09-13 13:49:36 +02:00
axxel
bfbdc60600 add GNU __attribute__((__format__(printf,...))) to new aprintf function 2024-09-13 13:49:36 +02:00
axxel
578ec6324d fix a couple sprintf/strncpy related issues with buffer size 2024-09-13 13:49:36 +02:00
axxel
87e158c23e introduce helper function aprintf(fmt, ...) (#1010)
This replaces the verbose and error prone pattern of calling
    str = malloc(strlen("some value is 12345678"));
    sprintf(str, "some value is %d", val)
with
    str = aprintf(some value is %d", val);


This is similar to the GNU function asprintf() but returns the pointer
instead of assigning it to the first parameter. It uses the existing
gpi_vsnprintf(fmt, va_list) function.
2024-09-12 13:07:52 +02:00
axxel
b8743d8c3a fix memory leaks related to PTPCanon_changes_entry.u.info (#1009)
* fix memory leaks related to PTPCanon_changes_entry.u.info

Unpacking canon EOS event data uses heap memory stored in `char *info` for
different types of information (mostly PTP_CANON_EOS_CHANGES_TYPE_UNKNOWN
but also PTP_CANON_EOS_CHANGES_TYPE_FOCUS*). This memory needs to be freed
on every call-sight of ptp_get_one_eos_event, which it wasn't and it needs
to do so for every type using it, but if at all, it only freed it for
PTP_CANON_EOS_CHANGES_TYPE_UNKNOWN data.

This patch replaces `char *info` with `char info[84]` and introduces a
macro called PTP_CANON_SET_INFO() for setting that data. 84 is used,
because the union is at least that large anyway because of the `object`
member and 84 is sufficient for all current use cases. The macro makes
sure there is no buffer overflow in the future.

This change does away with the error prone task of freeing the `info`
memory after every ptp_get_one_eos_event() call.

* fix CodeQL complaint about return value check of sscanf

---------

Co-authored-by: axxel <awagger@web.de>
2024-09-11 11:58:18 +02:00
axxel
dac3b5705c Ptp cleanup (#1007)
* improve consistency in standard usecases of ptp_transaction()

 * use CHECK_PTP_RC where applicable
 * don't perform unnecessary checks for data != NULL
 * use stack allocated memory where appropriate (no malloc/free)

* fix a bunch of memory leaks and potential SEGFAULTs in ptp.c

---------

Co-authored-by: axxel <awagger@web.de>
2024-09-10 09:34:13 +02:00
axxel
a9091deb5d add a few missing C_MEM() checks for realloc/strdup (#1006)
Co-authored-by: axxel <awagger@web.de>
2024-09-05 14:56:29 +02:00
axxel
742b4db660 White space cleanup #3 (#1005)
* remove trailing whitespace in *.c/*.h files

This is now 'enforced' via .editoconfig. Do it here once to prevent random
ws changes during editing.

* Cleanup intra-line whitespace in large submenu tables in config.c

Consistently use spaces to layout columns, to make it independent of tab
size.

---------

Co-authored-by: axxel <awagger@web.de>
2024-09-05 14:55:44 +02:00
axxel
1a3c47b5f1 add 3 missing .gitignore entries (#1004)
Co-authored-by: axxel <awagger@web.de>
2024-09-05 11:13:38 +02:00