WIP: somethings wrong.. #19
@ -38,11 +38,16 @@ class DeviceCommunicationIF: public HasReturnvaluesIF {
|
|||||||
public:
|
public:
|
||||||
static const uint8_t INTERFACE_ID = CLASS_ID::DEVICE_COMMUNICATION_IF;
|
static const uint8_t INTERFACE_ID = CLASS_ID::DEVICE_COMMUNICATION_IF;
|
||||||
|
|
||||||
static const ReturnValue_t INVALID_COOKIE_TYPE = MAKE_RETURN_CODE(0x01);
|
//!< This is used if no read request is to be made by the device handler.
|
||||||
static const ReturnValue_t NOT_ACTIVE = MAKE_RETURN_CODE(0x02);
|
static const ReturnValue_t NO_READ_REQUEST = MAKE_RETURN_CODE(0x01);
|
||||||
static const ReturnValue_t TOO_MUCH_DATA = MAKE_RETURN_CODE(0x03);
|
//! General protocol error. Define more concrete errors in child handler
|
||||||
static const ReturnValue_t NULLPOINTER = MAKE_RETURN_CODE(0x04);
|
static const ReturnValue_t PROTOCOL_ERROR = MAKE_RETURN_CODE(0x02);
|
||||||
static const ReturnValue_t PROTOCOL_ERROR = MAKE_RETURN_CODE(0x05);
|
//! If cookie is a null pointer
|
||||||
|
static const ReturnValue_t NULLPOINTER = MAKE_RETURN_CODE(0x03);
|
||||||
|
static const ReturnValue_t INVALID_COOKIE_TYPE = MAKE_RETURN_CODE(0x04);
|
||||||
|
// is this needed if there is no open/close call?
|
||||||
|
static const ReturnValue_t NOT_ACTIVE = MAKE_RETURN_CODE(0x05);
|
||||||
|
static const ReturnValue_t TOO_MUCH_DATA = MAKE_RETURN_CODE(0x06);
|
||||||
|
|
||||||
virtual ~DeviceCommunicationIF() {}
|
virtual ~DeviceCommunicationIF() {}
|
||||||
|
|
||||||
@ -54,7 +59,8 @@ public:
|
|||||||
* this can be performed in this function, which is called on device handler
|
* this can be performed in this function, which is called on device handler
|
||||||
* initialization.
|
* initialization.
|
||||||
* @param cookie
|
* @param cookie
|
||||||
* @return
|
* @return -@c RETURN_OK if initialization was successfull
|
||||||
|
* - Everything else triggers failure event with returnvalue as parameter 1
|
||||||
*/
|
*/
|
||||||
virtual ReturnValue_t initializeInterface(CookieIF * cookie) = 0;
|
virtual ReturnValue_t initializeInterface(CookieIF * cookie) = 0;
|
||||||
|
|
||||||
@ -66,8 +72,7 @@ public:
|
|||||||
* @param data
|
* @param data
|
||||||
* @param len
|
* @param len
|
||||||
* @return -@c RETURN_OK for successfull send
|
* @return -@c RETURN_OK for successfull send
|
||||||
* - Everything else triggers sending failed event with
|
* - Everything else triggers failure event with returnvalue as parameter 1
|
||||||
* returnvalue as parameter 1
|
|
||||||
*/
|
*/
|
||||||
virtual ReturnValue_t sendMessage(CookieIF *cookie, const uint8_t * sendData,
|
virtual ReturnValue_t sendMessage(CookieIF *cookie, const uint8_t * sendData,
|
||||||
size_t sendLen) = 0;
|
size_t sendLen) = 0;
|
||||||
@ -77,8 +82,7 @@ public:
|
|||||||
* Get send confirmation that the data in sendMessage() was sent successfully.
|
* Get send confirmation that the data in sendMessage() was sent successfully.
|
||||||
* @param cookie
|
* @param cookie
|
||||||
* @return -@c RETURN_OK if data was sent successfull
|
* @return -@c RETURN_OK if data was sent successfull
|
||||||
* - Everything else triggers sending failed event with
|
* - Everything else triggers falure event with returnvalue as parameter 1
|
||||||
* returnvalue as parameter 1
|
|
||||||
*/
|
*/
|
||||||
virtual ReturnValue_t getSendSuccess(CookieIF *cookie) = 0;
|
virtual ReturnValue_t getSendSuccess(CookieIF *cookie) = 0;
|
||||||
|
|
||||||
@ -86,7 +90,10 @@ public:
|
|||||||
* Called by DHB in the SEND_WRITE doSendRead().
|
* Called by DHB in the SEND_WRITE doSendRead().
|
||||||
* Request a reply.
|
* Request a reply.
|
||||||
* @param cookie
|
* @param cookie
|
||||||
* @return
|
* @return -@c RETURN_OK to confirm the request for data has been sent.
|
||||||
|
* -@c NO_READ_REQUEST if no request shall be made. readReceivedMessage()
|
||||||
|
* will not be called in the respective communication cycle.
|
||||||
|
* - Everything else triggers failure event with returnvalue as parameter 1
|
||||||
*/
|
*/
|
||||||
virtual ReturnValue_t requestReceiveMessage(CookieIF *cookie, size_t requestLen) = 0;
|
virtual ReturnValue_t requestReceiveMessage(CookieIF *cookie, size_t requestLen) = 0;
|
||||||
|
|
||||||
@ -98,8 +105,7 @@ public:
|
|||||||
* @param data
|
* @param data
|
||||||
* @param len
|
* @param len
|
||||||
* @return @c RETURN_OK for successfull receive
|
* @return @c RETURN_OK for successfull receive
|
||||||
* - Everything else triggers receiving failed with
|
* - Everything else triggers failure event with returnvalue as parameter 1
|
||||||
* returnvalue as parameter 1
|
|
||||||
*/
|
*/
|
||||||
virtual ReturnValue_t readReceivedMessage(CookieIF *cookie, uint8_t **buffer,
|
virtual ReturnValue_t readReceivedMessage(CookieIF *cookie, uint8_t **buffer,
|
||||||
size_t *size) = 0;
|
size_t *size) = 0;
|
||||||
|
@ -554,7 +554,7 @@ void DeviceHandlerBase::doSendRead() {
|
|||||||
if (result == RETURN_OK) {
|
if (result == RETURN_OK) {
|
||||||
cookieInfo.state = COOKIE_READ_SENT;
|
cookieInfo.state = COOKIE_READ_SENT;
|
||||||
}
|
}
|
||||||
else if(result == NO_READ_REQUEST) {
|
else if(result == DeviceCommunicationIF::NO_READ_REQUEST) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -777,8 +777,8 @@ void DeviceHandlerBase::buildRawDeviceCommand(CommandMessage* commandMessage) {
|
|||||||
replyReturnvalueToCommand(result, RAW_COMMAND_ID);
|
replyReturnvalueToCommand(result, RAW_COMMAND_ID);
|
||||||
storedRawData.raw = StorageManagerIF::INVALID_ADDRESS;
|
storedRawData.raw = StorageManagerIF::INVALID_ADDRESS;
|
||||||
} else {
|
} else {
|
||||||
cookieInfo.pendingCommand = deviceCommandMap.find(
|
cookieInfo.pendingCommand = deviceCommandMap.
|
||||||
(DeviceCommandId_t) RAW_COMMAND_ID);
|
find((DeviceCommandId_t) RAW_COMMAND_ID);
|
||||||
cookieInfo.pendingCommand->second.isExecuting = true;
|
cookieInfo.pendingCommand->second.isExecuting = true;
|
||||||
cookieInfo.state = COOKIE_WRITE_READY;
|
cookieInfo.state = COOKIE_WRITE_READY;
|
||||||
}
|
}
|
||||||
|
@ -90,8 +90,6 @@ public:
|
|||||||
// Standard codes used in buildCommandFromCommand
|
// Standard codes used in buildCommandFromCommand
|
||||||
static const ReturnValue_t INVALID_COMMAND_PARAMETER = MAKE_RETURN_CODE(0xD0);
|
static const ReturnValue_t INVALID_COMMAND_PARAMETER = MAKE_RETURN_CODE(0xD0);
|
||||||
static const ReturnValue_t INVALID_NUMBER_OR_LENGTH_OF_PARAMETERS = MAKE_RETURN_CODE(0xD1);
|
static const ReturnValue_t INVALID_NUMBER_OR_LENGTH_OF_PARAMETERS = MAKE_RETURN_CODE(0xD1);
|
||||||
// Standard codes used in buildNomalDeviceCommand
|
|
||||||
static const ReturnValue_t NO_READ_REQUEST = MAKE_RETURN_CODE(0xD2);
|
|
||||||
|
|
||||||
// Standard codes used in getSwitches
|
// Standard codes used in getSwitches
|
||||||
static const ReturnValue_t NO_SWITCH = MAKE_RETURN_CODE(0xE1); //!< Return in getSwitches() to specify there are no switches
|
static const ReturnValue_t NO_SWITCH = MAKE_RETURN_CODE(0xE1); //!< Return in getSwitches() to specify there are no switches
|
||||||
|
@ -11,8 +11,8 @@
|
|||||||
#include "task.h"
|
#include "task.h"
|
||||||
|
|
||||||
BinarySemaphore::BinarySemaphore() {
|
BinarySemaphore::BinarySemaphore() {
|
||||||
xSemaphoreCreateBinary(handle); // @suppress("Function cannot be resolved")
|
xSemaphoreCreateBinary(handle);
|
||||||
if(handle == NULL) {
|
if(handle == nullptr) {
|
||||||
error << "Binary semaphore creation failure" << std::endl;
|
error << "Binary semaphore creation failure" << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -22,7 +22,7 @@ BinarySemaphore::~BinarySemaphore() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t BinarySemaphore::takeBinarySemaphore(uint32_t timeoutMs) {
|
ReturnValue_t BinarySemaphore::takeBinarySemaphore(uint32_t timeoutMs) {
|
||||||
if(handle == NULL) {
|
if(handle == nullptr) {
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
TickType_t timeout = portMAX_DELAY;
|
TickType_t timeout = portMAX_DELAY;
|
||||||
@ -39,7 +39,7 @@ ReturnValue_t BinarySemaphore::takeBinarySemaphore(uint32_t timeoutMs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t BinarySemaphore::takeBinarySemaphoreTickTimeout(TickType_t timeoutTicks) {
|
ReturnValue_t BinarySemaphore::takeBinarySemaphoreTickTimeout(TickType_t timeoutTicks) {
|
||||||
if(handle == NULL) {
|
if(handle == nullptr) {
|
||||||
return SEMAPHORE_NOT_FOUND;
|
return SEMAPHORE_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ ReturnValue_t BinarySemaphore::takeBinarySemaphoreTickTimeout(TickType_t timeout
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t BinarySemaphore::giveBinarySemaphore() {
|
ReturnValue_t BinarySemaphore::giveBinarySemaphore() {
|
||||||
if (handle == NULL) {
|
if (handle == nullptr) {
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
BaseType_t returncode = xSemaphoreGive(handle);
|
BaseType_t returncode = xSemaphoreGive(handle);
|
||||||
@ -68,7 +68,7 @@ SemaphoreHandle_t BinarySemaphore::getSemaphore() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t BinarySemaphore::giveBinarySemaphore(SemaphoreHandle_t semaphore) {
|
ReturnValue_t BinarySemaphore::giveBinarySemaphore(SemaphoreHandle_t semaphore) {
|
||||||
if (semaphore == NULL) {
|
if (semaphore == nullptr) {
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
BaseType_t returncode = xSemaphoreGive(semaphore);
|
BaseType_t returncode = xSemaphoreGive(semaphore);
|
||||||
@ -80,13 +80,15 @@ ReturnValue_t BinarySemaphore::giveBinarySemaphore(SemaphoreHandle_t semaphore)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BinarySemaphore::resetSemaphore() {
|
void BinarySemaphore::resetSemaphore() {
|
||||||
vSemaphoreDelete(handle);
|
if(handle != nullptr) {
|
||||||
xSemaphoreCreateBinary(handle);
|
vSemaphoreDelete(handle);
|
||||||
|
xSemaphoreCreateBinary(handle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t BinarySemaphore::giveBinarySemaphoreFromISR(SemaphoreHandle_t semaphore,
|
ReturnValue_t BinarySemaphore::giveBinarySemaphoreFromISR(SemaphoreHandle_t semaphore,
|
||||||
BaseType_t * higherPriorityTaskWoken) {
|
BaseType_t * higherPriorityTaskWoken) {
|
||||||
if (semaphore == NULL) {
|
if (semaphore == nullptr) {
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
BaseType_t returncode = xSemaphoreGiveFromISR(semaphore, higherPriorityTaskWoken);
|
BaseType_t returncode = xSemaphoreGiveFromISR(semaphore, higherPriorityTaskWoken);
|
||||||
|
Loading…
Reference in New Issue
Block a user