Returning NMBS_ERROR_INVALID_UNIT_ID in case of invalid unit ID in response
This commit is contained in:
parent
30c7ce3854
commit
037de71d9b
@ -338,6 +338,7 @@ static nmbs_error recv_req_header(nmbs_t* nmbs, bool* first_byte_received) {
|
|||||||
|
|
||||||
static nmbs_error recv_res_header(nmbs_t* nmbs) {
|
static nmbs_error recv_res_header(nmbs_t* nmbs) {
|
||||||
uint16_t req_transaction_id = nmbs->msg.transaction_id;
|
uint16_t req_transaction_id = nmbs->msg.transaction_id;
|
||||||
|
uint8_t req_unit_id = nmbs->msg.unit_id;
|
||||||
uint8_t req_fc = nmbs->msg.fc;
|
uint8_t req_fc = nmbs->msg.fc;
|
||||||
|
|
||||||
nmbs_error err = recv_msg_header(nmbs, NULL);
|
nmbs_error err = recv_msg_header(nmbs, NULL);
|
||||||
@ -349,8 +350,8 @@ static nmbs_error recv_res_header(nmbs_t* nmbs) {
|
|||||||
return NMBS_ERROR_INVALID_RESPONSE;
|
return NMBS_ERROR_INVALID_RESPONSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nmbs->msg.ignored)
|
if (nmbs->msg.unit_id != req_unit_id)
|
||||||
return NMBS_ERROR_INVALID_RESPONSE;
|
return NMBS_ERROR_INVALID_UNIT_ID;
|
||||||
|
|
||||||
if (nmbs->msg.fc != req_fc) {
|
if (nmbs->msg.fc != req_fc) {
|
||||||
if (nmbs->msg.fc - 0x80 == req_fc) {
|
if (nmbs->msg.fc - 0x80 == req_fc) {
|
||||||
|
|||||||
@ -54,6 +54,7 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
typedef enum nmbs_error {
|
typedef enum nmbs_error {
|
||||||
// Library errors
|
// Library errors
|
||||||
|
NMBS_ERROR_INVALID_UNIT_ID = -7, /**< Received invalid unit ID in response from server */
|
||||||
NMBS_ERROR_INVALID_TCP_MBAP = -6, /**< Received invalid TCP MBAP */
|
NMBS_ERROR_INVALID_TCP_MBAP = -6, /**< Received invalid TCP MBAP */
|
||||||
NMBS_ERROR_CRC = -5, /**< Received invalid CRC */
|
NMBS_ERROR_CRC = -5, /**< Received invalid CRC */
|
||||||
NMBS_ERROR_TRANSPORT = -4, /**< Transport error */
|
NMBS_ERROR_TRANSPORT = -4, /**< Transport error */
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user