mirror of
				https://github.com/espressif/esp-idf.git
				synced 2025-11-04 06:11:06 +00:00 
			
		
		
		
	freemodbus: fix invalid error handling for duplicate param_key
This commit is contained in:
		@@ -232,7 +232,7 @@ esp_err_t mbc_master_get_cid_info(uint16_t cid, const mb_parameter_descriptor_t*
 | 
				
			|||||||
 * @return
 | 
					 * @return
 | 
				
			||||||
 *     - esp_err_t ESP_OK - request was successful and value buffer contains
 | 
					 *     - esp_err_t ESP_OK - request was successful and value buffer contains
 | 
				
			||||||
 *                          representation of actual parameter data from slave
 | 
					 *                          representation of actual parameter data from slave
 | 
				
			||||||
 *     - esp_err_t ESP_ERR_INVALID_ARG - invalid argument of function
 | 
					 *     - esp_err_t ESP_ERR_INVALID_ARG - invalid argument of function or parameter descriptor
 | 
				
			||||||
 *     - esp_err_t ESP_ERR_INVALID_RESPONSE - an invalid response from slave
 | 
					 *     - esp_err_t ESP_ERR_INVALID_RESPONSE - an invalid response from slave
 | 
				
			||||||
 *     - esp_err_t ESP_ERR_INVALID_STATE - invalid state during data processing or allocation failure
 | 
					 *     - esp_err_t ESP_ERR_INVALID_STATE - invalid state during data processing or allocation failure
 | 
				
			||||||
 *     - esp_err_t ESP_ERR_TIMEOUT - operation timed out and no response from slave
 | 
					 *     - esp_err_t ESP_ERR_TIMEOUT - operation timed out and no response from slave
 | 
				
			||||||
@@ -253,7 +253,7 @@ esp_err_t mbc_master_get_parameter(uint16_t cid, char* name, uint8_t* value, uin
 | 
				
			|||||||
 *
 | 
					 *
 | 
				
			||||||
 * @return
 | 
					 * @return
 | 
				
			||||||
 *     - esp_err_t ESP_OK - request was successful and value was saved in the slave device registers
 | 
					 *     - esp_err_t ESP_OK - request was successful and value was saved in the slave device registers
 | 
				
			||||||
 *     - esp_err_t ESP_ERR_INVALID_ARG - invalid argument of function
 | 
					 *     - esp_err_t ESP_ERR_INVALID_ARG - invalid argument of function or parameter descriptor
 | 
				
			||||||
 *     - esp_err_t ESP_ERR_INVALID_RESPONSE - an invalid response from slave during processing of parameter
 | 
					 *     - esp_err_t ESP_ERR_INVALID_RESPONSE - an invalid response from slave during processing of parameter
 | 
				
			||||||
 *     - esp_err_t ESP_ERR_INVALID_STATE - invalid state during data processing or allocation failure
 | 
					 *     - esp_err_t ESP_ERR_INVALID_STATE - invalid state during data processing or allocation failure
 | 
				
			||||||
 *     - esp_err_t ESP_ERR_TIMEOUT - operation timed out and no response from slave
 | 
					 *     - esp_err_t ESP_ERR_TIMEOUT - operation timed out and no response from slave
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -410,8 +410,9 @@ static esp_err_t mbc_serial_master_get_parameter(uint16_t cid, char* name,
 | 
				
			|||||||
        // Set the type of parameter found in the table
 | 
					        // Set the type of parameter found in the table
 | 
				
			||||||
        *type = reg_info.param_type;
 | 
					        *type = reg_info.param_type;
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        ESP_LOGD(MB_MASTER_TAG, "%s: The cid(%u) not found in the data dictionary.",
 | 
					        ESP_LOGE(MB_MASTER_TAG, "%s: The cid(%u) not found in the data dictionary.",
 | 
				
			||||||
                                                    __FUNCTION__, reg_info.cid);
 | 
					                                                    __FUNCTION__, reg_info.cid);
 | 
				
			||||||
 | 
					        error = ESP_ERR_INVALID_ARG;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return error;
 | 
					    return error;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -446,6 +447,7 @@ static esp_err_t mbc_serial_master_set_parameter(uint16_t cid, char* name,
 | 
				
			|||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        ESP_LOGE(MB_MASTER_TAG, "%s: The requested cid(%u) not found in the data dictionary.",
 | 
					        ESP_LOGE(MB_MASTER_TAG, "%s: The requested cid(%u) not found in the data dictionary.",
 | 
				
			||||||
                                    __FUNCTION__, reg_info.cid);
 | 
					                                    __FUNCTION__, reg_info.cid);
 | 
				
			||||||
 | 
					        error = ESP_ERR_INVALID_ARG;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return error;
 | 
					    return error;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -444,8 +444,9 @@ static esp_err_t mbc_tcp_master_get_parameter(uint16_t cid, char* name, uint8_t*
 | 
				
			|||||||
        // Set the type of parameter found in the table
 | 
					        // Set the type of parameter found in the table
 | 
				
			||||||
        *type = reg_info.param_type;
 | 
					        *type = reg_info.param_type;
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        ESP_LOGD(MB_MASTER_TAG, "%s: The cid(%u) not found in the data dictionary.",
 | 
					        ESP_LOGE(MB_MASTER_TAG, "%s: The cid(%u) not found in the data dictionary.",
 | 
				
			||||||
                                                    __FUNCTION__, reg_info.cid);
 | 
					                                                    __FUNCTION__, reg_info.cid);
 | 
				
			||||||
 | 
					        error = ESP_ERR_INVALID_ARG;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return error;
 | 
					    return error;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -482,6 +483,7 @@ static esp_err_t mbc_tcp_master_set_parameter(uint16_t cid, char* name, uint8_t*
 | 
				
			|||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        ESP_LOGE(MB_MASTER_TAG, "%s: The requested cid(%u) not found in the data dictionary.",
 | 
					        ESP_LOGE(MB_MASTER_TAG, "%s: The requested cid(%u) not found in the data dictionary.",
 | 
				
			||||||
                                    __FUNCTION__, reg_info.cid);
 | 
					                                    __FUNCTION__, reg_info.cid);
 | 
				
			||||||
 | 
					        error = ESP_ERR_INVALID_ARG;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return error;
 | 
					    return error;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user