-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Related Issues & PRs
Description
- currently no differentiation between multiple channel types
- channels are dependent on freertos source
Solution
- reduce channel struct to identifier, same/unique list and introduce handler callback
- specialize channel by embedding generic channel into new struct
- handler callback gets pointer to generic channel
- handler can cast generic channel to specialized channel
- enables code separation of basic channel functionalities and actors (like freertos queue handlers)
- enables debugging of specific channel types without modifying the generic channel code.
- enables future updates without breaking channel users
- define enum for handler error codes
- OK if successful (hard success)
- FAILED if operation failed and is not repeatable (hard error)
- i.e. system state is erroneous
- TIMEOUT if timeout constraint was hit, but operation could have succeeded (soft error)
- i.e. freertos queue is blocking and timeout occurred
- TRY_AGAIN if operation expected to be executable, but was blocked (soft error)
- may be solvable by repeating request
- i.e. freertos queue should have been free, but we did wait
- BUFFERED if operation succeeded, but request will be executed later (soft success)
- request was accepted and was put into dedicated queue for later execution
- further requests may result in BLOCKED
- system state is not the one we expected
- i.e. want to send over wifi, but wifi is not connected
- request was accepted and was put into dedicated queue for later execution
- BLOCKED if operation expected to may be buffered, but was not (soft error)
- system state is not the one we expected
- repeating request will not solve this block
- i.e. want to send over wifi, but wifi is not connected and transmit queue is full
Alternative solutions
- introduce enum to differentiate between types
- enum is static
- channel lib needs to be modified for each new type
Context
typedef int (*channel_handler_t) (channel_t *ch, const void *data, const size_t size, const size_t timeout_ms);
typedef struct {
const char *identifier;
struct list_head same;
struct list_head unique;
channel_handler_t handler;
} channel_t;
typedef struct {
const channel_T channel;
lifesensor_queue_T *queue;
} channel_consumer_queue_t;
int channel_consumer_queue_handler( channel_t *ch_base, const void *data, const size_t size, const size_t timeout) {
channel_consumer_queue_t *ch = container_of(ch_base, channel_consumer_queue_t, channel_t);
// do stuff with ch
return errorcode;
}Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request