Skip to content

Commit

Permalink
Implement more CHDK/ML opcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
petabyt committed Nov 13, 2023
1 parent 1392f11 commit 541ab7d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/canon.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Canon and EOS Specific operation implementations
// Basic Canon and EOS operations
// Copyright 2022 by Daniel C (https://github.com/petabyt/camlib)

#include <stdio.h>
Expand Down Expand Up @@ -108,7 +108,7 @@ int ptp_eos_set_prop_value(struct PtpRuntime *r, int code, int value) {

int ptp_eos_set_prop_data(struct PtpRuntime *r, int code, void *data, int dlength) {
// Might be unsafe (EOS buffer overflow bricks?)
exit(1);
//exit(1);
}

int ptp_eos_get_event(struct PtpRuntime *r) {
Expand Down
27 changes: 25 additions & 2 deletions src/ml.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Magic Lantern PTP functionality
// Magic Lantern and CHDK extension functionality
// Copyright 2023 by Daniel C (https://github.com/petabyt/camlib)

#include <stdlib.h>
#include <stdio.h>
Expand Down Expand Up @@ -97,7 +98,6 @@ int ptp_ml_get_bmp_lv(struct PtpRuntime *r, uint32_t **buffer_ptr) {
// TODO: parse ver info from header
//struct PtpMlLvHeader *header = (struct PtpMlLvHeader *)(ptp_get_payload(r));


uint8_t *bmp = (uint8_t *)(ptp_get_payload(r));

int i = 0;
Expand Down Expand Up @@ -146,3 +146,26 @@ int ptp_ml_get_bmp_lv(struct PtpRuntime *r, uint32_t **buffer_ptr) {

return 0;
}

int ptp_chdk_upload_file(struct PtpRuntime *r, char *input, char *dest) {
struct PtpCommand cmd;
cmd.code = PTP_OC_CHDK;
cmd.param_length = 1;
cmd.params[0] = PTP_CHDK_UploadFile;

int size_all = 0;
char *data = ptp_pack_chdk_upload_file(r, input, dest, &size_all);
if (data == NULL) {
return PTP_RUNTIME_ERR;
}

return ptp_generic_send_data(r, &cmd, data, size_all);
}

int ptp_chdk_get_version(struct PtpRuntime *r) {
struct PtpCommand cmd;
cmd.code = PTP_OC_CHDK;
cmd.param_length = 1;
cmd.params[0] = PTP_CHDK_Version;
return ptp_generic_send(r, &cmd);
}

0 comments on commit 541ab7d

Please sign in to comment.