Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python Bindings: CP add CMD_STATUS support #116

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions python/pyosdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ void pyosdp_add_module_constants(PyObject *module)
ADD_CONST("CMD_KEYSET", OSDP_CMD_KEYSET);
ADD_CONST("CMD_MFG", OSDP_CMD_MFG);
ADD_CONST("CMD_FILE_TX", OSDP_CMD_FILE_TX);
ADD_CONST("CMD_STATUS", OSDP_CMD_STATUS);

/* For `struct osdp_cmd_file_tx`::flags */
ADD_CONST("CMD_FILE_TX_FLAG_CANCEL", OSDP_CMD_FILE_TX_FLAG_CANCEL);
Expand Down
8 changes: 6 additions & 2 deletions python/pyosdp_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,11 @@ static int pyosdp_make_struct_cmd_file_tx(struct osdp_cmd *p, PyObject *dict)
}

/* Dummies for commands that don't have any body */
static int pyosdp_make_struct_cmd_dummy(struct osdp_cmd *cmd, PyObject *obj) { return 0; }
static int pyosdp_make_struct_cmd_dummy(struct osdp_cmd *cmd, PyObject *obj) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to be the only usage of this function. Should we rename the function and update the comment since it has a body now?

Copy link
Member

@sidcha sidcha Jun 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the issue is because we are setting cmd->id in the wrong place. The caller pyosdp_make_struct_cmd should set it so the dummy can stay as it is now.

cmd->id = OSDP_CMD_STATUS;

return 0;
}
static int pyosdp_make_dict_cmd_dummy(PyObject *obj, struct osdp_cmd *cmd) { return 0; }


Expand Down Expand Up @@ -695,4 +699,4 @@ int pyosdp_make_dict_event(PyObject **dict, struct osdp_event *event)

*dict = obj;
return 0;
}
}