diff --git a/include/pros/adi.h b/include/pros/adi.h index 71e32471a..e0e733588 100644 --- a/include/pros/adi.h +++ b/include/pros/adi.h @@ -122,8 +122,7 @@ namespace c { * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of ADI Ports. - * EACCES - Another resource is currently trying to access the ADI. + * ENXIO - The given value is not within the range of ADI Ports. * * \param port * The ADI port number (from 1-8, 'a'-'h', 'A'-'H') for which to return @@ -138,8 +137,7 @@ adi_port_config_e_t adi_port_get_config(uint8_t port); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of ADI Ports. - * EACCES - Another resource is currently trying to access the ADI. + * ENXIO - The given value is not within the range of ADI Ports. * * \param port * The ADI port number (from 1-8, 'a'-'h', 'A'-'H') for which the value @@ -154,8 +152,7 @@ int32_t adi_port_get_value(uint8_t port); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of ADI Ports. - * EACCES - Another resource is currently trying to access the ADI. + * ENXIO - The given value is not within the range of ADI Ports. * * \param port * The ADI port number (from 1-8, 'a'-'h', 'A'-'H') to configure @@ -175,8 +172,7 @@ int32_t adi_port_set_config(uint8_t port, adi_port_config_e_t type); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of ADI Ports. - * EACCES - Another resource is currently trying to access the ADI. + * ENXIO - The given value is not within the range of ADI Ports. * * \param port * The ADI port number (from 1-8, 'a'-'h', 'A'-'H') for which the value @@ -243,9 +239,7 @@ int32_t adi_port_set_value(uint8_t port, int32_t value); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of ADI Ports, or the given - * port is not configured as an analog input. - * EACCES - Another resource is currently trying to access the ADI. + * ENXIO - The given value is not within the range of ADI Ports * * \param port * The ADI port to calibrate (from 1-8, 'a'-'h', 'A'-'H') @@ -262,9 +256,8 @@ int32_t adi_analog_calibrate(uint8_t port); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of ADI Ports, or the given - * port is not configured as an analog input. - * EACCES - Another resource is currently trying to access the ADI. + * ENXIO - The given value is not within the range of ADI Ports + * EADDRINUSE - The port is not configured as an analog input * * \param port * The ADI port (from 1-8, 'a'-'h', 'A'-'H') for which the value will be @@ -285,9 +278,8 @@ int32_t adi_analog_read(uint8_t port); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of ADI Ports, or the given - * port is not configured as an analog input. - * EACCES - Another resource is currently trying to access the ADI. + * ENXIO - The given value is not within the range of ADI Ports + * EADDRINUSE - The port is not configured as an analog input * * \param port * The ADI port (from 1-8, 'a'-'h', 'A'-'H') for which the value will be @@ -313,9 +305,8 @@ int32_t adi_analog_read_calibrated(uint8_t port); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of ADI Ports, or the given - * port is not configured as an analog input. - * EACCES - Another resource is currently trying to access the ADI. + * ENXIO - The given value is not within the range of ADI Ports + * EADDRINUSE - The port is not configured as an analog input * * \param port * The ADI port (from 1-8, 'a'-'h', 'A'-'H') for which the value will be @@ -336,9 +327,8 @@ int32_t adi_analog_read_calibrated_HR(uint8_t port); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of ADI Ports, or the given - * port is not configured as a digital input. - * EACCES - Another resource is currently trying to access the ADI. + * ENXIO - The given value is not within the range of ADI Ports + * EADDRINUSE - The port is not configured as a digital input * * \param port * The ADI port to read (from 1-8, 'a'-'h', 'A'-'H') @@ -360,9 +350,8 @@ int32_t adi_digital_read(uint8_t port); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of ADI Ports, or the given - * port is not configured as a digital input. - * EACCES - Another resource is currently trying to access the ADI. + * ENXIO - The given value is not within the range of ADI Ports + * EADDRINUSE - The port is not configured as a digital input * * \param port * The ADI port to read (from 1-8, 'a'-'h', 'A'-'H') @@ -379,9 +368,8 @@ int32_t adi_digital_get_new_press(uint8_t port); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of ADI Ports, or the given - * port is not configured as a digital output. - * EACCES - Another resource is currently trying to access the ADI. + * ENXIO - The given value is not within the range of ADI Ports + * EADDRINUSE - The port is not configured as a digital output * * \param port * The ADI port to read (from 1-8, 'a'-'h', 'A'-'H') @@ -399,8 +387,7 @@ int32_t adi_digital_write(uint8_t port, const bool value); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of ADI Ports. - * EACCES - Another resource is currently trying to access the ADI. + * ENXIO - The given value is not within the range of ADI Ports * * \param port * The ADI port to read (from 1-8, 'a'-'h', 'A'-'H') @@ -417,9 +404,8 @@ int32_t adi_pin_mode(uint8_t port, uint8_t mode); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of ADI Ports, or the given - * port is not configured as an ADI Motor. - * EACCES - Another resource is currently trying to access the ADI. + * ENXIO - The given value is not within the range of ADI Ports + * EADDRINUSE - The port is not configured as an motor * * \param port * The ADI port to set (from 1-8, 'a'-'h', 'A'-'H') @@ -437,9 +423,8 @@ int32_t adi_motor_set(uint8_t port, int8_t speed); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of ADI Ports, or the given - * port is not configured as an ADI Motor. - * EACCES - Another resource is currently trying to access the ADI. + * ENXIO - The given value is not within the range of ADI Ports + * EADDRINUSE - The port is not configured as an motor * * \param port * The ADI port to get (from 1-8, 'a'-'h', 'A'-'H') @@ -453,9 +438,8 @@ int32_t adi_motor_get(uint8_t port); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of ADI Ports, or the given - * port is not configured as an ADI Motor. - * EACCES - Another resource is currently trying to access the ADI. + * ENXIO - The given value is not within the range of ADI Ports + * EADDRINUSE - The port is not configured as an motor * * \param port * The ADI port to set (from 1-8, 'a'-'h', 'A'-'H') @@ -480,9 +464,9 @@ typedef int32_t adi_encoder_t; * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of ADI Ports, or the given - * port is not configured as an ADI Encoder. - * EACCES - Another resource is currently trying to access the ADI. + * ENXIO - The given value is not within the range of ADI Ports + * EADDRINUSE - The port is not configured as an encoder + * * \param enc * The adi_encoder_t object from adi_encoder_init() to read @@ -497,9 +481,9 @@ int32_t adi_encoder_get(adi_encoder_t enc); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of ADI Ports, or the given - * port is not configured as an ADI Encoder. - * EACCES - Another resource is currently trying to access the ADI. + * ENXIO - The given value is not within the range of ADI Ports + * EADDRINUSE - The port is not configured as an encoder + * * \param port_top * The "top" wire from the encoder sensor with the removable cover side @@ -522,9 +506,9 @@ adi_encoder_t adi_encoder_init(uint8_t port_top, uint8_t port_bottom, const bool * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of ADI Ports, or the given - * port is not configured as an ADI Encoder. - * EACCES - Another resource is currently trying to access the ADI. + * ENXIO - The given value is not within the range of ADI Ports + * EADDRINUSE - The port is not configured as an encoder + * * \param enc * The adi_encoder_t object from adi_encoder_init() to reset @@ -539,9 +523,8 @@ int32_t adi_encoder_reset(adi_encoder_t enc); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of ADI Ports, or the given - * port is not configured as an ADI Encoder. - * EACCES - Another resource is currently trying to access the ADI. + * ENXIO - The given value is not within the range of ADI Ports + * EADDRINUSE - The port is not configured as an encoder * * \param enc * The adi_encoder_t object from adi_encoder_init() to stop @@ -568,9 +551,8 @@ typedef int32_t adi_ultrasonic_t; * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of ADI Ports, or the given - * port is not configured as an ADI Ultrasonic. - * EACCES - Another resource is currently trying to access the ADI. + * ENXIO - The given value is not within the range of ADI Ports + * EADDRINUSE - The port is not configured as an ultrasonic * * \param ult * The adi_ultrasonic_t object from adi_ultrasonic_init() to read @@ -585,9 +567,8 @@ int32_t adi_ultrasonic_get(adi_ultrasonic_t ult); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of ADI Ports, or the given - * port is not configured as an ADI Ultrasonic. - * EACCES - Another resource is currently trying to access the ADI. + * ENXIO - The given value is not within the range of ADI Ports + * EADDRINUSE - The port is not configured as an ultrasonic * * \param port_ping * The port connected to the orange OUTPUT cable. This should be in the @@ -606,9 +587,8 @@ adi_ultrasonic_t adi_ultrasonic_init(uint8_t port_ping, uint8_t port_echo); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of ADI Ports, or the given - * port is not configured as an ADI Ultrasonic. - * EACCES - Another resource is currently trying to access the ADI. + * ENXIO - The given value is not within the range of ADI Ports + * EADDRINUSE - The port is not configured as an ultrasonic * * \param ult * The adi_ultrasonic_t object from adi_ultrasonic_init() to stop @@ -636,9 +616,8 @@ typedef int32_t adi_gyro_t; * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of ADI Ports, or the given - * port is not configured as an ADI Gyro. - * EACCES - Another resource is currently trying to access the ADI. + * ENXIO - The given value is not within the range of ADI Ports + * EADDRINUSE - The port is not configured as a gyro * * \param gyro * The adi_gyro_t object for which the angle will be returned @@ -657,8 +636,8 @@ double adi_gyro_get(adi_gyro_t gyro); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of ADI Ports. - * EACCES - Another resource is currently trying to access the ADI. + * ENXIO - The given value is not within the range of ADI Ports + * EADDRINUSE - The port is not configured as a gyro * * \param port * The ADI port to initialize as a gyro (from 1-8, 'a'-'h', 'A'-'H') @@ -676,9 +655,8 @@ adi_gyro_t adi_gyro_init(uint8_t port, double multiplier); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of ADI Ports, or the given - * port is not configured as an ADI Gyro. - * EACCES - Another resource is currently trying to access the ADI. + * ENXIO - The given value is not within the range of ADI Ports + * EADDRINUSE - The port is not configured as a gyro * * \param gyro * The adi_gyro_t object for which the angle will be returned @@ -693,9 +671,8 @@ int32_t adi_gyro_reset(adi_gyro_t gyro); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of ADI Ports, or the given - * port is not configured as an ADI Gyro. - * EACCES - Another resource is currently trying to access the ADI. + * ENXIO - The given value is not within the range of ADI Ports + * EADDRINUSE - The port is not configured as a gyro * * \param gyro * The adi_gyro_t object to be shut down diff --git a/include/pros/adi.hpp b/include/pros/adi.hpp index d047ae6e4..8c2a93e32 100644 --- a/include/pros/adi.hpp +++ b/include/pros/adi.hpp @@ -30,8 +30,7 @@ class ADIPort { * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of ADI Ports. - * EACCES - Another resource is currently trying to access the ADI. + * ENXIO - The given value is not within the range of ADI Ports * * \param port * The ADI port number (from 1-8, 'a'-'h', 'A'-'H') to configure @@ -45,10 +44,6 @@ class ADIPort { /** * Gets the configuration for the given ADI port. * - * This function uses the following values of errno when an error state is - * reached: - * EACCES - Another resource is currently trying to access the ADI. - * * \return The ADI configuration for the given port */ std::int32_t get_config(void) const; @@ -56,10 +51,6 @@ class ADIPort { /** * Gets the value for the given ADI port. * - * This function uses the following values of errno when an error state is - * reached: - * EACCES - Another resource is currently trying to access the ADI. - * * \return The value stored for the given port */ std::int32_t get_value(void) const; @@ -67,10 +58,6 @@ class ADIPort { /** * Configures an ADI port to act as a given sensor type. * - * This function uses the following values of errno when an error state is - * reached: - * EACCES - Another resource is currently trying to access the ADI. - * * \param type * The configuration type for the port * @@ -85,10 +72,6 @@ class ADIPort { * This only works on ports configured as outputs, and the behavior will * change depending on the configuration of the port. * - * This function uses the following values of errno when an error state is - * reached: - * EACCES - Another resource is currently trying to access the ADI. - * * \param value * The value to set the ADI port to * @@ -109,8 +92,7 @@ class ADIAnalogIn : private ADIPort { * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of ADI Ports. - * EACCES - Another resource is currently trying to access the ADI. + * ENXIO - The given value is not within the range of ADI Ports * * \param port * The ADI port number (from 1-8, 'a'-'h', 'A'-'H') to configure @@ -140,7 +122,7 @@ class ADIAnalogIn : private ADIPort { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the ADI. + * ENODEV - The port is not configured as an analog input * * \return The average sensor value computed by this function */ @@ -156,7 +138,7 @@ class ADIAnalogIn : private ADIPort { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the ADI. + * ENODEV - The port is not configured as an analog input * * \return The difference of the sensor value from its calibrated default from * -4095 to 4095 @@ -178,7 +160,7 @@ class ADIAnalogIn : private ADIPort { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the ADI. + * ENODEV - The port is not configured as an analog input * * \return The difference of the sensor value from its calibrated default from * -16384 to 16384 @@ -193,7 +175,7 @@ class ADIAnalogIn : private ADIPort { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the ADI. + * ENODEV - The port is not configured as an analog input * * \return The analog sensor value, where a value of 0 reflects an input * voltage of nearly 0 V and a value of 4095 reflects an input voltage of @@ -214,8 +196,7 @@ class ADIAnalogOut : private ADIPort { * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of ADI Ports. - * EACCES - Another resource is currently trying to access the ADI. + * ENXIO - The given value is not within the range of ADI Ports. * * \param port * The ADI port number (from 1-8, 'a'-'h', 'A'-'H') to configure @@ -232,7 +213,7 @@ class ADIAnalogOut : private ADIPort { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the ADI. + * ENODEV - The port is not configured as an analog output * * \param value * The value to set the ADI port to @@ -250,8 +231,7 @@ class ADIDigitalOut : private ADIPort { * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of ADI Ports. - * EACCES - Another resource is currently trying to access the ADI. + * ENXIO - The given value is not within the range of ADI Ports. * * \param port * The ADI port number (from 1-8, 'a'-'h', 'A'-'H') to configure @@ -268,7 +248,7 @@ class ADIDigitalOut : private ADIPort { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the ADI. + * ENODEV - The port is not configured as a digital output * * \param value * The value to set the ADI port to @@ -286,8 +266,7 @@ class ADIDigitalIn : private ADIPort { * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of ADI Ports. - * EACCES - Another resource is currently trying to access the ADI. + * ENXIO - The given value is not within the range of ADI Ports. * * \param port * The ADI port number (from 1-8, 'a'-'h', 'A'-'H') to configure @@ -309,7 +288,7 @@ class ADIDigitalIn : private ADIPort { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the ADI. + * ENODEV - The port is not configured as a digital input * * \return 1 if the button is pressed and had not been pressed the last time * this function was called, 0 otherwise. @@ -321,7 +300,7 @@ class ADIDigitalIn : private ADIPort { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the ADI. + * ENODEV - The port is not configured as a digital input * * \return The value stored for the given port */ @@ -337,8 +316,7 @@ class ADIMotor : private ADIPort { * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of ADI Ports. - * EACCES - Another resource is currently trying to access the ADI. + * ENXIO - The given value is not within the range of ADI Ports. * * \param port * The ADI port number (from 1-8, 'a'-'h', 'A'-'H') to configure @@ -352,7 +330,7 @@ class ADIMotor : private ADIPort { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the ADI. + * ENODEV - The port is not configured as a motor * * \return 1 if the operation was successful or PROS_ERR if the operation * failed, setting errno. @@ -364,7 +342,7 @@ class ADIMotor : private ADIPort { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the ADI. + * ENODEV - The port is not configured as a motor * * \param value * The new signed speed; -127 is full reverse and 127 is full forward, @@ -380,7 +358,7 @@ class ADIMotor : private ADIPort { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the ADI. + * ENODEV - The port is not configured as a motor * * \return The last set speed of the motor on the given port */ @@ -394,8 +372,7 @@ class ADIEncoder : private ADIPort { * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of ADI Ports. - * EACCES - Another resource is currently trying to access the ADI. + * ENXIO - The given value is not within the range of ADI Ports. * * \param port_top * The "top" wire from the encoder sensor with the removable cover side @@ -415,7 +392,7 @@ class ADIEncoder : private ADIPort { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the ADI. + * ENODEV - The port is not configured as a motor * * \return 1 if the operation was successful or PROS_ERR if the operation * failed, setting errno. @@ -429,7 +406,7 @@ class ADIEncoder : private ADIPort { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the ADI. + * ENODEV - The port is not configured as a motor * * \return The signed and cumulative number of counts since the last start or * reset @@ -444,8 +421,7 @@ class ADIUltrasonic : private ADIPort { * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of ADI Ports. - * EACCES - Another resource is currently trying to access the ADI. + * ENXIO - The given value is not within the range of ADI Ports. * * \param port_ping * The port connected to the orange OUTPUT cable. This should be in the @@ -465,7 +441,7 @@ class ADIUltrasonic : private ADIPort { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the ADI. + * ENODEV - The port is not configured as an ultrasonic * * \return The distance to the nearest object in m^-4 (10000 indicates 1 * meter), measured from the sensor's mounting points. @@ -488,8 +464,7 @@ class ADIGyro : private ADIPort { * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of ADI Ports - * EACCES - Another resource is currently trying to access the ADI. + * ENXIO - The given value is not within the range of ADI Ports * * \param port * The ADI port to initialize as a gyro (from 1-8, 'a'-'h', 'A'-'H') @@ -511,7 +486,7 @@ class ADIGyro : private ADIPort { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the ADI. + * ENODEV - The port is not configured as a gyro * * \return The gyro angle in degrees. */ @@ -522,7 +497,7 @@ class ADIGyro : private ADIPort { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the ADI. + * ENODEV - The port is not configured as a gyro * * \return 1 if the operation was successful or PROS_ERR if the operation * failed, setting errno. diff --git a/include/pros/apix.h b/include/pros/apix.h index 1e8597c83..ca278b4de 100644 --- a/include/pros/apix.h +++ b/include/pros/apix.h @@ -384,7 +384,7 @@ typedef enum v5_device_e { * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21), or a + * ENXIO - The given value is not within the range of V5 ports (1-21), or a * a different device than specified is plugged in. * EADDRINUSE - The port is already registered to another device. * @@ -404,7 +404,7 @@ int registry_bind_port(uint8_t port, v5_device_e_t device_type); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). + * ENXIO - The given value is not within the range of V5 ports (1-21). * * \param port * The port number to deregister diff --git a/include/pros/motors.h b/include/pros/motors.h index b1e55ba17..364f8d830 100644 --- a/include/pros/motors.h +++ b/include/pros/motors.h @@ -43,8 +43,8 @@ namespace c { * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -67,8 +67,8 @@ int32_t motor_move(uint8_t port, int32_t voltage); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -95,8 +95,8 @@ int32_t motor_move_absolute(uint8_t port, const double position, const int32_t v * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -121,8 +121,8 @@ int32_t motor_move_relative(uint8_t port, const double position, const int32_t v * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -140,8 +140,8 @@ int32_t motor_move_velocity(uint8_t port, const int32_t velocity); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -160,8 +160,8 @@ int32_t motor_move_voltage(uint8_t port, const int32_t voltage); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -179,8 +179,8 @@ int32_t motor_modify_profiled_velocity(uint8_t port, const int32_t velocity); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -195,8 +195,8 @@ double motor_get_target_position(uint8_t port); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -217,8 +217,8 @@ int32_t motor_get_target_velocity(uint8_t port); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -233,8 +233,8 @@ double motor_get_actual_velocity(uint8_t port); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -249,8 +249,8 @@ int32_t motor_get_current_draw(uint8_t port); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -269,8 +269,8 @@ int32_t motor_get_direction(uint8_t port); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -285,8 +285,8 @@ double motor_get_efficiency(uint8_t port); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -301,8 +301,8 @@ int32_t motor_is_over_current(uint8_t port); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -382,8 +382,8 @@ namespace c { * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -428,8 +428,8 @@ namespace c { * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -443,8 +443,8 @@ uint32_t motor_get_flags(uint8_t port); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -463,8 +463,8 @@ int32_t motor_get_raw_position(uint8_t port, uint32_t* const timestamp); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -479,8 +479,8 @@ double motor_get_position(uint8_t port); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -495,8 +495,8 @@ double motor_get_power(uint8_t port); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -511,8 +511,8 @@ double motor_get_temperature(uint8_t port); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -527,8 +527,8 @@ double motor_get_torque(uint8_t port); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -656,8 +656,8 @@ namespace c { * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -674,8 +674,8 @@ int32_t motor_set_zero_position(uint8_t port, const double position); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -690,8 +690,8 @@ int32_t motor_tare_position(uint8_t port); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -708,8 +708,8 @@ int32_t motor_set_brake_mode(uint8_t port, const motor_brake_mode_e_t mode); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -726,8 +726,8 @@ int32_t motor_set_current_limit(uint8_t port, const int32_t limit); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -744,8 +744,8 @@ int32_t motor_set_encoder_units(uint8_t port, const motor_encoder_units_e_t unit * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -766,8 +766,8 @@ int32_t motor_set_gearing(uint8_t port, const motor_gearset_e_t gearset); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param kf * The feedforward constant @@ -791,8 +791,8 @@ motor_pid_s_t motor_convert_pid(double kf, double kp, double ki, double kd); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param kf * The feedforward constant @@ -828,8 +828,8 @@ motor_pid_full_s_t motor_convert_pid_full(double kf, double kp, double ki, doubl * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -851,8 +851,8 @@ int32_t motor_set_pos_pid(uint8_t port, const motor_pid_s_t pid); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -875,8 +875,8 @@ int32_t motor_set_pos_pid_full(uint8_t port, const motor_pid_full_s_t pid); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -898,8 +898,8 @@ int32_t motor_set_vel_pid(uint8_t port, const motor_pid_s_t pid); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -918,8 +918,8 @@ int32_t motor_set_vel_pid_full(uint8_t port, const motor_pid_full_s_t pid); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -936,8 +936,8 @@ int32_t motor_set_reversed(uint8_t port, const bool reverse); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -954,8 +954,8 @@ int32_t motor_set_voltage_limit(uint8_t port, const int32_t limit); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -972,8 +972,8 @@ motor_brake_mode_e_t motor_get_brake_mode(uint8_t port); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -988,8 +988,8 @@ int32_t motor_get_current_limit(uint8_t port); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -1004,8 +1004,8 @@ motor_encoder_units_e_t motor_get_encoder_units(uint8_t port); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -1022,8 +1022,8 @@ motor_gearset_e_t motor_get_gearing(uint8_t port); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * Additionally, in an error state all values of the returned struct are set * to their negative maximum values. @@ -1043,8 +1043,8 @@ motor_pid_full_s_t motor_get_pos_pid(uint8_t port); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * Additionally, in an error state all values of the returned struct are set * to their negative maximum values. @@ -1062,8 +1062,8 @@ motor_pid_full_s_t motor_get_vel_pid(uint8_t port); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -1081,8 +1081,8 @@ int32_t motor_is_reversed(uint8_t port); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 diff --git a/include/pros/motors.hpp b/include/pros/motors.hpp index 40dac7d03..d2dbc15a1 100644 --- a/include/pros/motors.hpp +++ b/include/pros/motors.hpp @@ -30,8 +30,8 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -67,7 +67,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \param voltage * The new motor voltage from -127 to 127 @@ -86,7 +86,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \param voltage * The new motor voltage from -127 to 127 @@ -108,7 +108,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \param position * The absolute position to move to in the motor's encoder units @@ -133,7 +133,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \param position * The relative position to move to in the motor's encoder units @@ -156,7 +156,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \param velocity * The new motor velocity from -+-100, +-200, or +-600 depending on the @@ -172,7 +172,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -191,8 +191,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \param velocity * The new motor velocity from +-100, +-200, or +-600 depending on the @@ -208,7 +207,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \return The target position in its encoder units or PROS_ERR_F if the * operation failed, setting errno. @@ -220,7 +219,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \return The commanded motor velocity from +-100, +-200, or +-600, or * PROS_ERR if the operation failed, setting errno. @@ -238,7 +237,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \return The motor's actual velocity in RPM or PROS_ERR_F if the operation * failed, setting errno. @@ -250,7 +249,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \return The motor's current in mA or PROS_ERR if the operation failed, * setting errno. @@ -262,7 +261,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \return 1 for moving in the positive direction, -1 for moving in the * negative direction, and PROS_ERR if the operation failed, setting errno. @@ -278,7 +277,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \return The motor's efficiency in percent or PROS_ERR_F if the operation * failed, setting errno. @@ -290,7 +289,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \return 1 if the motor's current limit is being exceeded and 0 if the * current limit is not exceeded, or PROS_ERR if the operation failed, setting @@ -301,6 +300,10 @@ class Motor { /** * Checks if the motor is stopped. * + * This function uses the following values of errno when an error state is + * reached: + * ENODEV - The port cannot be configured as a motor + * * \note Although this function forwards data from the motor, the motor * presently does not provide any value. This function returns PROS_ERR with * errno set to ENOSYS. @@ -313,6 +316,10 @@ class Motor { /** * Checks if the motor is at its zero position. * + * This function uses the following values of errno when an error state is + * reached: + * ENODEV - The port cannot be configured as a motor + * * \note Although this function forwards data from the motor, the motor * presently does not provide any value. This function returns PROS_ERR with * errno set to ENOSYS. @@ -330,7 +337,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -346,7 +353,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \param port * The V5 port number from 1-21 @@ -360,7 +367,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \param[in] timestamp * A pointer to a time in milliseconds for which the encoder count @@ -377,7 +384,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \return 1 if the temperature limit is exceeded and 0 if the temperature is * below the limit, or PROS_ERR if the operation failed, setting errno. @@ -389,7 +396,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \return The motor's absolute position in its encoder units or PROS_ERR_F * if the operation failed, setting errno. @@ -401,7 +408,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \return The motor's power draw in Watts or PROS_ERR_F if the operation * failed, setting errno. @@ -413,7 +420,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \return The motor's temperature in degrees Celsius or PROS_ERR_F if the * operation failed, setting errno. @@ -425,7 +432,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \return The motor's torque in Nm or PROS_ERR_F if the operation failed, * setting errno. @@ -437,7 +444,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \return The motor's voltage in mV or PROS_ERR_F if the operation failed, * setting errno. @@ -458,7 +465,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \param position * The new reference position in its encoder units @@ -473,7 +480,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \return 1 if the operation was successful or PROS_ERR if the operation * failed, setting errno. @@ -485,7 +492,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \param mode * The motor_brake_mode_e_t to set for the motor @@ -500,7 +507,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \param limit * The new current limit in mA @@ -515,7 +522,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \param units * The new motor encoder units @@ -530,7 +537,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \param gearset * The new motor gearset @@ -547,11 +554,6 @@ class Motor { * This function will convert the floating point values to the nearest 4.4 * value. * - * This function uses the following values of errno when an error state is - * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. - * * \param kf * The feedforward constant * \param kp @@ -572,11 +574,6 @@ class Motor { * This function will convert the floating point values to the nearest 4.4 * value. * - * This function uses the following values of errno when an error state is - * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. - * * \param kf * The feedforward constant * \param kp @@ -609,8 +606,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \param pid * The new motor PID constants @@ -628,8 +624,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \param pid * The new motor PID constants @@ -648,8 +643,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \param pid * The new motor PID constants @@ -667,8 +661,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \param pid * The new motor PID constants @@ -685,7 +678,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \param reverse * True reverses the motor, false is default @@ -700,7 +693,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \param limit * The new voltage limit in Volts @@ -715,7 +708,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \return One of motor_brake_mode_e_t, according to what was set for the * motor, or E_MOTOR_BRAKE_INVALID if the operation failed, setting errno. @@ -729,7 +722,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \return The motor's current limit in mA or PROS_ERR if the operation failed, * setting errno. @@ -741,7 +734,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \return One of motor_encoder_units_e_t according to what is set for the * motor or E_MOTOR_ENCODER_INVALID if the operation failed. @@ -753,7 +746,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \return One of motor_gearset_e_t according to what is set for the motor, * or E_GEARSET_INVALID if the operation failed. @@ -767,8 +760,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * Additionally, in an error state all values of the returned struct are set * to their negative maximum values. @@ -785,8 +777,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * Additionally, in an error state all values of the returned struct are set * to their negative maximum values. @@ -801,7 +792,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \return 1 if the motor has been reversed and 0 if the motor was not * reversed, or PROS_ERR if the operation failed, setting errno. @@ -816,7 +807,7 @@ class Motor { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a motor * * \return The motor's voltage limit in V or PROS_ERR if the operation failed, * setting errno. diff --git a/include/pros/vision.h b/include/pros/vision.h index bd0a7d791..57634d665 100644 --- a/include/pros/vision.h +++ b/include/pros/vision.h @@ -121,8 +121,8 @@ namespace c { * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a vision sensor * * \param port * The V5 port number from 1-21 @@ -167,8 +167,8 @@ vision_signature_s_t vision_signature_from_utility(const int32_t id, const int32 * * This function uses the following values of errno when an error state is * reached: - * EINVAL - Fewer than two signatures have been provided, or one of the - * signatures is out of its [1-7] range. + * EINVAL - Fewer than two signatures have been provided or one of the + * signatures is out of its [1-7] range (or 0 when omitted). * * \param port * The V5 port number from 1-21 @@ -193,8 +193,8 @@ vision_color_code_t vision_create_color_code(uint8_t port, const uint32_t sig_id * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a vision sensor * EDOM - size_id is greater than the number of available objects. * EHOSTDOWN - Reading the vision sensor failed for an unknown reason. * @@ -214,10 +214,11 @@ vision_object_s_t vision_get_by_size(uint8_t port, const uint32_t size_id); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a vision sensor + * EINVAL - sig_id is outside the range [1-8] * EDOM - size_id is greater than the number of available objects. - * EHOSTDOWN - Reading the vision sensor failed for an unknown reason. + * EAGAIN - Reading the vision sensor failed for an unknown reason. * * \param port * The V5 port number from 1-21 @@ -237,9 +238,9 @@ vision_object_s_t vision_get_by_sig(uint8_t port, const uint32_t size_id, const * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. - * EAGAIN - Reading the Vision Sensor failed for an unknown reason. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a vision sensor + * EAGAIN - Reading the vision sensor failed for an unknown reason. * * \param port * The V5 port number from 1-21 @@ -261,8 +262,8 @@ vision_object_s_t vision_get_by_code(uint8_t port, const uint32_t size_id, const * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a vision sensor * * \param port * The V5 port number from 1-21 @@ -277,8 +278,8 @@ int32_t vision_get_exposure(uint8_t port); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a vision sensor * * \param port * The V5 port number from 1-21 @@ -293,8 +294,8 @@ int32_t vision_get_object_count(uint8_t port); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a vision sensor * * \param port * The V5 port number from 1-21 @@ -318,9 +319,9 @@ int32_t vision_print_signature(const vision_signature_s_t sig); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21), or + * ENXIO - The given value is not within the range of V5 ports (1-21), or * fewer than object_count number of objects were found. - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a vision sensor * EDOM - size_id is greater than the number of available objects. * * \param port @@ -347,9 +348,9 @@ int32_t vision_read_by_size(uint8_t port, const uint32_t size_id, const uint32_t * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21), or + * ENXIO - The given value is not within the range of V5 ports (1-21), or * fewer than object_count number of objects were found. - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a vision sensor * EDOM - size_id is greater than the number of available objects. * * \param port @@ -378,9 +379,9 @@ int32_t vision_read_by_sig(uint8_t port, const uint32_t size_id, const uint32_t * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21), or + * ENXIO - The given value is not within the range of V5 ports (1-21), or * fewer than object_count number of objects were found. - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a vision sensor * * \param port * The V5 port number from 1-21 @@ -437,8 +438,9 @@ int32_t vision_set_signature(uint8_t port, const uint8_t signature_id, vision_si * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a vision sensor + * EINVAL - enable was not 0 or 1 * * \param port * The V5 port number from 1-21 @@ -457,8 +459,8 @@ int32_t vision_set_auto_white_balance(uint8_t port, const uint8_t enable); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a vision sensor * * \param port * The V5 port number from 1-21 @@ -475,8 +477,8 @@ int32_t vision_set_exposure(uint8_t port, const uint8_t exposure); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a vision sensor * * \param port * The V5 port number from 1-21 @@ -493,8 +495,8 @@ int32_t vision_set_led(uint8_t port, const int32_t rgb); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a vision sensor * * \param port * The V5 port number from 1-21 @@ -515,8 +517,8 @@ int32_t vision_set_white_balance(uint8_t port, const int32_t rgb); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). - * EACCES - Another resource is currently trying to access the port. + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a vision sensor * * \param port * The V5 port number from 1-21 @@ -533,7 +535,7 @@ int32_t vision_set_zero_point(uint8_t port, vision_zero_e_t zero_point); * * This functions uses the following values of errno when an error state is * reached: - * EINVAL - The given port is not within the range of V5 ports (1-21) + * ENXIO - The given port is not within the range of V5 ports (1-21) * EACCESS - Anothe resources is currently trying to access the port * * \param port diff --git a/include/pros/vision.hpp b/include/pros/vision.hpp index cf06e10fa..4c8680e5b 100644 --- a/include/pros/vision.hpp +++ b/include/pros/vision.hpp @@ -30,6 +30,11 @@ class Vision { /** * Create a Vision Sensor object on the given port. * + * This function uses the following values of errno when an error state is + * reached: + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a vision sensor + * * \param port * The V5 port number from 1-21 * \param zero_point @@ -43,7 +48,7 @@ class Vision { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a vision sensor * * \return 1 if the operation was successful or PROS_ERR if the operation * failed, setting errno. @@ -86,8 +91,8 @@ class Vision { * * This function uses the following values of errno when an error state is * reached: - * EINVAL - Fewer than two signatures have been provided, or one of the - * signatures is out of its [1-7] range. + * EINVAL - Fewer than two signatures have been provided or one of the + * signatures is out of its [1-7] range (or 0 when omitted). * * \param sig_id1 * The first signature id [1-7] to add to the color code @@ -111,9 +116,9 @@ class Vision { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a vision sensor * EDOM - size_id is greater than the number of available objects. - * EHOSTDOWN - Reading the vision sensor failed for an unknown reason. + * EAGAIN - Reading the vision sensor failed for an unknown reason. * * \param size_id * The object to read from a list roughly ordered by object size @@ -129,9 +134,10 @@ class Vision { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a vision sensor * EDOM - size_id is greater than the number of available objects. - * EHOSTDOWN - Reading the vision sensor failed for an unknown reason. + * EINVAL - sig_id is outside the range [1-8] + * EAGAIN - Reading the vision sensor failed for an unknown reason. * * \param size_id * The object to read from a list roughly ordered by object size @@ -150,7 +156,7 @@ class Vision { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a vision sensor * EAGAIN - Reading the Vision Sensor failed for an unknown reason. * * \param size_id @@ -171,7 +177,7 @@ class Vision { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a vision sensor * * \return The current exposure parameter from [0,150], * PROS_ERR if an error occurred @@ -183,7 +189,7 @@ class Vision { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a vision sensor * * \return The number of objects detected on the specified vision sensor. * Returns PROS_ERR if the port was invalid or an error occurred. @@ -193,6 +199,10 @@ class Vision { /** * Gets the object detection signature with the given id number. * + * This function uses the following values of errno when an error state is + * reached: + * ENODEV - The port cannot be configured as a vision sensor + * * \param signature_id * The signature id to read * @@ -205,7 +215,7 @@ class Vision { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a vision sensor * * \return The current RGB white balance setting of the sensor */ @@ -216,8 +226,9 @@ class Vision { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a vision sensor * EDOM - size_id is greater than the number of available objects. + * EAGAIN - Reading the vision sensor failed for an unknown reason. * * \param size_id * The object to read from a list roughly ordered by object size @@ -241,9 +252,10 @@ class Vision { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a vision sensor * EDOM - size_id is greater than the number of available objects. - * EHOSTDOWN - Reading the vision sensor failed for an unknown reason. + * EINVAL - sig_id is outside the range [1-8] + * EAGAIN - Reading the vision sensor failed for an unknown reason. * * \param object_count * The number of objects to read @@ -270,8 +282,9 @@ class Vision { * * This function uses the following values of errno when an error state is * reached: - * EINVAL - Fewer than object_count number of objects were found. - * EACCES - Another resource is currently trying to access the port. + * EDOM - size_id is greater than the number of available objects. + * ENODEV - The port cannot be configured as a vision sensor + * EAGAIN - Reading the vision sensor failed for an unknown reason. * * \param object_count * The number of objects to read @@ -307,7 +320,7 @@ class Vision { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a vision sensor * * \param enabled * Pass 0 to disable, 1 to enable @@ -324,7 +337,7 @@ class Vision { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a vision sensor * * \param percent * The new exposure setting from [0,150]. @@ -339,7 +352,7 @@ class Vision { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a vision sensor * * \param rgb * An RGB code to set the LED to @@ -355,6 +368,11 @@ class Vision { * NOTE: This saves the signature in volatile memory, and the signature will be * lost as soon as the sensor is powered down. * + * This function uses the following values of errno when an error state is + * reached: + * ENODEV - The port cannot be configured as a vision sensor + * EINVAL - sig_id is outside the range [1-8] + * * \param signature_id * The signature id to store into * \param[in] signature_ptr @@ -369,7 +387,7 @@ class Vision { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a vision sensor * * \param rgb * The new RGB white balance setting of the sensor @@ -388,7 +406,7 @@ class Vision { * * This function uses the following values of errno when an error state is * reached: - * EACCES - Another resource is currently trying to access the port. + * ENODEV - The port cannot be configured as a vision sensor * * \param zero_point * One of vision_zero_e_t to set the (0,0) coordinate for the FOV @@ -403,8 +421,7 @@ class Vision { * * This functions uses the following values of errno when an error state is * reached: - * EINVAL - The given port is not within the range of V5 ports (1-21) - * EACCESS - Anothe resources is currently trying to access the port + * ENODEV - The port cannot be configured as a vision sensor * * \param enable * Disable Wi-Fi on the Vision sensor if 0, enable otherwise (e.g. 1) diff --git a/include/v5_api.h b/include/v5_api.h new file mode 100644 index 000000000..3298ac1f3 --- /dev/null +++ b/include/v5_api.h @@ -0,0 +1,310 @@ +/*----------------------------------------------------------------------------*/ +/* */ +/* Copyright (c) Innovation First 2016, All rights reserved. */ +/* */ +/* Module: v5_api.h */ +/* Author: James Pearman */ +/* Created: 8 Nov 2016 */ +/* */ +/* Revisions: V0.1 */ +/* */ +/*----------------------------------------------------------------------------*/ + +#ifndef V5_API_H_ +#define V5_API_H_ + +#include "stdint.h" +#include "stdbool.h" +#include "stdarg.h" + +/*-----------------------------------------------------------------------------*/ +/** @file v5_api.h + * @brief Header for V5 API +*//*---------------------------------------------------------------------------*/ + +#include "v5_apitypes.h" +#include "v5_apiuser.h" +#include "v5_color.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*----------------------------------------------------------------------------*/ +/* jumptable public API */ +/*----------------------------------------------------------------------------*/ +// +// These are the raw jumptable wrapper function prototypes +// Many are used directly, others are further wrapped in a simpler API allowing +// access via V5 port number rather than a device pointer. +// see v5_apiuser.h for these functions +// + +// simple background processing +void vexBackgroundProcessing( void ); + +// Console output +int32_t vexDebug( char const *fmt, ... ); +int32_t vex_printf( char const *fmt, ... ); +int32_t vex_sprintf ( char *out, const char *format, ... ); +int32_t vex_snprintf( char *out, uint32_t max_len, const char *format, ... ); +int32_t vex_vsprintf( char *out, const char *format, va_list args ); +int32_t vex_vsnprintf( char *out, uint32_t max_len, const char *format, va_list args ); + +// system +uint32_t vexSystemTimeGet( void ); +void vexGettime( struct time *pTime ); +void vexGetdate( struct date *pDate ); +void vexSystemMemoryDump( void ); +void vexSystemDigitalIO( uint32_t pin, uint32_t value ); +uint32_t vexSystemStartupOptions(void); +void vexSystemExitRequest(void); +uint64_t vexSystemHighResTimeGet( void ); +uint64_t vexSystemPowerupTimeGet( void ); +uint32_t vexSystemLinkAddrGet( void ); +uint32_t vexSystemUsbStatus( void ); + +// Generic device +uint32_t vexDevicesGetNumber( void ); +uint32_t vexDevicesGetNumberByType( V5_DeviceType type ); +V5_DeviceT vexDevicesGet( void ); +V5_DeviceT vexDeviceGetByIndex( uint32_t index ); +int32_t vexDeviceGetStatus( V5_DeviceType *buffer ); + +// This is used by the port index functions to map an index to the device pointer +#define VEX_DEVICE_GET(device, index) V5_DeviceT device = vexDeviceGetByIndex( index ) + +// Controller +int32_t vexControllerGet( V5_ControllerId id, V5_ControllerIndex index ); +V5_ControllerStatus vexControllerConnectionStatusGet( V5_ControllerId id ); +bool vexControllerTextSet( V5_ControllerId id, uint32_t line, uint32_t col, const char *str ); + +// LED sensor +void vexDeviceLedSet( V5_DeviceT device, V5_DeviceLedColor value ); +void vexDeviceLedRgbSet( V5_DeviceT device, uint32_t color ); +V5_DeviceLedColor vexDeviceLedGet( V5_DeviceT device ); +uint32_t vexDeviceLedRgbGet( V5_DeviceT device ); + +// ADI sensor +void vexDeviceAdiPortConfigSet( V5_DeviceT device, uint32_t port, V5_AdiPortConfiguration type ); +V5_AdiPortConfiguration vexDeviceAdiPortConfigGet( V5_DeviceT device, uint32_t port ); +void vexDeviceAdiValueSet( V5_DeviceT device, uint32_t port, int32_t value ); +int32_t vexDeviceAdiValueGet( V5_DeviceT device, uint32_t port ); + +// Bumper switch +V5_DeviceBumperState vexDeviceBumperGet( V5_DeviceT device ); + +// Gyro - obsolete, there is currently no dedicated gyro +void vexDeviceGyroReset( V5_DeviceT device ); +double vexDeviceGyroHeadingGet( V5_DeviceT device ); +double vexDeviceGyroDegreesGet( V5_DeviceT device ); + +// Sonar - obsolete, there is currently no dedicated gyro +int32_t vexDeviceSonarValueGet( V5_DeviceT device ); + +// Generic sensor - (who knows !) +int32_t vexDeviceGenericValueGet( V5_DeviceT device ); + +// Motor +void vexDeviceMotorVelocitySet( V5_DeviceT device, int32_t velocity ); +void vexDeviceMotorVelocityUpdate( V5_DeviceT device, int32_t velocity ); +void vexDeviceMotorVoltageSet( V5_DeviceT device, int32_t value ); +int32_t vexDeviceMotorVelocityGet( V5_DeviceT device ); +double vexDeviceMotorActualVelocityGet( V5_DeviceT device ); +int32_t vexDeviceMotorDirectionGet( V5_DeviceT device ); +void vexDeviceMotorModeSet( V5_DeviceT device, V5MotorControlMode mode ); +V5MotorControlMode vexDeviceMotorModeGet( V5_DeviceT device ); +void vexDeviceMotorPwmSet( V5_DeviceT device, int32_t value ); +int32_t vexDeviceMotorPwmGet( V5_DeviceT device ); +void vexDeviceMotorCurrentLimitSet( V5_DeviceT device, int32_t value ); +int32_t vexDeviceMotorCurrentLimitGet( V5_DeviceT device ); +void vexDeviceMotorVoltageLimitSet( V5_DeviceT device, int32_t value ); +int32_t vexDeviceMotorVoltageLimitGet( V5_DeviceT device ); +void vexDeviceMotorPositionPidSet( V5_DeviceT device, V5_DeviceMotorPid *pid ); +void vexDeviceMotorVelocityPidSet( V5_DeviceT device, V5_DeviceMotorPid *pid ); +int32_t vexDeviceMotorCurrentGet( V5_DeviceT device ); +int32_t vexDeviceMotorVoltageGet( V5_DeviceT device ); +double vexDeviceMotorPowerGet( V5_DeviceT device ); +double vexDeviceMotorTorqueGet( V5_DeviceT device ); +double vexDeviceMotorEfficiencyGet( V5_DeviceT device ); +double vexDeviceMotorTemperatureGet( V5_DeviceT device ); +bool vexDeviceMotorOverTempFlagGet( V5_DeviceT device ); +bool vexDeviceMotorCurrentLimitFlagGet( V5_DeviceT device ); +uint32_t vexDeviceMotorFaultsGet( V5_DeviceT device ); +bool vexDeviceMotorZeroVelocityFlagGet( V5_DeviceT device ); +bool vexDeviceMotorZeroPositionFlagGet( V5_DeviceT device ); +uint32_t vexDeviceMotorFlagsGet( V5_DeviceT device ); +void vexDeviceMotorReverseFlagSet( V5_DeviceT device, bool value ); +bool vexDeviceMotorReverseFlagGet( V5_DeviceT device ); +void vexDeviceMotorEncoderUnitsSet( V5_DeviceT device, V5MotorEncoderUnits units ); +V5MotorEncoderUnits vexDeviceMotorEncoderUnitsGet( V5_DeviceT device ); +void vexDeviceMotorBrakeModeSet( V5_DeviceT device, V5MotorBrakeMode mode ); +V5MotorBrakeMode vexDeviceMotorBrakeModeGet( V5_DeviceT device ); +void vexDeviceMotorPositionSet( V5_DeviceT device, double position ); +double vexDeviceMotorPositionGet( V5_DeviceT device ); +int32_t vexDeviceMotorPositionRawGet( V5_DeviceT device, uint32_t *timestamp ); +void vexDeviceMotorPositionReset( V5_DeviceT device ); +double vexDeviceMotorTargetGet( V5_DeviceT device ); +void vexDeviceMotorServoTargetSet( V5_DeviceT device, double position ); +void vexDeviceMotorAbsoluteTargetSet( V5_DeviceT device, double position, int32_t velocity ); +void vexDeviceMotorRelativeTargetSet( V5_DeviceT device, double position, int32_t velocity ); +void vexDeviceMotorGearingSet( V5_DeviceT device, V5MotorGearset value ); +V5MotorGearset vexDeviceMotorGearingGet( V5_DeviceT device ); + +// Vision sensor +void vexDeviceVisionModeSet( V5_DeviceT device, V5VisionMode mode ); +V5VisionMode vexDeviceVisionModeGet( V5_DeviceT device ); +int32_t vexDeviceVisionObjectCountGet( V5_DeviceT device ); +int32_t vexDeviceVisionObjectGet( V5_DeviceT device, uint32_t indexObj, V5_DeviceVisionObject *pObject ); +void vexDeviceVisionSignatureSet( V5_DeviceT device, V5_DeviceVisionSignature *pSignature ); +bool vexDeviceVisionSignatureGet( V5_DeviceT device, uint32_t id, V5_DeviceVisionSignature *pSignature ); +void vexDeviceVisionBrightnessSet( V5_DeviceT device, uint8_t percent ); +uint8_t vexDeviceVisionBrightnessGet( V5_DeviceT device ); +void vexDeviceVisionWhiteBalanceModeSet( V5_DeviceT device, V5VisionWBMode mode ); +V5VisionWBMode vexDeviceVisionWhiteBalanceModeGet( V5_DeviceT device ); +void vexDeviceVisionWhiteBalanceSet( V5_DeviceT device, V5_DeviceVisionRgb color ); +V5_DeviceVisionRgb vexDeviceVisionWhiteBalanceGet( V5_DeviceT device ); +void vexDeviceVisionLedModeSet( V5_DeviceT device, V5VisionLedMode mode ); +V5VisionLedMode vexDeviceVisionLedModeGet( V5_DeviceT device ); +void vexDeviceVisionLedBrigntnessSet( V5_DeviceT device, uint8_t percent ); +uint8_t vexDeviceVisionLedBrigntnessGet( V5_DeviceT device ); +void vexDeviceVisionLedColorSet( V5_DeviceT device, V5_DeviceVisionRgb color); +V5_DeviceVisionRgb vexDeviceVisionLedColorGet( V5_DeviceT device ); +void vexDeviceVisionWifiModeSet( V5_DeviceT device, V5VisionWifiMode mode ); +V5VisionWifiMode vexDeviceVisionWifiModeGet( V5_DeviceT device ); + +// IMU - actual API to be determined +void vexDeviceImuReset( V5_DeviceT device ); +double vexDeviceImuHeadingGet( V5_DeviceT device ); +double vexDeviceImuDegreesGet( V5_DeviceT device ); + +// Rangefinder/Lidar - actual API to be determined +int32_t vexDeviceRangeValueGet( V5_DeviceT device ); + +// Generic serial port comms to any device +void vexDeviceGenericSerialEnable( V5_DeviceT device, int32_t options ); +void vexDeviceGenericSerialBaudrate( V5_DeviceT device, int32_t baudrate ); +int32_t vexDeviceGenericSerialWriteChar( V5_DeviceT device, uint8_t c ); +int32_t vexDeviceGenericSerialWriteFree( V5_DeviceT device ); +int32_t vexDeviceGenericSerialTransmit( V5_DeviceT device, uint8_t *buffer, int32_t length ); +int32_t vexDeviceGenericSerialReadChar( V5_DeviceT device ); +int32_t vexDeviceGenericSerialPeekChar( V5_DeviceT device ); +int32_t vexDeviceGenericSerialReceiveAvail( V5_DeviceT device ); +int32_t vexDeviceGenericSerialReceive( V5_DeviceT device, uint8_t *buffer, int32_t length ); +void vexDeviceGenericSerialFlush( V5_DeviceT device ); + +// Display/graphics +void vexDisplayForegroundColor( uint32_t col ); +void vexDisplayBackgroundColor( uint32_t col ); +uint32_t vexDisplayForegroundColorGet( void ); +uint32_t vexDisplayBackgroundColorGet( void ); +void vexDisplayErase(void); +void vexDisplayScroll( int32_t nStartLine, int32_t nLines ); +void vexDisplayScrollRect( int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t nLines ); +void vexDisplayCopyRect( int32_t x1, int32_t y1, int32_t x2, int32_t y2, uint32_t *pSrc, int32_t srcStride ); +void vexDisplayPixelSet( uint32_t x, uint32_t y ); +void vexDisplayPixelClear( uint32_t x, uint32_t y ); +void vexDisplayLineDraw( int32_t x1, int32_t y1, int32_t x2, int32_t y2 ); +void vexDisplayLineClear( int32_t x1, int32_t y1, int32_t x2, int32_t y2 ); +void vexDisplayRectDraw( int32_t x1, int32_t y1, int32_t x2, int32_t y2 ); +void vexDisplayRectClear( int32_t x1, int32_t y1, int32_t x2, int32_t y2 ); +void vexDisplayRectFill( int32_t x1, int32_t y1, int32_t x2, int32_t y2 ); +void vexDisplayCircleDraw( int32_t xc, int32_t yc, int32_t radius ); +void vexDisplayCircleClear( int32_t xc, int32_t yc, int32_t radius ); +void vexDisplayCircleFill( int32_t xc, int32_t yc, int32_t radius ); + +void vexDisplayPrintf( int32_t xpos, int32_t ypos, uint32_t bOpaque, const char *format, ... ); +void vexDisplayString( const int32_t nLineNumber, const char *format, ... ); +void vexDisplayStringAt( int32_t xpos, int32_t ypos, const char *format, ... ); +void vexDisplayBigString( const int32_t nLineNumber, const char *format, ... ); +void vexDisplayBigStringAt( int32_t xpos, int32_t ypos, const char *format, ... ); +void vexDisplaySmallStringAt( int32_t xpos, int32_t ypos, const char *format, ... ); +void vexDisplayCenteredString( const int32_t nLineNumber, const char *format, ...); +void vexDisplayBigCenteredString( const int32_t nLineNumber, const char *format, ...); + +// Not really for user code but we need these for some wrapper functions +void vexDisplayVPrintf( int32_t xpos, int32_t ypos, uint32_t bOpaque, const char *format, va_list args ); +void vexDisplayVString( const int32_t nLineNumber, const char *format, va_list args ); +void vexDisplayVStringAt( int32_t xpos, int32_t ypos, const char *format, va_list args ); +void vexDisplayVBigString( const int32_t nLineNumber, const char *format, va_list args); +void vexDisplayVBigStringAt( int32_t xpos, int32_t ypos, const char *format, va_list args ); +void vexDisplayVSmallStringAt( int32_t xpos, int32_t ypos, const char *format, va_list args ); +void vexDisplayVCenteredString( const int32_t nLineNumber, const char *format, va_list args ); +void vexDisplayVBigCenteredString( const int32_t nLineNumber, const char *format, va_list args ); + +void vexDisplayTextSize( uint32_t n, uint32_t d ); +void vexDisplayFontNamedSet( const char *pFontName ); +int32_t vexDisplayStringWidthGet( const char *pString ); +int32_t vexDisplayStringHeightGet( const char *pString ); + +bool vexDisplayRender( bool bVsyncWait, bool bRunScheduler ); +void vexDisplayDoubleBufferDisable(void); + +// SD card +FRESULT vexFileMountSD( void ); +FRESULT vexFileDirectoryGet( const char *path, char *buffer, uint32_t len ); +FIL *vexFileOpen(const char *filename, const char *mode ); +FIL *vexFileOpenWrite(const char *filename); +FIL *vexFileOpenCreate(const char *filename); +void vexFileClose(FIL *fdp); +int32_t vexFileRead( char *buf, uint32_t size, uint32_t nItems, FIL *fdp ); +int32_t vexFileWrite( char *buf, uint32_t size, uint32_t nItems, FIL *fdp ); +int32_t vexFileSize( FIL *fdp ); +FRESULT vexFileSeek( FIL *fdp, uint32_t offset, int32_t whence ); +bool vexFileDriveStatus( uint32_t drive ); +int32_t vexFileTell( FIL *fdp ); + +// CDC +int32_t vexSerialWriteChar( uint32_t channel, uint8_t c ); +int32_t vexSerialWriteBuffer( uint32_t channel, uint8_t *data, uint32_t data_len ); +int32_t vexSerialReadChar( uint32_t channel ); +int32_t vexSerialPeekChar( uint32_t channel ); +void vexSerialEnableRemoteConsole( void ); +int32_t vexSerialWriteFree( uint32_t channel ); + +// rtos hooks +void vexSystemTimerStop(); +void vexSystemTimerClearInterrupt(); +int32_t vexSystemTimerReinitForRtos( uint32_t priority, void (*handler)(void *data) ); +void vexSystemApplicationIRQHandler( uint32_t ulICCIAR ); +int32_t vexSystemWatchdogReinitRtos( void ); +uint32_t vexSystemWatchdogGet( void ); + +// Hooks into the interrupt system, some of these will be used by FreeRTOS +// the others are just placeholders for now +void vexSystemBoot( void ); +void vexSystemUndefinedException( void ); +void vexSystemFIQInterrupt( void ); +void vexSystemIQRQnterrupt( void ); +void vexSystemSWInterrupt( void ); +void vexSystemDataAbortInterrupt( void ); +void vexSystemPrefetchAbortInterrupt( void ); + +// touch +void vexTouchUserCallbackSet(void (* callback)(V5_TouchEvent, int32_t, int32_t)); +bool vexTouchDataGet( V5_TouchStatus *status ); + +// system utility +uint32_t vexSystemVersion( void ); +uint32_t vexStdlibVersion( void ); +// get SDK version +uint32_t vexSdkVersion( void ); + +// duplication of prototypes in v5_util.h for use by user code +uint32_t vexStdlibVersionLinked( void ); +bool vexStdlibVersionVerify( void ); + +// comp status +uint32_t vexCompetitionStatus( void ); +void vexCompetitionControl( uint32_t data ); + +// battery +int32_t vexBatteryVoltageGet( void ); +int32_t vexBatteryCurrentGet( void ); +double vexBatteryTemperatureGet( void ); +double vexBatteryCapacityGet( void ); + +#ifdef __cplusplus +} +#endif +#endif /* V5_API_H_*/ diff --git a/include/v5_apitypes.h b/include/v5_apitypes.h new file mode 100644 index 000000000..c49674cba --- /dev/null +++ b/include/v5_apitypes.h @@ -0,0 +1,446 @@ +/*----------------------------------------------------------------------------*/ +/* */ +/* Copyright (c) Innovation First 2016, All rights reserved. */ +/* */ +/* Module: v5_apitypes.h */ +/* Author: James Pearman */ +/* Created: 8 Nov 2016 */ +/* */ +/* Revisions: V0.1 */ +/* */ +/*----------------------------------------------------------------------------*/ + +#ifndef V5_APITYPES_H_ +#define V5_APITYPES_H_ + +#include "stdint.h" +#include "stdbool.h" + +/*-----------------------------------------------------------------------------*/ +/** @file v5_apitypes.h + * @brief Header for V5 API - type definitions +*//*---------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/*----------------------------------------------------------------------------*/ +/** @brief Code signature */ +/*----------------------------------------------------------------------------*/ +/** @details + * The first 16 bytes of a user code binary should contain the user code + * signature. For simple user code programs this will be created by the + * startup code in the runtime library, certain types of user code, + * for example a virtual machine, may override the default settings to cause + * the V5 system code to enable custom functionality yet TBD. + * + * to override the default use a definition like this in one of the user + * code source files. + * + * __attribute__ ((section (".boot_data"))) vcodesig vexCodeSig = + * { V5_SIG_MAGIC, + * V5_SIG_TYPE_USER, + * V5_SIG_OWNER_VEX, + * V5_SIG_OPTIONS_NONE + * }; + * + * V5_SIG_MAGIC must be set, other fields and their behavior are TBD + * + * vexCodeSig is defined as "weak" and this definition will override it. + */ +typedef struct __attribute__ ((packed)) _vcodesig { + uint32_t magic; // Magic, must be 'VXV5' 0x35565856 le + uint32_t type; // program type + uint32_t owner; // program originator + uint32_t options; // program options +} vcodesig ; + +// +#define V5_SIG_MAGIC 0x35585658 +#define V5_SIG_TYPE_USER 0 +#define V5_SIG_OWNER_SYS 0 +#define V5_SIG_OWNER_VEX 1 +#define V5_SIG_OWNER_PARTNER 2 +#define V5_SIG_OPTIONS_NONE 0 +#define V5_SIG_OPTIONS_INDG (1 << 0) // Invert default graphics colors +#define V5_SIG_OPTIONS_EXIT (1 << 1) // Kill threads when main exits +#define V5_SIG_OPTIONS_THDG (1 << 2) // Invert graphics based on theme + +#define V5_CODE_SIG( type, owner, options ) \ +vcodesig vexCodeSig __attribute__ ((section (".boot_data"))) = \ + { V5_SIG_MAGIC, type, owner, options }; + +/*----------------------------------------------------------------------------*/ +/** @brief Structures used by system time functions */ +/*----------------------------------------------------------------------------*/ + +// Time +struct time { + uint8_t ti_hour; /// Hours + uint8_t ti_min; /// Minutes + uint8_t ti_sec; /// Seconds + uint8_t ti_hund; /// Hundredths of seconds +}; + +// Time +struct date { + uint16_t da_year; /// Year - 1980 + uint8_t da_day; /// Day of the month + uint8_t da_mon; /// Month (1 = Jan) +}; +// DEVICE IDs + +/*----------------------------------------------------------------------------*/ +/** @brief V5 Device type definitions */ +/*----------------------------------------------------------------------------*/ +// TODO +// Do we really want to include the declare.h file ?? +typedef enum { + kDeviceTypeNoSensor = 0, + kDeviceTypeMotorSensor = 2, + kDeviceTypeLedSensor = 3, + kDeviceTypeAbsEncSensor = 4, + kDeviceTypeBumperSensor = 5, + kDeviceTypeImuSensor = 6, + kDeviceTypeRangeSensor = 7, + kDeviceTypeRadioSensor = 8, + kDeviceTypeTetherSensor = 9, + kDeviceTypeBrainSensor = 10, + kDeviceTypeVisionSensor = 11, + kDeviceTypeAdiSensor = 12, + kDeviceTypeGyroSensor = 0x46, + kDeviceTypeSonarSensor = 0x47, + kDeviceTypeGenericSensor = 128, + kDeviceTypeGenericSerial = 129, + kDeviceTypeUndefinedSensor = 255 +} V5_DeviceType; + + +// Opaque pointer to V5 device type structure +typedef struct _V5_Device * V5_DeviceT; + +// Some ports will be virtual, some physical +#define V5_MAX_DEVICE_PORTS 32 +typedef V5_DeviceType V5_DeviceTypeBuffer[V5_MAX_DEVICE_PORTS]; + +/*----------------------------------------------------------------------------*/ +/** @brief V5 Controller definitions */ +/*----------------------------------------------------------------------------*/ +// +// March 2018, obsolete types now removed +// additional enum for final V5 controller labels added +// +typedef enum _V5_ControllerIndex { + AnaLeftX = 0, + AnaLeftY, + AnaRightX, + AnaRightY, + AnaSpare1, + AnaSpare2, + + Button5U, + Button5D, + Button6U, + Button6D, + Button7U, + Button7D, + Button7L, + Button7R, + Button8U, + Button8D, + Button8L, + Button8R, + + ButtonSEL, + + BatteryLevel, + + ButtonAll, + Flags, + BatteryCapacity, + + // Final V5 names + Axis1 = AnaRightX, + Axis2 = AnaRightY, + Axis3 = AnaLeftY, + Axis4 = AnaLeftX, + + ButtonL1 = Button5U, + ButtonL2 = Button5D, + ButtonR1 = Button6U, + ButtonR2 = Button6D, + + ButtonUp = Button7U, + ButtonDown = Button7D, + ButtonLeft = Button7L, + ButtonRight = Button7R, + + ButtonX = Button8U, + ButtonB = Button8D, + ButtonY = Button8L, + ButtonA = Button8R +} V5_ControllerIndex; + +typedef enum _V5_ControllerStatus { + kV5ControllerOffline = 0, + kV5ControllerTethered, + kV5ControllerVexnet +} V5_ControllerStatus; + +typedef enum _V5_ControllerId { + kControllerMaster = 0, + kControllerPartner +} V5_ControllerId; + +/*----------------------------------------------------------------------------*/ +/** @brief V5 LED device definitions */ +/*----------------------------------------------------------------------------*/ +// The LED is an obsolete sensor but we will leave as it's available on the Dev +// systems +typedef enum _V5_DeviceLedColor { + kLedColorBlack = 0, + kLedColorRed = 0xFF0000, + kLedColorGreen = 0x00FF00, + kLedColorBlue = 0x0000FF, + kLedColorYellow = 0xFFFF00, + kLedColorCyan = 0x00FFFF, + kLedColorMagenta = 0xFF00FF, + kLedColorWhite = 0xFFFFFF +} V5_DeviceLedColor; + +/*----------------------------------------------------------------------------*/ +/** @brief V5 ADI device definitions */ +/*----------------------------------------------------------------------------*/ +typedef enum _V5_AdiPortConfiguration { + kAdiPortTypeAnalogIn = 0, + kAdiPortTypeAnalogOut, + kAdiPortTypeDigitalIn, + kAdiPortTypeDigitalOut, + + kAdiPortTypeSmartButton, + kAdiPortTypeSmartPot, + + kAdiPortTypeLegacyButton, + kAdiPortTypeLegacyPotentiometer, + kAdiPortTypeLegacyLineSensor, + kAdiPortTypeLegacyLightSensor, + kAdiPortTypeLegacyGyro, + kAdiPortTypeLegacyAccelerometer, + + kAdiPortTypeLegacyServo, + kAdiPortTypeLegacyPwm, + + kAdiPortTypeQuadEncoder, + kAdiPortTypeSonar, + + kAdiPortTypeLegacyPwmSlew, + + kAdiPortTypeUndefined = 255 +} V5_AdiPortConfiguration; + +// ADI sensor has 8 ports +#define V5_ADI_PORT_NUM 8 + +/*----------------------------------------------------------------------------*/ +/** @brief V5 Bumper switch device definitions */ +/*----------------------------------------------------------------------------*/ +typedef enum _V5_DeviceBumperState { + kBumperReleased = 0, /// Switch pressed + kBumperPressed = 1 /// Switch released +} V5_DeviceBumperState; + +/*----------------------------------------------------------------------------*/ +/** @brief V5 Motor definitions */ +/*----------------------------------------------------------------------------*/ +// Most of this is still TBD and is currently based on the IQ implementation +typedef enum { + kMotorControlModeOFF = 0, /// Motor is off and in coast mode + kMotorControlModeBRAKE = 1, /// Motor is off and in brake mode + kMotorControlModeHOLD = 2, /// Motor is holding at current position + kMotorControlModeSERVO = 3, /// Motor is in "Servo" mode. Move to position and hold at that position + kMotorControlModePROFILE = 4, /// Motor moves to set position and stops. + kMotorControlModeVELOCITY = 5, /// Motor is unlimited movement at set 'velocity' + kMotorControlModeUNDEFINED = 6 /// +} V5MotorControlMode; + +typedef enum _V5_MotorBrakeMode { + kV5MotorBrakeModeCoast = 0, /// Motor will coast when stopped + kV5MotorBrakeModeBrake = 1, /// Motor will brake when stopped + kV5MotorBrakeModeHold = 2 /// Motor will hold position when stopped +} V5MotorBrakeMode; + +typedef enum { + kMotorEncoderDegrees = 0, /// degrees Encoder Count Mode + kMotorEncoderRotations = 1, /// rotations Encoder Count Mode + kMotorEncoderCounts = 2 /// Raw Encoder Count Mode +} V5MotorEncoderUnits; + +typedef enum _V5MotorGearset { + kMotorGearSet_36 = 0, /// 36:1 gear set, torque + kMotorGearSet_18 = 1, /// 18:1 gear set, speed + kMotorGearSet_06 = 2 /// 6:1 gear set, high speed +} V5MotorGearset; + +// This is for 36:1 gear set +#define V5_MOTOR_COUNTS_PER_ROT 1800.0 + +// +// preliminary, used for position and velocity +// +typedef struct __attribute__ ((packed)) _V5_DeviceMotorPid { + uint8_t kf; + uint8_t kp; + uint8_t ki; + uint8_t kd; + uint8_t filter; + uint8_t pad1; + uint16_t limit; + uint8_t threshold; + uint8_t loopspeed; + uint8_t pad2[2]; +} V5_DeviceMotorPid; + +/*----------------------------------------------------------------------------*/ +/** @brief V5 Vision sensor definitions */ +/*----------------------------------------------------------------------------*/ + +// subject to change +typedef enum { + kVisionModeNormal = 0, + kVisionModeMixed = 1, + kVisionModeLineDetect = 2, + kVisionTypeTest = 3 +} V5VisionMode; + +typedef enum { + kVisionTypeNormal = 0, + kVisionTypeColorCode = 1, + kVisionTypeLineDetect = 2 +} V5VisionBlockType; + +// White balance +typedef enum { + kVisionWBNormal = 0, + kVisionWBStart = 1, + kVisionWBManual = 2 +} V5VisionWBMode; + +// LED control, from V5 or by the vision sensor +typedef enum { + kVisionLedModeAuto = 0, + kVisionLedModeManual = 1 +} V5VisionLedMode; + +// Wifi mode +typedef enum { + kVisionWifiModeOff = 0, + kVisionWifiModeOn = 1 +} V5VisionWifiMode; + +// signature should be 40 bytes and is the same data +// as sent to the vision sensor + +// if bit0 is now set you know signature is read back +#define VISION_SIG_FLAG_STATUS (1<<0) + +typedef struct __attribute__ ((__packed__)) { + uint8_t id; + uint8_t flags; + uint8_t pad[2]; + float range; + int32_t uMin; + int32_t uMax; + int32_t uMean; + int32_t vMin; + int32_t vMax; + int32_t vMean; + uint32_t mRgb; + uint32_t mType; +} V5_DeviceVisionSignature; + +typedef struct __attribute(( packed )) _V5_DeviceVisionObject { + uint16_t signature; /// block signature + V5VisionBlockType type; /// block type + uint16_t xoffset; /// left side of block + uint16_t yoffset; /// top of block + uint16_t width; /// width of block + uint16_t height; /// height of block + uint16_t angle; /// angle of CC block in 0.1 deg units +} V5_DeviceVisionObject; + +// Color structure, used for LED and white balance +typedef struct __attribute(( packed )) _V5_DeviceVisionRgb { + uint8_t red; + uint8_t green; + uint8_t blue; + uint8_t brightness; /// not used yet +} V5_DeviceVisionRgb; + +/*----------------------------------------------------------------------------*/ +/** @brief V5 SD File system definitions */ +/*----------------------------------------------------------------------------*/ + +// Opaque pointer (FIL *) to file structure +typedef void FIL; + +// seek flags +// changed, Mar 6 2018 to be more consistent with stdio.h +#define FS_SEEK_SET 0 +#define FS_SEEK_CUR 1 +#define FS_SEEK_END 2 + +// File function return code (FRESULT) +typedef enum { + FR_OK = 0U, /// (0) Succeeded + FR_DISK_ERR, /// (1) A hard error occurred in the low level disk I/O layer + FR_INT_ERR, /// (2) Assertion failed + FR_NOT_READY, /// (3) The physical drive cannot work + FR_NO_FILE, /// (4) Could not find the file + FR_NO_PATH, /// (5) Could not find the path + FR_INVALID_NAME, /// (6) The path name format is invalid + FR_DENIED, /// (7) Access denied due to prohibited access or directory full + FR_EXIST, /// (8) Access denied due to prohibited access + FR_INVALID_OBJECT, /// (9) The file/directory object is invalid + FR_WRITE_PROTECTED, /// (10) The physical drive is write protected + FR_INVALID_DRIVE, /// (11) The logical drive number is invalid + FR_NOT_ENABLED, /// (12) The volume has no work area + FR_NO_FILESYSTEM, /// (13) There is no valid FAT volume + FR_MKFS_ABORTED, /// (14) The f_mkfs() aborted due to any parameter error + FR_TIMEOUT, /// (15) Could not get a grant to access the volume within defined period + FR_LOCKED, /// (16) The operation is rejected according to the file sharing policy + FR_NOT_ENOUGH_CORE, /// (17) LFN working buffer could not be allocated + FR_TOO_MANY_OPEN_FILES, /// (18) Number of open files > _FS_SHARE + FR_INVALID_PARAMETER /// (19) Given parameter is invalid +} FRESULT; + +/*----------------------------------------------------------------------------*/ +/** @brief V5 touch events */ +/*----------------------------------------------------------------------------*/ +typedef enum _touchEvent { + kTouchEventRelease, + kTouchEventPress, + kTouchEventPressAuto +} V5_TouchEvent; + +typedef struct _V5_TouchStatus { + V5_TouchEvent lastEvent; + int16_t lastXpos; + int16_t lastYpos; + int32_t pressCount; + int32_t releaseCount; +} V5_TouchStatus; + +/*----------------------------------------------------------------------------*/ +/** @brief V5 competition status bits */ +/*----------------------------------------------------------------------------*/ + +#define V5_COMP_BIT_EBL 1 // if set then robot disabled +#define V5_COMP_BIT_MODE 2 // if set then robot in autonomous +#define V5_COMP_BIT_COMP 4 // if set then either comp switch or field control connected +#define V5_COMP_BIT_GAME 8 // if set then field control connected + +#ifdef __cplusplus +} +#endif +#endif /* V5_APITYPES_H_*/ diff --git a/include/v5_apiuser.h b/include/v5_apiuser.h new file mode 100644 index 000000000..b07cc0815 --- /dev/null +++ b/include/v5_apiuser.h @@ -0,0 +1,138 @@ +/*----------------------------------------------------------------------------*/ +/* */ +/* Copyright (c) Innovation First 2016, All rights reserved. */ +/* */ +/* Module: v5_apiuser.h */ +/* Author: James Pearman */ +/* Created: 8 Nov 2016 */ +/* */ +/* Revisions: V0.1 */ +/* */ +/*----------------------------------------------------------------------------*/ + +#ifndef V5_APIUSER_H_ +#define V5_APIUSER_H_ + +#include "stdint.h" +#include "stdbool.h" + +/*----------------------------------------------------------------------------*/ +/** @file v5_apiuser.h + * @brief Header for V5 API device wrapper functions +*//*--------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" { +#endif + +void vexDelay( uint32_t timems ); + +void vexLedSet( uint32_t index, V5_DeviceLedColor value ); +void vexLedRgbSet( uint32_t index, uint32_t color); +V5_DeviceLedColor vexLedGet( uint32_t index ); +uint32_t vexLedRgbGet( uint32_t index ); + +void vexAdiPortConfigSet( uint32_t index, uint32_t port, V5_AdiPortConfiguration type ); +V5_AdiPortConfiguration vexAdiPortConfigGet( uint32_t index, uint32_t port ); +void vexAdiValueSet( uint32_t index, uint32_t port, int32_t value ); +int32_t vexAdiValueGet( uint32_t index, uint32_t port ); + +V5_DeviceBumperState vexBumperGet( uint32_t index ); + +void vexGyroReset( uint32_t index ); +double vexGyroHeadingGet( uint32_t index ); +double vexGyroDegreesGet( uint32_t index ); + +int32_t vexSonarValueGet( uint32_t index ); + +int32_t vexGenericValueGet( uint32_t index ); + +void vexMotorVelocitySet( uint32_t index, int32_t velocity ); +void vexMotorVelocityUpdate( uint32_t index, int32_t velocity ); +void vexMotorVoltageSet( uint32_t index, int32_t value ); +int32_t vexMotorVelocityGet( uint32_t index ); +int32_t vexMotorDirectionGet( uint32_t index ); +double vexMotorActualVelocityGet( uint32_t index ); +void vexMotorModeSet( uint32_t index, V5MotorControlMode mode ); +V5MotorControlMode vexMotorModeGet( uint32_t index ); +void vexMotorPwmSet( uint32_t index, int32_t value ); +int32_t vexMotorPwmGet( uint32_t index ); +void vexMotorCurrentLimitSet( uint32_t index, int32_t value ); +int32_t vexMotorCurrentLimitGet( uint32_t index ); +void vexMotorVoltageLimitSet( uint32_t index, int32_t value ); +int32_t vexMotorVoltageLimitGet( uint32_t index ); +void vexMotorPositionPidSet( uint32_t index, V5_DeviceMotorPid *pid ); +void vexMotorVelocityPidSet( uint32_t index, V5_DeviceMotorPid *pid ); +int32_t vexMotorCurrentGet( uint32_t index ); +int32_t vexMotorVoltageGet( uint32_t index ); +double vexMotorPowerGet( uint32_t index ); +double vexMotorTorqueGet( uint32_t index ); +double vexMotorEfficiencyGet( uint32_t index ); +double vexMotorTemperatureGet( uint32_t index ); +bool vexMotorOverTempFlagGet( uint32_t index ); +bool vexMotorCurrentLimitFlagGet( uint32_t index ); +uint32_t vexMotorFaultsGet( uint32_t index ); +bool vexMotorZeroVelocityFlagGet( uint32_t index ); +bool vexMotorZeroPositionFlagGet( uint32_t index ); +uint32_t vexMotorFlagsGet( uint32_t index ); +void vexMotorReverseFlagSet( uint32_t index, bool value ); +bool vexMotorReverseFlagGet( uint32_t index ); +void vexMotorEncoderUnitsSet( uint32_t index, V5MotorEncoderUnits units ); +V5MotorEncoderUnits vexMotorEncoderUnitsGet( uint32_t index ); +void vexMotorBrakeModeSet( uint32_t index, V5MotorBrakeMode mode ); +V5MotorBrakeMode vexMotorBrakeModeGet( uint32_t index ); +void vexMotorPositionSet( uint32_t index, double position ); +double vexMotorPositionGet( uint32_t index ); +int32_t vexMotorPositionRawGet( uint32_t index, uint32_t *timestamp ); +void vexMotorPositionReset( uint32_t index ); +double vexMotorTargetGet( uint32_t index ); +void vexMotorServoTargetSet( uint32_t index, double position ); +void vexMotorAbsoluteTargetSet( uint32_t index, double position, int32_t velocity ); +void vexMotorRelativeTargetSet( uint32_t index, double position, int32_t velocity ); +void vexMotorGearingSet( uint32_t index, V5MotorGearset value ); +V5MotorGearset vexMotorGearingGet( uint32_t index ); + +void vexVisionModeSet( uint32_t index, V5VisionMode mode ); +V5VisionMode vexVisionModeGet( uint32_t index ); +int32_t vexVisionObjectCountGet( uint32_t index ); +int32_t vexVisionObjectGet( uint32_t index, uint32_t indexObj, V5_DeviceVisionObject *pObject ); +void vexVisionSignatureSet( uint32_t index, V5_DeviceVisionSignature *pSignature ); +bool vexVisionSignatureGet( uint32_t index, uint32_t id, V5_DeviceVisionSignature *pSignature ); +void vexVisionBrightnessSet( uint32_t index, uint8_t percent ); +uint8_t vexVisionBrightnessGet( uint32_t index ); +void vexVisionWhiteBalanceModeSet( uint32_t index, V5VisionWBMode mode ); +V5VisionWBMode vexVisionWhiteBalanceModeGet( uint32_t index ); +void vexVisionWhiteBalanceSet( uint32_t index, V5_DeviceVisionRgb color ); +V5_DeviceVisionRgb vexVisionWhiteBalanceGet( uint32_t index ); +void vexVisionLedModeSet( uint32_t index, V5VisionLedMode mode ); +V5VisionLedMode vexVisionLedModeGet( uint32_t index ); +void vexVisionLedBrigntnessSet( uint32_t index, uint8_t percent ); +uint8_t vexVisionLedBrigntnessGet( uint32_t index ); +void vexVisionLedColorSet( uint32_t index, V5_DeviceVisionRgb color); +V5_DeviceVisionRgb vexVisionLedColorGet( uint32_t index ); +void vexVisionWifiModeSet( uint32_t index, V5VisionWifiMode mode ); +V5VisionWifiMode vexVisionWifiModeGet( uint32_t index ); + +void vexImuReset( uint32_t index ); +double vexImuHeadingGet( uint32_t index ); +double vexImuDegreesGet( uint32_t index ); + +int32_t vexRangeValueGet( uint32_t index ); + +// Generic serial port comms to any device +void vexGenericSerialEnable( uint32_t index, int32_t options ); +void vexGenericSerialBaudrate( uint32_t index, int32_t baudrate ); +int32_t vexGenericSerialWriteChar( uint32_t index, uint8_t c ); +int32_t vexGenericSerialWriteFree( uint32_t index ); +int32_t vexGenericSerialTransmit( uint32_t index, uint8_t *buffer, int32_t length ); +int32_t vexGenericSerialReadChar( uint32_t index ); +int32_t vexGenericSerialPeekChar( uint32_t index ); +int32_t vexGenericSerialReceiveAvail( uint32_t index ); +int32_t vexGenericSerialReceive( uint32_t index, uint8_t *buffer, int32_t length ); +void vexGenericSerialFlush( uint32_t index ); + + +#ifdef __cplusplus +} +#endif +#endif /* V5_APIUSER_H_ */ \ No newline at end of file diff --git a/include/v5_color.h b/include/v5_color.h new file mode 100644 index 000000000..e88aabcc8 --- /dev/null +++ b/include/v5_color.h @@ -0,0 +1,177 @@ +/*----------------------------------------------------------------------------*/ +/* */ +/* Copyright (c) Innovation First 2016, All rights reserved. */ +/* */ +/* Module: v5_color.h */ +/* Author: James Pearman */ +/* Created: 20 August 2016 */ +/* */ +/* Revisions: */ +/* V1.00 TBD - Initial release */ +/* */ +/*----------------------------------------------------------------------------*/ + + +#ifndef _VEX_COLORS +#define _VEX_COLORS + +//***************************************************************************** +// +// A set of color definitions. This set is the subset of the X11 colors (from +// rgb.txt) that are supported by typical web browsers. +// +//***************************************************************************** +#define ClrAliceBlue 0x00F0F8FF +#define ClrAntiqueWhite 0x00FAEBD7 +#define ClrAqua 0x0000FFFF +#define ClrAquamarine 0x007FFFD4 +#define ClrAzure 0x00F0FFFF +#define ClrBeige 0x00F5F5DC +#define ClrBisque 0x00FFE4C4 +#define ClrBlack 0x00000000 +#define ClrBlanchedAlmond 0x00FFEBCD +#define ClrBlue 0x000000FF +#define ClrBlueViolet 0x008A2BE2 +#define ClrBrown 0x00A52A2A +#define ClrBurlyWood 0x00DEB887 +#define ClrCadetBlue 0x005F9EA0 +#define ClrChartreuse 0x007FFF00 +#define ClrChocolate 0x00D2691E +#define ClrCoral 0x00FF7F50 +#define ClrCornflowerBlue 0x006495ED +#define ClrCornsilk 0x00FFF8DC +#define ClrCrimson 0x00DC143C +#define ClrCyan 0x0000FFFF +#define ClrDarkBlue 0x0000008B +#define ClrDarkCyan 0x00008B8B +#define ClrDarkGoldenrod 0x00B8860B +#define ClrDarkGray 0x00A9A9A9 +#define ClrDarkGreen 0x00006400 +#define ClrDarkKhaki 0x00BDB76B +#define ClrDarkMagenta 0x008B008B +#define ClrDarkOliveGreen 0x00556B2F +#define ClrDarkOrange 0x00FF8C00 +#define ClrDarkOrchid 0x009932CC +#define ClrDarkRed 0x008B0000 +#define ClrDarkSalmon 0x00E9967A +#define ClrDarkSeaGreen 0x008FBC8F +#define ClrDarkSlateBlue 0x00483D8B +#define ClrDarkSlateGray 0x002F4F4F +#define ClrDarkTurquoise 0x0000CED1 +#define ClrDarkViolet 0x009400D3 +#define ClrDeepPink 0x00FF1493 +#define ClrDeepSkyBlue 0x0000BFFF +#define ClrDimGray 0x00696969 +#define ClrDodgerBlue 0x001E90FF +#define ClrFireBrick 0x00B22222 +#define ClrFloralWhite 0x00FFFAF0 +#define ClrForestGreen 0x00228B22 +#define ClrFuchsia 0x00FF00FF +#define ClrGainsboro 0x00DCDCDC +#define ClrGhostWhite 0x00F8F8FF +#define ClrGold 0x00FFD700 +#define ClrGoldenrod 0x00DAA520 +#define ClrGray 0x00808080 +#define ClrGreen 0x00008000 +#define ClrGreenYellow 0x00ADFF2F +#define ClrHoneydew 0x00F0FFF0 +#define ClrHotPink 0x00FF69B4 +#define ClrIndianRed 0x00CD5C5C +#define ClrIndigo 0x004B0082 +#define ClrIvory 0x00FFFFF0 +#define ClrKhaki 0x00F0E68C +#define ClrLavender 0x00E6E6FA +#define ClrLavenderBlush 0x00FFF0F5 +#define ClrLawnGreen 0x007CFC00 +#define ClrLemonChiffon 0x00FFFACD +#define ClrLightBlue 0x00ADD8E6 +#define ClrLightCoral 0x00F08080 +#define ClrLightCyan 0x00E0FFFF +#define ClrLightGoldenrodYellow 0x00FAFAD2 +#define ClrLightGreen 0x0090EE90 +#define ClrLightGrey 0x00D3D3D3 +#define ClrLightPink 0x00FFB6C1 +#define ClrLightSalmon 0x00FFA07A +#define ClrLightSeaGreen 0x0020B2AA +#define ClrLightSkyBlue 0x0087CEFA +#define ClrLightSlateGray 0x00778899 +#define ClrLightSteelBlue 0x00B0C4DE +#define ClrLightYellow 0x00FFFFE0 +#define ClrLime 0x0000FF00 +#define ClrLimeGreen 0x0032CD32 +#define ClrLinen 0x00FAF0E6 +#define ClrMagenta 0x00FF00FF +#define ClrMaroon 0x00800000 +#define ClrMediumAquamarine 0x0066CDAA +#define ClrMediumBlue 0x000000CD +#define ClrMediumOrchid 0x00BA55D3 +#define ClrMediumPurple 0x009370DB +#define ClrMediumSeaGreen 0x003CB371 +#define ClrMediumSlateBlue 0x007B68EE +#define ClrMediumSpringGreen 0x0000FA9A +#define ClrMediumTurquoise 0x0048D1CC +#define ClrMediumVioletRed 0x00C71585 +#define ClrMidnightBlue 0x00191970 +#define ClrMintCream 0x00F5FFFA +#define ClrMistyRose 0x00FFE4E1 +#define ClrMoccasin 0x00FFE4B5 +#define ClrNavajoWhite 0x00FFDEAD +#define ClrNavy 0x00000080 +#define ClrOldLace 0x00FDF5E6 +#define ClrOlive 0x00808000 +#define ClrOliveDrab 0x006B8E23 +#define ClrOrange 0x00FFA500 +#define ClrOrangeRed 0x00FF4500 +#define ClrOrchid 0x00DA70D6 +#define ClrPaleGoldenrod 0x00EEE8AA +#define ClrPaleGreen 0x0098FB98 +#define ClrPaleTurquoise 0x00AFEEEE +#define ClrPaleVioletRed 0x00DB7093 +#define ClrPapayaWhip 0x00FFEFD5 +#define ClrPeachPuff 0x00FFDAB9 +#define ClrPeru 0x00CD853F +#define ClrPink 0x00FFC0CB +#define ClrPlum 0x00DDA0DD +#define ClrPowderBlue 0x00B0E0E6 +#define ClrPurple 0x00800080 +#define ClrRed 0x00FF0000 +#define ClrRosyBrown 0x00BC8F8F +#define ClrRoyalBlue 0x004169E1 +#define ClrSaddleBrown 0x008B4513 +#define ClrSalmon 0x00FA8072 +#define ClrSandyBrown 0x00F4A460 +#define ClrSeaGreen 0x002E8B57 +#define ClrSeashell 0x00FFF5EE +#define ClrSienna 0x00A0522D +#define ClrSilver 0x00C0C0C0 +#define ClrSkyBlue 0x0087CEEB +#define ClrSlateBlue 0x006A5ACD +#define ClrSlateGray 0x00708090 +#define ClrSnow 0x00FFFAFA +#define ClrSpringGreen 0x0000FF7F +#define ClrSteelBlue 0x004682B4 +#define ClrTan 0x00D2B48C +#define ClrTeal 0x00008080 +#define ClrThistle 0x00D8BFD8 +#define ClrTomato 0x00FF6347 +#define ClrTurquoise 0x0040E0D0 +#define ClrViolet 0x00EE82EE +#define ClrWheat 0x00F5DEB3 +#define ClrWhite 0x00FFFFFF +#define ClrWhiteSmoke 0x00F5F5F5 +#define ClrYellow 0x00FFFF00 +#define ClrYellowGreen 0x009ACD32 + +//***************************************************************************** +// +// Masks and shifts to aid in color format translation by drivers. +// +//***************************************************************************** +#define ClrRedMask 0x00FF0000 +#define ClrRedShift 16 +#define ClrGreenMask 0x0000FF00 +#define ClrGreenShift 8 +#define ClrBlueMask 0x000000FF +#define ClrBlueShift 0 + +#endif // _VEX_COLORS \ No newline at end of file diff --git a/include/vdml/registry.h b/include/vdml/registry.h index af2ca7e26..ae97b185f 100644 --- a/include/vdml/registry.h +++ b/include/vdml/registry.h @@ -40,7 +40,7 @@ void registry_update_types(); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). + * ENXIO - The given value is not within the range of V5 ports (1-21). * * \param port * The V5 port number from 1-21 @@ -55,7 +55,7 @@ v5_smart_device_s_t* registry_get_device(uint8_t port); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). + * ENXIO - The given value is not within the range of V5 ports (1-21). * * \param port * The V5 port number from 0-32 @@ -70,7 +70,7 @@ v5_smart_device_s_t* registry_get_device_internal(uint8_t port); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). + * ENXIO - The given value is not within the range of V5 ports (1-21). * * \param port * The V5 port number from 1-21 @@ -85,7 +85,7 @@ v5_device_e_t registry_get_bound_type(uint8_t port); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). + * ENXIO - The given value is not within the range of V5 ports (1-21). * * \param port * The V5 port number from 1-21 @@ -105,7 +105,7 @@ v5_device_e_t registry_get_plugged_type(uint8_t port); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). + * ENXIO - The given value is not within the range of V5 ports (1-21). * * \param port * The V5 port number from 1-21 diff --git a/include/vdml/vdml.h b/include/vdml/vdml.h index 4fd92c958..fb3519491 100644 --- a/include/vdml/vdml.h +++ b/include/vdml/vdml.h @@ -39,19 +39,18 @@ * The v5_device_e_t that the port is configured as */ #define claim_port(port, device_type) \ - if (!VALIDATE_PORT_NO(port)) { \ - errno = EINVAL; \ - return PROS_ERR; \ - } \ - if (registry_validate_binding(port, device_type) != 0) { \ - errno = EINVAL; \ - return PROS_ERR; \ - } \ - v5_smart_device_s_t* device = registry_get_device(port); \ - if (!port_mutex_take(port)) { \ - errno = EACCES; \ - return PROS_ERR; \ - } + if (!VALIDATE_PORT_NO(port)) { \ + errno = ENXIO; \ + return PROS_ERR; \ + } \ + if (registry_validate_binding(port, device_type) != 0) { \ + return PROS_ERR; \ + } \ + v5_smart_device_s_t* device = registry_get_device(port); \ + if (!port_mutex_take(port)) { \ + errno = EACCES; \ + return PROS_ERR; \ + } /** * A function that executes claim_port for functions that do not return an @@ -59,7 +58,7 @@ * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (1-21). + * ENXIO - The given value is not within the range of V5 ports (1-21). * EACCES - Another resource is currently trying to access the port. * * \param port @@ -84,8 +83,8 @@ int32_t claim_port_try(uint8_t port, v5_device_e_t type); * \return The rtn parameter */ #define return_port(port, rtn) \ - port_mutex_give(port); \ - return rtn; + port_mutex_give(port); \ + return rtn; /** * Bitmap to indicate if a port has had an error printed or not. @@ -138,7 +137,7 @@ void vdml_reset_port_error(); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (0-20). + * ENXIO - The given value is not within the range of V5 ports (0-20). * * \param port * The V5 port number to claim from 0-20 @@ -159,7 +158,7 @@ int port_mutex_take(uint8_t port); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (0-20). + * ENXIO - The given value is not within the range of V5 ports (0-20). * * \param port * The V5 port number to free from 0-20 @@ -183,7 +182,7 @@ void port_mutex_give_all(); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (0-32). + * ENXIO - The given value is not within the range of V5 ports (0-32). * * \param port * The V5 port number from 0-32 @@ -201,7 +200,7 @@ int internal_port_mutex_take(uint8_t port); * * This function uses the following values of errno when an error state is * reached: - * EINVAL - The given value is not within the range of V5 ports (0-32). + * ENXIO - The given value is not within the range of V5 ports (0-32). * * \param port * The V5 port number from 0-32 diff --git a/src/devices/registry.c b/src/devices/registry.c index e3d92777e..b55c93aa3 100644 --- a/src/devices/registry.c +++ b/src/devices/registry.c @@ -46,7 +46,7 @@ void registry_update_types() { int registry_bind_port(uint8_t port, v5_device_e_t device_type) { if (!VALIDATE_PORT_NO(port)) { kprintf("[VDML][ERROR]Registration: Invalid port number %d\n", port + 1); - errno = EINVAL; + errno = ENXIO; return PROS_ERR; } if (registry[port].device_type != E_DEVICE_NONE) { @@ -56,7 +56,7 @@ int registry_bind_port(uint8_t port, v5_device_e_t device_type) { } if ((v5_device_e_t)registry_types[port] != device_type && (v5_device_e_t)registry_types[port] != E_DEVICE_NONE) { kprintf("[VDML][ERROR]Registration: Device mismatch in port %d\n", port + 1); - errno = EINVAL; + errno = EADDRINUSE; return PROS_ERR; } kprintf("[VDML][INFO]Registering device in port %d\n", port + 1); @@ -70,7 +70,7 @@ int registry_bind_port(uint8_t port, v5_device_e_t device_type) { int registry_unbind_port(uint8_t port) { port--; if (!VALIDATE_PORT_NO(port)) { - errno = EINVAL; + errno = ENXIO; return PROS_ERR; } registry[port].device_type = E_DEVICE_NONE; @@ -80,7 +80,7 @@ int registry_unbind_port(uint8_t port) { v5_smart_device_s_t* registry_get_device(uint8_t port) { if (!VALIDATE_PORT_NO(port)) { - errno = EINVAL; + errno = ENXIO; return NULL; } return ®istry[port]; @@ -88,7 +88,7 @@ v5_smart_device_s_t* registry_get_device(uint8_t port) { v5_smart_device_s_t* registry_get_device_internal(uint8_t port) { if (!VALIDATE_PORT_NO_INTERNAL(port)) { - errno = EINVAL; + errno = ENXIO; return NULL; } return ®istry[port]; @@ -96,7 +96,7 @@ v5_smart_device_s_t* registry_get_device_internal(uint8_t port) { v5_device_e_t registry_get_bound_type(uint8_t port) { if (!VALIDATE_PORT_NO(port)) { - errno = EINVAL; + errno = ENXIO; return E_DEVICE_UNDEFINED; } return registry[port].device_type; @@ -104,7 +104,7 @@ v5_device_e_t registry_get_bound_type(uint8_t port) { v5_device_e_t registry_get_plugged_type(uint8_t port) { if (!VALIDATE_PORT_NO(port)) { - errno = EINVAL; + errno = ENXIO; return -1; } return registry_types[port]; @@ -112,7 +112,7 @@ v5_device_e_t registry_get_plugged_type(uint8_t port) { int32_t registry_validate_binding(uint8_t port, v5_device_e_t expected_t) { if (!VALIDATE_PORT_NO(port)) { - errno = EINVAL; + errno = ENXIO; return PROS_ERR; } @@ -137,6 +137,7 @@ int32_t registry_validate_binding(uint8_t port, v5_device_e_t expected_t) { kprintf("[VDML][WARNING] No device in port %d. Is it plugged in?\n", port + 1); vdml_set_port_error(port); } + errno = ENODEV; return 1; } else { // Warn about a mismatch @@ -144,6 +145,7 @@ int32_t registry_validate_binding(uint8_t port, v5_device_e_t expected_t) { kprintf("[VDML][WARNING] Device mistmatch in port %d.\n", port + 1); vdml_set_port_error(port); } + errno = EADDRINUSE; return 2; } } diff --git a/src/devices/vdml.c b/src/devices/vdml.c index 21fef140b..a43394962 100644 --- a/src/devices/vdml.c +++ b/src/devices/vdml.c @@ -31,11 +31,10 @@ extern void port_mutex_init(); int32_t claim_port_try(uint8_t port, v5_device_e_t type) { if (!VALIDATE_PORT_NO(port)) { - errno = EINVAL; + errno = ENXIO; return PROS_ERR; } if (registry_validate_binding(port, type) != 0) { - errno = EINVAL; return PROS_ERR; } if (!port_mutex_take(port)) { @@ -77,7 +76,7 @@ void port_mutex_init() { int port_mutex_take(uint8_t port) { if (port >= V5_MAX_DEVICE_PORTS) { - errno = EINVAL; + errno = ENXIO; return PROS_ERR; } return xTaskGetSchedulerState() != taskSCHEDULER_RUNNING || mutex_take(port_mutexes[port], TIMEOUT_MAX); @@ -85,7 +84,7 @@ int port_mutex_take(uint8_t port) { int internal_port_mutex_take(uint8_t port) { if (port >= V5_MAX_DEVICE_PORTS) { - errno = EINVAL; + errno = ENXIO; return PROS_ERR; } return mutex_take(port_mutexes[port], TIMEOUT_MAX); @@ -99,7 +98,7 @@ static inline char* print_num(char* buff, int num) { int port_mutex_give(uint8_t port) { if (port >= V5_MAX_DEVICE_PORTS) { - errno = EINVAL; + errno = ENXIO; return PROS_ERR; } return xTaskGetSchedulerState() != taskSCHEDULER_RUNNING || mutex_give(port_mutexes[port]); @@ -107,7 +106,7 @@ int port_mutex_give(uint8_t port) { int internal_port_mutex_give(uint8_t port) { if (port >= V5_MAX_DEVICE_PORTS) { - errno = EINVAL; + errno = ENXIO; return PROS_ERR; } return mutex_give(port_mutexes[port]); diff --git a/src/devices/vdml_adi.c b/src/devices/vdml_adi.c index da1676a2f..8749ff275 100644 --- a/src/devices/vdml_adi.c +++ b/src/devices/vdml_adi.c @@ -114,32 +114,38 @@ static void set_gyro_tare(uint8_t port, double tare) { else \ port--; \ if (port > 7 || port < 0) { \ - errno = EINVAL; \ + errno = ENXIO; \ return PROS_ERR; \ } #define validate_type(port, type) \ adi_port_config_e_t config = _adi_port_get_config(port); \ if (config != type) { \ + errno = EADDRINUSE; \ return PROS_ERR; \ } #define validate_type_f(port, type) \ adi_port_config_e_t config = _adi_port_get_config(port); \ if (config != type) { \ + errno = EADDRINUSE; \ return PROS_ERR_F; \ } #define validate_motor(port) \ adi_port_config_e_t config = _adi_port_get_config(port); \ + if (config == E_ADI_TYPE_UNDEFINED) { \ + errno = ENODEV; \ + return PROS_ERR; \ + } \ if (config != E_ADI_LEGACY_PWM && config != E_ADI_LEGACY_SERVO) { \ - errno = EINVAL; \ + errno = EADDRINUSE; \ return PROS_ERR; \ } #define validate_twowire(port_top, port_bottom) \ if (abs(port_top - port_bottom) > 1) { \ - errno = EINVAL; \ + errno = ENXIO; \ return PROS_ERR; \ } \ int port; \ @@ -148,6 +154,7 @@ static void set_gyro_tare(uint8_t port, double tare) { else if (port_bottom < port_top) \ port = port_bottom; \ else \ + errno = EINVAL; \ return PROS_ERR; \ if (port % 2 == 1) { \ return PROS_ERR; \ @@ -155,7 +162,7 @@ static void set_gyro_tare(uint8_t port, double tare) { static inline int32_t _adi_port_set_config(uint8_t port, adi_port_config_e_t type) { claim_port(INTERNAL_ADI_PORT, E_DEVICE_ADI); - vexDeviceAdiPortConfigSet(device->device_info, port, type); + vexDeviceAdiPortConfigSet(device->device_info, port, (V5_AdiPortConfiguration)type); return_port(INTERNAL_ADI_PORT, 1); } diff --git a/src/devices/vdml_vision.c b/src/devices/vdml_vision.c index 53dcd57c6..04cd13f57 100644 --- a/src/devices/vdml_vision.c +++ b/src/devices/vdml_vision.c @@ -51,8 +51,7 @@ int32_t vision_get_object_count(uint8_t port) { vision_object_s_t vision_get_by_size(uint8_t port, const uint32_t size_id) { vision_object_s_t rtn; v5_smart_device_s_t* device; - int32_t err = claim_port_try(port - 1, E_DEVICE_VISION); - if (err == PROS_ERR) { + if (claim_port_try(port - 1, E_DEVICE_VISION) == PROS_ERR) { rtn.signature = VISION_OBJECT_ERR_SIG; return rtn; } @@ -62,9 +61,8 @@ vision_object_s_t vision_get_by_size(uint8_t port, const uint32_t size_id) { rtn.signature = VISION_OBJECT_ERR_SIG; goto leave; } - err = vexDeviceVisionObjectGet(device->device_info, size_id, (V5_DeviceVisionObject*)&rtn); - if (err == 0) { - errno = EHOSTDOWN; + if (vexDeviceVisionObjectGet(device->device_info, size_id, (V5_DeviceVisionObject*)&rtn) == 0) { + errno = EAGAIN; rtn.signature = VISION_OBJECT_ERR_SIG; goto leave; } @@ -82,10 +80,8 @@ vision_object_s_t _vision_get_by_sig(uint8_t port, const uint32_t size_id, const uint8_t count = 0; int32_t object_count = 0; - int32_t err = claim_port_try(port - 1, E_DEVICE_VISION); - if (err == PROS_ERR) { - errno = EINVAL; - goto err_return; + if (claim_port_try(port - 1, E_DEVICE_VISION) == PROS_ERR) { + goto err_return_no_mutex; } device = registry_get_device(port - 1); @@ -97,9 +93,8 @@ vision_object_s_t _vision_get_by_sig(uint8_t port, const uint32_t size_id, const for (uint8_t i = 0; i <= object_count; i++) { vision_object_s_t check; - err = vexDeviceVisionObjectGet(device->device_info, i, (V5_DeviceVisionObject*)&check); - if (err == PROS_ERR) { - errno = EHOSTDOWN; + if (vexDeviceVisionObjectGet(device->device_info, i, (V5_DeviceVisionObject*)&check) == PROS_ERR) { + errno = EAGAIN; rtn = check; goto err_return; } @@ -113,9 +108,11 @@ vision_object_s_t _vision_get_by_sig(uint8_t port, const uint32_t size_id, const count++; } } + errno = EDOM; // we read through all the objects and none matched sig_id and size_id err_return: port_mutex_give(port - 1); +err_return_no_mutex: rtn.signature = VISION_OBJECT_ERR_SIG; return rtn; } @@ -151,6 +148,8 @@ int32_t vision_read_by_size(uint8_t port, const uint32_t size_id, const uint32_t for (uint32_t i = size_id; i < c; i++) { if (!vexDeviceVisionObjectGet(device->device_info, i, (V5_DeviceVisionObject*)(object_arr + i))) { + errno = EAGAIN; + object_arr[i].signature = VISION_OBJECT_ERR_SIG; break; } _vision_transform_coords(port - 1, &object_arr[i]); @@ -238,7 +237,7 @@ vision_signature_s_t vision_get_signature(uint8_t port, const uint8_t signature_ } int32_t vision_set_signature(uint8_t port, const uint8_t signature_id, vision_signature_s_t* const signature_ptr) { - if (signature_id > 8 || signature_id == 0) { + if (signature_id > 7 || signature_id == 0) { errno = EINVAL; return PROS_ERR; } @@ -345,11 +344,11 @@ int32_t vision_get_white_balance(uint8_t port) { int32_t vision_set_zero_point(uint8_t port, vision_zero_e_t zero_point) { if (!VALIDATE_PORT_NO(port - 1)) { - errno = EINVAL; + errno = ENXIO; return PROS_ERR; } if (registry_validate_binding(port - 1, E_DEVICE_VISION) != 0) { - errno = EINVAL; + errno = ENODEV; return PROS_ERR; } if (!port_mutex_take(port - 1)) {