Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: modify return type of getIntV() and getExtV() to int32_t #111

Conversation

TDA-2030
Copy link
Contributor

@TDA-2030 TDA-2030 commented Jul 16, 2024

As shown in the following code, since the range of the data type uint16_t cannot express numbers greater than 78000, there is a comparison that is always true.

bool TMC4671::hasPower(){
	uint16_t intV = getIntV();
	return (intV > 10000) && (getExtV() > 10000) && (intV < 78000);
}

Therefore, the return type of getExtV() and getIntV() has been changed to int32_t

@TDA-2030 TDA-2030 force-pushed the bugfix/error_data_type_in_TMC4671_power_check branch from e33c351 to e8a1de2 Compare July 16, 2024 06:15
@Ultrawipf
Copy link
Owner

Thank you for finding this.
As the limit should be 65v it should usually not affect anything at the moment but it seems reasonable to change the type to 32b in case higher voltages are measured at some point.

Have to check if there is anything else that might be affected so i am going to merge into the dev branch first for the next release as it didn't seem to have caused issues yet.

@Ultrawipf Ultrawipf changed the base branch from master to development July 16, 2024 07:59
@Ultrawipf Ultrawipf merged commit 6867c8a into Ultrawipf:development Jul 16, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants