fully implemented special request handling
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
This commit is contained in:
parent
bc2a0d875f
commit
a026f5e2d0
@ -73,7 +73,7 @@ ReturnValue_t RwPollingTask::performOperation(uint8_t operationCode) {
|
|||||||
if (writeAndReadAllRws(rws::CLEAR_LAST_RESET_STATUS) != returnvalue::OK) {
|
if (writeAndReadAllRws(rws::CLEAR_LAST_RESET_STATUS) != returnvalue::OK) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// TODO: Special requests
|
handleSpecialRequests();
|
||||||
}
|
}
|
||||||
|
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
@ -382,6 +382,54 @@ size_t RwPollingTask::idAndIdxToReadBuffer(DeviceCommandId_t id, uint8_t rwIdx,
|
|||||||
return rws::idToPacketLen(id);
|
return rws::idToPacketLen(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RwPollingTask::fillSpecialRequestArray() {
|
||||||
|
for (unsigned idx = 0; idx < rwCookies.size(); idx++) {
|
||||||
|
if (skipCommandingForRw[idx]) {
|
||||||
|
specialRequestIds[idx] = DeviceHandlerIF::NO_COMMAND_ID;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
switch (rwCookies[idx]->specialRequest) {
|
||||||
|
case (rws::SpecialRwRequest::GET_TM): {
|
||||||
|
specialRequestIds[idx] = rws::GET_TM;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case (rws::SpecialRwRequest::INIT_RW_CONTROLLER): {
|
||||||
|
specialRequestIds[idx] = rws::INIT_RW_CONTROLLER;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
specialRequestIds[idx] = DeviceHandlerIF::NO_COMMAND_ID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RwPollingTask::handleSpecialRequests() {
|
||||||
|
int fd = 0;
|
||||||
|
fillSpecialRequestArray();
|
||||||
|
ReturnValue_t result = openSpi(O_RDWR, fd);
|
||||||
|
if (result != returnvalue::OK) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (unsigned idx = 0; idx < rwCookies.size(); idx++) {
|
||||||
|
if (specialRequestIds[idx] == DeviceHandlerIF::NO_COMMAND_ID) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
prepareSimpleCommand(specialRequestIds[idx]);
|
||||||
|
writeOneRwCmd(idx, fd);
|
||||||
|
}
|
||||||
|
closeSpi(fd);
|
||||||
|
usleep(rws::SPI_REPLY_DELAY);
|
||||||
|
for (unsigned idx = 0; idx < rwCookies.size(); idx++) {
|
||||||
|
if (specialRequestIds[idx] == DeviceHandlerIF::NO_COMMAND_ID) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
uint8_t* replyBuf;
|
||||||
|
size_t maxReadLen = idAndIdxToReadBuffer(specialRequestIds[idx], idx, &replyBuf);
|
||||||
|
readNextReply(*rwCookies[idx], replyBuf, maxReadLen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// This closes the SPI
|
// This closes the SPI
|
||||||
void RwPollingTask::closeSpi(int fd) {
|
void RwPollingTask::closeSpi(int fd) {
|
||||||
// This will perform the function to close the SPI
|
// This will perform the function to close the SPI
|
||||||
|
@ -45,6 +45,7 @@ class RwPollingTask : public SystemObject, public ExecutableObjectIF, public Dev
|
|||||||
const char* spiDev;
|
const char* spiDev;
|
||||||
SpiComIF* spiIF;
|
SpiComIF* spiIF;
|
||||||
std::array<bool, 4> skipCommandingForRw;
|
std::array<bool, 4> skipCommandingForRw;
|
||||||
|
std::array<DeviceCommandId_t, 4> specialRequestIds;
|
||||||
std::array<RwCookie*, 4> rwCookies;
|
std::array<RwCookie*, 4> rwCookies;
|
||||||
std::array<uint8_t, rws::MAX_CMD_SIZE> writeBuffer;
|
std::array<uint8_t, rws::MAX_CMD_SIZE> writeBuffer;
|
||||||
std::array<uint8_t, rws::MAX_CMD_SIZE * 2> encodedBuffer;
|
std::array<uint8_t, rws::MAX_CMD_SIZE * 2> encodedBuffer;
|
||||||
@ -60,6 +61,8 @@ class RwPollingTask : public SystemObject, public ExecutableObjectIF, public Dev
|
|||||||
|
|
||||||
ReturnValue_t sendOneMessage(int fd, RwCookie& rwCookie);
|
ReturnValue_t sendOneMessage(int fd, RwCookie& rwCookie);
|
||||||
ReturnValue_t readNextReply(RwCookie& rwCookie, uint8_t* replyBuf, size_t maxReplyLen);
|
ReturnValue_t readNextReply(RwCookie& rwCookie, uint8_t* replyBuf, size_t maxReplyLen);
|
||||||
|
void handleSpecialRequests();
|
||||||
|
|
||||||
ReturnValue_t initializeInterface(CookieIF* cookie) override;
|
ReturnValue_t initializeInterface(CookieIF* cookie) override;
|
||||||
|
|
||||||
ReturnValue_t sendMessage(CookieIF* cookie, const uint8_t* sendData, size_t sendLen) override;
|
ReturnValue_t sendMessage(CookieIF* cookie, const uint8_t* sendData, size_t sendLen) override;
|
||||||
@ -75,6 +78,7 @@ class RwPollingTask : public SystemObject, public ExecutableObjectIF, public Dev
|
|||||||
ReturnValue_t prepareSetSpeedCmd(uint8_t rwIdx);
|
ReturnValue_t prepareSetSpeedCmd(uint8_t rwIdx);
|
||||||
|
|
||||||
size_t idAndIdxToReadBuffer(DeviceCommandId_t id, uint8_t rwIdx, uint8_t** readPtr);
|
size_t idAndIdxToReadBuffer(DeviceCommandId_t id, uint8_t rwIdx, uint8_t** readPtr);
|
||||||
|
void fillSpecialRequestArray();
|
||||||
|
|
||||||
void pullCsHigh(gpioId_t gpioId, GpioIF& gpioIF);
|
void pullCsHigh(gpioId_t gpioId, GpioIF& gpioIF);
|
||||||
void closeSpi(int);
|
void closeSpi(int);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user