heater main switch commanding

This commit is contained in:
2021-02-11 08:19:48 +01:00
parent d602912364
commit 5ccb3d1488
9 changed files with 75 additions and 24 deletions

View File

@ -164,6 +164,7 @@ ReturnValue_t CspComIF::cspTransfer(uint8_t cspAddress, uint8_t cspPort,
if (commandPacket == NULL) {
sif::error << "CspComIF::cspTransfer: Failed to get memory for a csp packet from the csp "
<< "stack" << std::endl;
csp_close(conn);
return RETURN_FAILED;
}
@ -173,6 +174,7 @@ ReturnValue_t CspComIF::cspTransfer(uint8_t cspAddress, uint8_t cspPort,
if (!csp_send(conn, commandPacket, timeout_ms)) {
csp_buffer_free(commandPacket);
sif::error << "CspComIF::cspTransfer: Failed to send csp packet" << std::endl;
csp_close(conn);
return RETURN_FAILED;
}
@ -185,6 +187,8 @@ ReturnValue_t CspComIF::cspTransfer(uint8_t cspAddress, uint8_t cspPort,
reply = csp_read(conn, timeout_ms);
if (reply == NULL) {
sif::error << "CspComIF::cspTransfer: Failed to read csp packet" << std::endl;
csp_buffer_free(reply);
csp_close(conn);
return RETURN_FAILED;
}
memcpy(replyBuffer, reply->data, reply->length);
@ -195,10 +199,13 @@ ReturnValue_t CspComIF::cspTransfer(uint8_t cspAddress, uint8_t cspPort,
reply = csp_read(conn, timeout_ms);
if (reply == NULL) {
sif::error << "CspComIF::cspTransfer: Failed to read csp packet" << std::endl;
csp_close(conn);
return RETURN_FAILED;
}
if ((reply->length + bytesRead) > iter->second.size()) {
sif::error << "CspComIF::cspTransfer: Reply buffer to short" << std::endl;
csp_buffer_free(reply);
csp_close(conn);
return RETURN_FAILED;
}
memcpy(replyBuffer + bytesRead, reply->data, reply->length);
@ -209,6 +216,7 @@ ReturnValue_t CspComIF::cspTransfer(uint8_t cspAddress, uint8_t cspPort,
if(expectedSize != 0){
sif::error << "CspComIF::cspTransfer: Received more bytes than requested" << std::endl;
csp_close(conn);
return RETURN_FAILED;
}