new returnvalue for scanForReply

to ignore full packet
DeviceCommunicationIF sendMessage function takes const data pointer now
This commit is contained in:
Robin Müller 2020-04-19 13:41:43 +02:00
parent 0c0c8ec448
commit 574d6051ba
3 changed files with 48 additions and 13 deletions

View File

@ -39,14 +39,35 @@ public:
virtual void close(Cookie *cookie) = 0;
//SHOULDDO can data be const?
virtual ReturnValue_t sendMessage(Cookie *cookie, uint8_t *data,
/**
* Called by DHB in the SEND_WRITE doSendWrite().
* This function is used to send data to the physical device
* by implementing and calling related drivers or wrapper functions.
* @param cookie
* @param data
* @param len
* @return - @c RETURN_OK for successfull send
* - Everything else triggers sending failed event with
* returnvalue as parameter 1
*/
virtual ReturnValue_t sendMessage(Cookie *cookie,const uint8_t *data,
uint32_t len) = 0;
virtual ReturnValue_t getSendSuccess(Cookie *cookie) = 0;
virtual ReturnValue_t requestReceiveMessage(Cookie *cookie) = 0;
/**
* Called by DHB in the GET_WIRTE doGetRead().
* This function is used to receive data from the physical device
* by implementing and calling related drivers or wrapper functions.
* @param cookie
* @param data
* @param len
* @return - @c RETURN_OK for successfull receive
* - Everything else triggers receiving failed with returnvalue
* as parameter 1
*/
virtual ReturnValue_t readReceivedMessage(Cookie *cookie, uint8_t **buffer,
uint32_t *size) = 0;

View File

@ -538,6 +538,8 @@ void DeviceHandlerBase::doGetRead() {
break;
case IGNORE_REPLY_DATA:
break;
case IGNORE_FULL_PACKET:
return;
default:
//We need to wait for timeout.. don't know what command failed and who sent it.
replyRawReplyIfnotWiretapped(receivedData, foundLen);

View File

@ -143,8 +143,10 @@ protected:
static const uint8_t INTERFACE_ID = CLASS_ID::DEVICE_HANDLER_BASE;
static const ReturnValue_t INVALID_CHANNEL = MAKE_RETURN_CODE(4);
static const ReturnValue_t APERIODIC_REPLY = MAKE_RETURN_CODE(5);
static const ReturnValue_t IGNORE_REPLY_DATA = MAKE_RETURN_CODE(6);
static const ReturnValue_t APERIODIC_REPLY = MAKE_RETURN_CODE(5); //!< This is used to specify for replies from a device which are not replies to requests
static const ReturnValue_t IGNORE_REPLY_DATA = MAKE_RETURN_CODE(6); //!< Ignore parts of the received packet
static const ReturnValue_t IGNORE_FULL_PACKET = MAKE_RETURN_CODE(7); //!< Ignore full received packet
// static const ReturnValue_t ONE_SWITCH = MAKE_RETURN_CODE(8);
// static const ReturnValue_t TWO_SWITCHES = MAKE_RETURN_CODE(9);
static const ReturnValue_t NO_SWITCH = MAKE_RETURN_CODE(10);
@ -583,6 +585,7 @@ protected:
* @return The current delay count. If the command does not exist (should never happen) it returns 0.
*/
uint8_t getReplyDelayCycles(DeviceCommandId_t deviceCommand);
/**
* Scans a buffer for a valid reply.
*
@ -594,16 +597,25 @@ protected:
* Errors should be reported directly, the base class does NOT report any errors based on the return
* value of this function.
*
* @param start start of data
* @param len length of data
* @param[out] foundId the id of the packet starting at @c start
* @param[out] foundLen length of the packet found
* @param start start of remaining buffer to be scanned
* @param len length of remaining buffer to be scanned
* @param[out] foundId the id of the data found in the buffer.
* @param[out] foundLen length of the data found. Is to be set in function, buffer is scanned at previous position + foundLen.
* @return
* - @c RETURN_OK a valid packet was found at @c start, @c foundLen is valid
* - @c NO_VALID_REPLY no reply could be found starting at @c start, implies @c foundLen is not valid, base class will call scanForReply() again with ++start
* - @c INVALID_REPLY a packet was found but it is invalid, eg checksum error, implies @c foundLen is valid, can be used to skip some bytes
* - @c TOO_SHORT @c len is too short for any valid packet
* - @c APERIODIC_REPLY if a valid reply is received that has not been requested by a command, but should be handled anyway (@see also fillCommandAndCookieMap() )
* - @c RETURN_OK a valid packet was found at @c start, @c foundLen is valid
* - @c RETURN_FAILED no reply could be found starting at @c start,
* implies @c foundLen is not valid, base class will call scanForReply()
* again with ++start
* - @c DeviceHandlerIF::INVALID_DATA a packet was found but it is invalid,
* e.g. checksum error, implies @c foundLen is valid, can be used to
* skip some bytes
* - @c DeviceHandlerIF::LENGTH_MISSMATCH @c len is invalid
* - @c DeviceHandlerIF::IGNORE_REPLY_DATA Ignore this specific part of
* the packet
* - @c DeviceHandlerIF::IGNORE_FULL_PACKET Ignore the packet
* - @c APERIODIC_REPLY if a valid reply is received that has not been
* requested by a command, but should be handled anyway
* (@see also fillCommandAndCookieMap() )
*/
virtual ReturnValue_t scanForReply(const uint8_t *start, uint32_t len,
DeviceCommandId_t *foundId, uint32_t *foundLen) = 0;