PROS error code meanings (errno)

#1

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?

0 Likes

#2

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

#3

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.

0 Likes

#4

Can you post the code you used?

0 Likes

#5

#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
pros::delay(50);
}
}

0 Likes

#6

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.

0 Likes

#7

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?

0 Likes

#8

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