new dvice com IF return value

This commit is contained in:
Robin Müller 2020-04-05 00:23:29 +02:00
parent bd468a1b74
commit 80b1d28bc8
2 changed files with 22 additions and 16 deletions

View File

@ -29,8 +29,8 @@
* *
* To identify different connection over a single interface can return * To identify different connection over a single interface can return
* so-called cookies to components. * so-called cookies to components.
* The CommunicationMessage message type can be used to extend the functionality of the * The CommunicationMessage message type can be used to extend the
* ComIF if a separate polling task is required. * functionality of the ComIF if a separate polling task is required.
* @ingroup interfaces * @ingroup interfaces
* @ingroup comm * @ingroup comm
*/ */
@ -38,8 +38,9 @@ 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;
//!< This is used if no read request is to be made by the device handler. //! This is returned in readReceivedMessage() if no reply was reived.
static const ReturnValue_t NO_READ_REQUEST = MAKE_RETURN_CODE(0x01); static const ReturnValue_t NO_REPLY_RECEIVED = MAKE_RETURN_CODE(0x01);
//! General protocol error. Define more concrete errors in child handler //! General protocol error. Define more concrete errors in child handler
static const ReturnValue_t PROTOCOL_ERROR = MAKE_RETURN_CODE(0x02); static const ReturnValue_t PROTOCOL_ERROR = MAKE_RETURN_CODE(0x02);
//! If cookie is a null pointer //! If cookie is a null pointer
@ -60,7 +61,8 @@ public:
* initialization. * initialization.
* @param cookie * @param cookie
* @return -@c RETURN_OK if initialization was successfull * @return -@c RETURN_OK if initialization was successfull
* - Everything else triggers failure event with returnvalue as parameter 1 * - Everything else triggers failure event with
* returnvalue as parameter 1
*/ */
virtual ReturnValue_t initializeInterface(CookieIF * cookie) = 0; virtual ReturnValue_t initializeInterface(CookieIF * cookie) = 0;
@ -72,7 +74,8 @@ 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 failure event with returnvalue as parameter 1 * - Everything else triggers failure event with
* 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;
@ -82,7 +85,8 @@ 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 falure event with returnvalue as parameter 1 * - Everything else triggers falure event with
* returnvalue as parameter 1
*/ */
virtual ReturnValue_t getSendSuccess(CookieIF *cookie) = 0; virtual ReturnValue_t getSendSuccess(CookieIF *cookie) = 0;
@ -96,7 +100,8 @@ public:
* @param cookie * @param cookie
* @param requestLen Size of data to read * @param requestLen Size of data to read
* @return -@c RETURN_OK to confirm the request for data has been sent. * @return -@c RETURN_OK to confirm the request for data has been sent.
* - Everything else triggers failure event with returnvalue as parameter 1 * - 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;
@ -105,10 +110,14 @@ public:
* This function is used to receive data from the physical device * This function is used to receive data from the physical device
* by implementing and calling related drivers or wrapper functions. * by implementing and calling related drivers or wrapper functions.
* @param cookie * @param cookie
* @param data * @param buffer [out] Set reply here (by using *buffer = ...)
* @param len * @param size [out] size pointer to set (by using *size = ...).
* @return @c RETURN_OK for successfull receive * Set to 0 if no reply was received
* - Everything else triggers failure event with returnvalue as parameter 1 * @return -@c RETURN_OK for successfull receive
* -@c NO_REPLY_RECEIVED if not reply was received. Setting size to
* 0 has the same effect
* - Everything else triggers failure event with
* 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;

View File

@ -557,9 +557,6 @@ void DeviceHandlerBase::doSendRead() {
if (result == RETURN_OK) { if (result == RETURN_OK) {
cookieInfo.state = COOKIE_READ_SENT; cookieInfo.state = COOKIE_READ_SENT;
} }
/* else if(result == DeviceCommunicationIF::NO_READ_REQUEST) {
return;
}*/
else { else {
triggerEvent(DEVICE_REQUESTING_REPLY_FAILED, result); triggerEvent(DEVICE_REQUESTING_REPLY_FAILED, result);
//We can't inform anyone, because we don't know which command was sent last. //We can't inform anyone, because we don't know which command was sent last.
@ -594,7 +591,7 @@ void DeviceHandlerBase::doGetRead() {
return; return;
} }
if (receivedDataLen == 0) if (receivedDataLen == 0 or result == DeviceCommunicationIF::NO_REPLY_RECEIVED)
return; return;
if (wiretappingMode == RAW) { if (wiretappingMode == RAW) {