Documentation

Communication Channel

LibOSDP uses a channel to communicate with devices. It is up to the user todefine a channel and pass it to osdp_{cp,pd}_setup(). A channel is defined as:

struct osdp_channel {
    void *data;
    osdp_read_fn_t recv;
    osdp_write_fn_t send;
    osdp_flush_fn_t flush;
};
structosdp_channel

User defined communication channel abstraction for OSDP devices. The methods for read/write/flush are expected to be non-blocking.

Members
void * data
pointer to a block of memory that will be passed to the send/receive/flush method. This is optional (can be set to NULL)
osdp_read_fn_t recv
Pointer to function used to receive osdp packet data
osdp_write_fn_t send
Pointer to function used to send osdp packet data
osdp_flush_fn_t flush
Pointer to function used to flush the channel (optional)
osdp_close_fn_t close
Pointer to function used to close the channel (optional)
typedefosdp_write_fn_t
typedef int(* osdp_write_fn_t) (void *data, uint8_t *buf, int len)

pointer to function that sends byte array into some channel. This function must be non-blocking.

Parameters
datafor use by underlying layers. osdp_channel::data is passed
bufbyte array to be sent
lennumber of bytes in buf
Returns
lenall len bytes queued for transmission
0transient unavailability: channel is momentarily not ready to accept this packet (e.g., half-duplex bus turnaround gap not elapsed, previous TX still draining). LibOSDP will re-invoke this callback on the next refresh with the same finalized buffer; no rebuild, no state advance.
<0 fatal error; the packet is dropped.
typedefosdp_read_fn_t
typedef int(* osdp_read_fn_t) (void *data, uint8_t *buf, int maxlen)

pointer to function that copies received bytes into buffer. This function should be non-blocking.

Parameters
datafor use by underlying layers. osdp_channel::data is passed
bufbyte array copy incoming data
maxlensizeof buf. Can copy utmost maxlen bytes into buf
Returns
+venumber of bytes copied on to buf. Must be <= len
-veon errors
typedefosdp_flush_fn_t
typedef void(* osdp_flush_fn_t) (void *data)

pointer to function that drops all bytes in TX/RX fifo. This function should be non-blocking.

Parameters
datafor use by underlying layers. osdp_channel::data is passed