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

Some function return wrong error code because of using claim_port macro #159

Closed
Jerrylum opened this issue Aug 29, 2019 · 3 comments
Closed
Labels
bug Something isn't working p: normal Normal priority

Comments

@Jerrylum
Copy link
Contributor

Jerrylum commented Aug 29, 2019

According to lines 47 ~ 48 in /include/api.h
https://github.com/purduesigbots/pros/blob/develop/include/api.h#L47-L48

As far as I know, the first one (PROS_ERR) is used in functions which return an integer value and PROS_ERR_Fis used in functions which return a double value.

But according to the file /src/devices/vdml_motors.c and file /include/vdml/vdml.h
https://github.com/purduesigbots/pros/blob/develop/src/devices/vdml_motors.c#L178-L182

https://github.com/purduesigbots/pros/blob/develop/include/vdml/vdml.h#L28-L57

The claim_port macro returns PROS_ERR. It used in all functions but not all of them should return PROS_ERR.

Expected Behavior:

claim_port macro should only be used in functions returning int32_t, so we need to change claim_port behavior.

Steps to reproduce:

Try it yourself

System information:

Platform: V5
PROS Kernel Version: all

Screenshots/Output Dumps/Stack Traces

@baylessj baylessj added bug Something isn't working p: normal Normal priority labels Aug 29, 2019
@Jerrylum Jerrylum changed the title clam_port macro used in functions that returns a double Some function return wrong error code because of using clam_port macro Aug 29, 2019
@baylessj baylessj changed the title Some function return wrong error code because of using clam_port macro Some function return wrong error code because of using claim_port macro Aug 29, 2019
@baylessj baylessj changed the title Some function return wrong error code because of using claim_port macro Some function return wrong error code because of using claim_port macro Aug 29, 2019
@baylessj
Copy link
Contributor

baylessj commented Aug 29, 2019

Good catch, thanks for opening this issue. Looks like we used just the internal_port_mutex_take function by itself to return PROS_ERR_F here:

double battery_get_temperature(void) {
if (!internal_port_mutex_take(V5_PORT_BATTERY)) {
errno = EACCES;
return PROS_ERR_F;
}
double rtn = vexBatteryTemperatureGet();
internal_port_mutex_give(V5_PORT_BATTERY);
return rtn;
}

The simplest fix would be to use this exact same method for the functions that you mentioned that are still using claim_port but it might be worth creating a claim_port_f macro for these instances.

@Octogonapus
Copy link
Contributor

@HotelCalifornia This should be closed.

@HotelCalifornia
Copy link
Contributor

Closed in #160. Not sure why it didn't close this automatically

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p: normal Normal priority
Projects
None yet
Development

No branches or pull requests

4 participants