diff --git a/mission/obc/CCSDSIPCoreBridge.cpp b/mission/obc/CCSDSIPCoreBridge.cpp index 8dd15a03..61b9b85b 100644 --- a/mission/obc/CCSDSIPCoreBridge.cpp +++ b/mission/obc/CCSDSIPCoreBridge.cpp @@ -56,6 +56,7 @@ ReturnValue_t CCSDSIPCoreBridge::handleTm() { ReturnValue_t CCSDSIPCoreBridge::sendTm(const uint8_t * data, size_t dataLen) { if(pollPapbSignal() == RETURN_OK) { + ptmeBufferEmpty(); startPacketTransfer(); } @@ -72,6 +73,7 @@ ReturnValue_t CCSDSIPCoreBridge::sendTm(const uint8_t * data, size_t dataLen) { } if(pollPapbSignal() == RETURN_OK) { + ptmeBufferEmpty(); endPacketTransfer(); } return RETURN_OK; @@ -103,3 +105,24 @@ ReturnValue_t CCSDSIPCoreBridge::pollPapbSignal() { return RETURN_OK; } + +void CCSDSIPCoreBridge::ptmeBufferEmpty() { + ReturnValue_t result = RETURN_OK; + int papbEmptyState = 1; + + result = gpioComIF->readGpio(papbEmptyId, &papbEmptyState); + + if (result != RETURN_OK) { + sif::debug << "CCSDSIPCoreBridge::ptmeBufferEmpty: Failed to read papb empty signal" + << std::endl; + return; + } + + if (papbEmptyState == 1) { + sif::debug << "CCSDSIPCoreBridge::ptmeBufferEmpty: Buffer is empty" << std::endl; + } + else { + sif::debug << "CCSDSIPCoreBridge::ptmeBufferEmpty: Buffer is not empty" << std::endl; + } + return; +} diff --git a/mission/obc/CCSDSIPCoreBridge.h b/mission/obc/CCSDSIPCoreBridge.h index 2b135350..e54875e0 100644 --- a/mission/obc/CCSDSIPCoreBridge.h +++ b/mission/obc/CCSDSIPCoreBridge.h @@ -53,7 +53,8 @@ private: /** Size of mapped address space. 4k (minimal size of pl device) */ - static const int MAP_SIZE = 0xFA0; +// static const int MAP_SIZE = 0xFA0; + static const int MAP_SIZE = 0x1000; /** * Configuration bits: @@ -111,6 +112,12 @@ private: * @return RETURN_OK when ready to receive data else PAPB_BUSY. */ ReturnValue_t pollPapbSignal(); + + /** + * @brief This function can be used for debugging to check wheter there are packets in + * the packet buffer of the PTME or not. + */ + void ptmeBufferEmpty(); }; #endif /* MISSION_OBC_CCSDSIPCOREBRIDGE_H_ */