PROS error code meanings (errno)

Is there a way of knowing what a particular error code (errno) means. if I print the value of errno it gives me a number eg. 23 Alternatively, are there any other ‘error variables’ that I can check?

You can Google errno. It’s a variable typically used by standard library functions to give extra information about error states reached by functions.

Note also that you can get a string representation of the error number by using strerror:

std::cout << strerror(errno) << std::endl;

(Also, the PROS documentation enumerates the values of errno that are set when functions reach error states)

1 Like

This gives me the string: 59100696
but what does this tell me exactly?
This relates to me post about vision sensor programming, it would be much appreciated if you could give me some advice. Thank you for your help so far.

Can you post the code you used?

#include “main.h”
#define VISION_PORT 1
#define BALL

void opcontrol() {
pros::Vision vision_sensor (VISION_PORT);
while (true) {
pros::vision_object_s_t rtn = vision_sensor.get_by_sig(0,1);
printf(“sig: %d”, rtn.signature);
printf(“error: %d”, strerror(errno));
// Gets the largest object

The problem is you’re printing the string (well, pointer to a character) as if it’s a number-- that’s what the %d means. You can change the format specifier to %s to print a string.

Thank you! This is helpful! I got the text: No space left on device
Is this talking about the vision sensor?
If so then how do I fix it?

Gonna shift the conversation back to the thread about the vision sensor itself since this thread was about how to print error code meanings and that thread we’re focused on why the vision sensor is reporting an error in the first place

Don’t wanna confuse our future selves :slight_smile:

1 Like