diff --git a/src/backend.c b/src/backend.c index 528ebb0..028c9a6 100644 --- a/src/backend.c +++ b/src/backend.c @@ -1,5 +1,5 @@ -// Common IO backend code - only applies to platforms that have generic -// USB packet IO access (Not Windows) +// Packet stream read/write logic - uses bare I/O operations +// Windows doesn't have that, so it can't be used here. // Copyright 2022 by Daniel C (https://github.com/petabyt/camlib) diff --git a/src/canon.c b/src/canon.c index c9d57c6..d65df4d 100644 --- a/src/canon.c +++ b/src/canon.c @@ -69,8 +69,6 @@ int ptp_eos_get_viewfinder_data(struct PtpRuntime *r) { cmd.param_length = 1; cmd.params[0] = 0x200000; - cmd.params[1] = 0x0; - cmd.params[2] = 0x0; return ptp_generic_send(r, &cmd); } diff --git a/src/ip.c b/src/ip.c index d5cdcd9..722e8b0 100644 --- a/src/ip.c +++ b/src/ip.c @@ -1,4 +1,4 @@ -// PTP/IP implementation - +// POSIX PTP/IP implementation // Copyright 2023 by Daniel C (https://github.com/petabyt/camlib) #include diff --git a/src/libwpd.c b/src/libwpd.c index 5b10eb3..ab7ffdb 100644 --- a/src/libwpd.c +++ b/src/libwpd.c @@ -1,3 +1,5 @@ +// Windows USB I/O frontend for libwpd (https://github.com/petabyt/libwpd) +// Copyright 2022 by Daniel C (https://github.com/petabyt/camlib) #include #include #include @@ -9,9 +11,16 @@ struct WpdStruct backend_wpd; -int ptp_device_init(struct PtpRuntime *r) { +int ptp_comm_init(struct PtpRuntime *r) { ptp_generic_reset(r); wpd_init(1, L"Camlib WPD"); + + return 0; +} + +int ptp_device_init(struct PtpRuntime *r) { + ptp_comm_init(); + int length = 0; wchar_t **devices = wpd_get_devices(&backend_wpd, &length); @@ -37,6 +46,14 @@ int ptp_device_init(struct PtpRuntime *r) { return PTP_NO_DEVICE; } +struct PtpDeviceEntry *ptpusb_device_list(struct PtpRuntime *r) { + return NULL; +} + +int ptp_device_open(struct PtpRuntime *r, struct PtpDeviceEntry *entry) { + return PTP_IO_ERR; +} + int ptp_send_bulk_packets(struct PtpRuntime *r, int length) { struct PtpCommand cmd; struct PtpBulkContainer *bulk = (struct PtpBulkContainer*)(r->data); @@ -121,7 +138,7 @@ int ptp_receive_bulk_packets(struct PtpRuntime *r) { return 0; } -int ptp_receive_int(void *to, int length) { +int ptp_read_int(void *to, int length) { return 0; } diff --git a/src/no_ip.c b/src/no_ip.c new file mode 100644 index 0000000..45c5f74 --- /dev/null +++ b/src/no_ip.c @@ -0,0 +1,36 @@ +// Include this if you wish to never use TCP/IP +// Copyright 2022 by Daniel C (https://github.com/petabyt/camlib) +#include +#include + +int ptpip_new_timeout_socket(char *addr, int port) { + return -1; +} + +int ptpip_connect(struct PtpRuntime *r, char *addr, int port) { + return -1; +} + +int ptpip_connect_events(struct PtpRuntime *r, char *addr, int port) { + return -1; +} + +int ptpip_close(struct PtpRuntime *r) { + return -1; +} + +int ptpip_cmd_write(struct PtpRuntime *r, void *data, int size) { + return -1; +} + +int ptpip_cmd_read(struct PtpRuntime *r, void *data, int size) { + return -1; +} + +int ptpip_event_send(struct PtpRuntime *r, void *data, int size) { + return -1; +} + +int ptpip_event_read(struct PtpRuntime *r, void *data, int size) { + return -1; +} diff --git a/src/pack.c b/src/pack.c new file mode 100644 index 0000000..b6619b6 --- /dev/null +++ b/src/pack.c @@ -0,0 +1,9 @@ +#include + +int ptp_pack_fuji_object_info(struct PtpRuntime *r, struct PtpObjectInfo *oi, void *buffer, int max) { + void **ptr = (void **)(&buffer); + + memcpy(*ptr, oi, PTP_FUJI_OBJ_INFO_VAR_START); + (*ptr) += PTP_FUJI_OBJ_INFO_VAR_START; + +} diff --git a/src/ptp.h b/src/ptp.h index 7f63216..6a2473a 100644 --- a/src/ptp.h +++ b/src/ptp.h @@ -660,6 +660,8 @@ struct PtpIpEndDataPacket { // See https://en.wikipedia.org/wiki/USB#Device_classes #define PTP_CLASS_ID 6 +#define USB_VENDOR_CANON 0x4A9 + // ISO number for PTP/IP, seems to be standard (?) #define PTP_IP_PORT 15740 diff --git a/src/util.c b/src/util.c index 1cf8c00..cf1b2bf 100644 --- a/src/util.c +++ b/src/util.c @@ -128,7 +128,7 @@ int ptp_generic_send_data(struct PtpRuntime *r, struct PtpCommand *cmd, void *da } else { // Single data packet plength = ptp_new_data_packet(r, cmd, data, length); - if (ptp_send_bulk_packets(r, plength) != plength) { + if (ptp_send_bulk_packets(r, plength) != plength + length) { ptp_mutex_unlock(r); return PTP_IO_ERR; } @@ -157,8 +157,7 @@ struct UintArray *ptp_dup_uint_array(struct UintArray *arr) { return arr2; } -// May be slightly inneficient for every frame/action -// TODO: maybe 'cache' dev type for speed +// TODO: maybe 'cache' dev type int ptp_device_type(struct PtpRuntime *r) { struct PtpDeviceInfo *di = r->di; if (di == NULL) return PTP_DEV_EMPTY;