Skip to content

Issue with PD commands response #262

@DanielSSolid360

Description

@DanielSSolid360

Hello,
some time ago you helped me with the implementation of the library on an STM32. I’ve been running it for a while as a CP to receive card data and keypresses from commercial OSDP readers. Now I’m implementing my own device that will act as a PD, but I’ve found something that doesn’t seem to be working as it should.

When the CP sends a command to the PD using a capability that the PD does not support, the PD’s response is not what would be expected. For example, if a PD only has the capability to control the buzzer and it receives an LED control command, this is what happens:

CP LOG:
[DEBUG] ../Drivers/LibOSDP/src/osdp_cp.c:673: CMD: LED(69) REPLY: ACK(40)

PD LOG:
OSDP: PD-0: [] [ERROR] ../Drivers/LibOSDP/src/osdp_pd.c:272: PD is not capable of handling CMD(69);
OSDP: PD-0: [] [DEBUG] ../Drivers/LibOSDP/src/osdp_pd.c:689: CMD: LED(69) REPLY: ACK(40)

After sending the command to the PD as the CP, we set a breakpoint in the cp_event_handler() function waiting for an event of type OSDP_EVENT_NOTIFICATION_COMMAND. Whether we enable the capability on the PD or not, the event’s argument 1 is exactly the same:
ev->notif.type = 0x00 (OSDP_EVENT_NOTIFICATION_COMMAND)
ev->notif.arg0 = 0x00000002
ev->notif.arg1 = 0x00000001

I also tested with the BEEP output capability and the same thing happens: in both cases, whether the capability is enabled or not in the PD, the notification event structure remains identical, only arg0 changes, which identifies the command ID:
ev->notif.type = 0x00 (OSDP_EVENT_NOTIFICATION_COMMAND)
ev->notif.arg0 = 0x00000003
ev->notif.arg1 = 0x00000001

On the PD side, I tried to send a command failure response inside pd_command_handler() using the osdp_pd_submit_event() function, but when a command involving an unsupported capability is sent, the handler is never called.
I also tried going a step further and adding the following lines of code at the end of the pd_cmd_cap_ok() function in osdp_pd.c:
...
LOG_ERR("PD is not capable of handling CMD(%02x); ", pd->cmd_id);
struct osdp_event invalidcmd;
invalidcmd.type = OSDP_EVENT_NOTIFICATION;
invalidcmd.notif.type = OSDP_EVENT_NOTIFICATION_COMMAND;
invalidcmd.notif.arg0 = pd->cmd_id;
invalidcmd.notif.arg1 = -1;
osdp_pd_submit_event(ctx_struct,&invalidcmd);

And the result was the following:

OSDP: PD-0: [] [ERROR] ../Drivers/LibOSDP/src/osdp_pd.c:188: Unknown event type 5

This is because the pd_translate_event() function does not consider the possibility of the event type OSDP_EVENT_NOTIFICATION_COMMAND.

Maybe another function among the many available could handle this situation, or perhaps there is a problem in my implementation.
Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions