@@ -603,19 +603,21 @@ static esp_err_t master_init(void)
603603 MB_RETURN_ON_FALSE ((err == ESP_OK ), ESP_ERR_INVALID_STATE , TAG ,
604604 "mb serial set pin failure, uart_set_pin() returned (0x%x)." , (int )err );
605605
606- err = mbc_master_start (master_handle );
606+ err = mbc_master_set_descriptor (master_handle , & device_parameters [ 0 ], num_device_parameters );
607607 MB_RETURN_ON_FALSE ((err == ESP_OK ), ESP_ERR_INVALID_STATE , TAG ,
608- "mb controller start fail, returned (0x%x)." , (int )err );
608+ "mb controller set descriptor fail, returns (0x%x)." , (int )err );
609609
610610 // Set driver mode to Half Duplex
611611 err = uart_set_mode (MB_PORT_NUM , UART_MODE_RS485_HALF_DUPLEX );
612612 MB_RETURN_ON_FALSE ((err == ESP_OK ), ESP_ERR_INVALID_STATE , TAG ,
613613 "mb serial set mode failure, uart_set_mode() returned (0x%x)." , (int )err );
614614
615615 vTaskDelay (5 );
616- err = mbc_master_set_descriptor (master_handle , & device_parameters [0 ], num_device_parameters );
616+
617+ err = mbc_master_start (master_handle );
617618 MB_RETURN_ON_FALSE ((err == ESP_OK ), ESP_ERR_INVALID_STATE , TAG ,
618- "mb controller set descriptor fail, returns(0x%x)." , (int )err );
619+ "mb controller start fail, returned (0x%x)." , (int )err );
620+
619621 ESP_LOGI (TAG , "Modbus master stack initialized..." );
620622 return err ;
621623}
0 commit comments