purduesigbots/pros

In some cases, vision_read_by_size will return an error without setting errno

nickmertin opened this issue · 1 comments

Expected Behavior:

Anytime an error code is returned from any API function, errno should be set to indicate the error which occured.

Actual Behavior:

Initially, vision_read_by_size fills the signature of each element in the output array with VISION_OBJ_ERR_SIG. If object_count is greater than the number of available objects (as given by vexDeviceVisionObjectCountGet), then one or more entries at the end of the array will not be touched by the second for loop, leaving them with a value which signifies that an error occurred. Meanwhile, unless an actual error occurs in the underlying VEX API, errno will not be set, leaving it at whatever value it happened to be when the function was called.

Steps to reproduce:

I don't have the hardware to test, but you should be able to reproduce by requesting more objects than exist. Try setting errno to something distinctive before calling vision_read_by_size and note that it won't have changed afterwards.

System information:

Platform: V5
PROS Kernel Version: latest develop branch

Never mind, please ignore. I just noticed that the function returns the number of objects actually read, which solves this problem.