diff --git a/src/camlib.h b/src/camlib.h index 70cab9d..e33fc27 100644 --- a/src/camlib.h +++ b/src/camlib.h @@ -106,6 +106,7 @@ struct PtpRuntime { // Set to 1 to kill all IO operations. By default, this is 1. When a valid connection // is achieved by libusb, libwpd, and tcp backends, it will be set to 0. On IO error, it // will be set to 1. + // TODO: Should the IO backend toggle the IO kill switch uint8_t io_kill_switch; // Is set to USB by default diff --git a/src/canon_adv.c b/src/canon_adv.c index a775252..427ad78 100644 --- a/src/canon_adv.c +++ b/src/canon_adv.c @@ -287,7 +287,7 @@ int ptp_eos_evproc_run(struct PtpRuntime *r, char *fmt, ...) { return PTP_RUNTIME_ERR; } - rc = ptp_eos_exec_evproc(r, data, length, 1); + rc = ptp_eos_exec_evproc(r, data, length, 0); if (rc) { return rc; } diff --git a/src/lib.c b/src/lib.c index 0aafbdf..aadd6db 100644 --- a/src/lib.c +++ b/src/lib.c @@ -8,14 +8,13 @@ #include #include -// Reset all fields of PtpRuntime - this must be updated when new fields are added +// Reset all fields of PtpRuntime - use this before reconnecting void ptp_generic_reset(struct PtpRuntime *r) { r->io_kill_switch = 1; r->transaction = 0; r->session = 0; r->connection_type = PTP_USB; r->caller_unlocks_mutex = 0; - r->mutex = NULL; r->wait_for_response = 1; } diff --git a/src/libusb.c b/src/libusb.c index b5c952c..4f1ef32 100644 --- a/src/libusb.c +++ b/src/libusb.c @@ -21,6 +21,7 @@ struct LibUSBBackend { libusb_device_handle *handle; }; +// TODO: If this is accidentally called in the middle of a connection, it will cause a huge fault int ptp_comm_init(struct PtpRuntime *r) { ptp_generic_reset(r); @@ -268,7 +269,10 @@ int ptp_device_reset(struct PtpRuntime *r) { int ptp_cmd_write(struct PtpRuntime *r, void *to, int length) { struct LibUSBBackend *backend = (struct LibUSBBackend *)r->comm_backend; - if (backend == NULL || r->io_kill_switch) return -1; + if (backend == NULL || r->io_kill_switch) { + puts("KIll switch"); + return -1; + } int transferred; int rc = libusb_bulk_transfer( backend->handle, diff --git a/src/libwpd.c b/src/libwpd.c index ef32700..7857166 100644 --- a/src/libwpd.c +++ b/src/libwpd.c @@ -16,7 +16,7 @@ int ptp_comm_init(struct PtpRuntime *r) { r->comm_backend = malloc(sizeof(struct WpdStruct)); // We are not using low-level I/O operations, so this is never used - r->r->max_packet_size = 512; + r->max_packet_size = 512; return 0; } diff --git a/src/transport.c b/src/transport.c index 4046a41..a59a4be 100644 --- a/src/transport.c +++ b/src/transport.c @@ -173,7 +173,7 @@ int ptpusb_read_all_packets(struct PtpRuntime *r) { r->wait_for_response = 1; if (rc < 0) { - ptp_verbose_log("Failed to read packets: %d\n"); + ptp_verbose_log("Failed to read packets: %d\n", rc); return PTP_IO_ERR; }