|
18 | 18 | #include "vehicles.h" |
19 | 19 |
|
20 | 20 |
|
| 21 | +/* |
| 22 | + * @brief MAX_CAN_IDS is the maximum number unique CAN IDs on the CAN bus used |
| 23 | + * for auto detection of CAN channels. Increasing this number increases the wait |
| 24 | + * time for checking if a channel contains expected CAN IDs, reducing this |
| 25 | + * number below number of CAN IDs broadcast could yield a false negative in auto |
| 26 | + * detection. |
| 27 | + * |
| 28 | + */ |
| 29 | +#define MAX_CAN_IDS ( 70 ) |
| 30 | + |
| 31 | + |
| 32 | +/* |
| 33 | + * @brief CAN_MESSAGE_TIMEOUT is the time to wait for a CAN message in |
| 34 | + * milliseconds used for auto detection of can channels. |
| 35 | + * |
| 36 | + */ |
| 37 | +#define CAN_MESSAGE_TIMEOUT ( 100 ) |
| 38 | + |
| 39 | + |
21 | 40 | typedef enum |
22 | 41 | { |
23 | 42 | OSCC_OK, |
24 | 43 | OSCC_ERROR, |
25 | 44 | OSCC_WARNING |
26 | 45 | } oscc_result_t; |
27 | 46 |
|
| 47 | +/** |
| 48 | + * @brief Looks for available CAN channels and automatically detects which |
| 49 | + * channel is OSCC control and which channel is vehicle CAN for feedback. |
| 50 | + * |
| 51 | + * @return OSCC_ERROR or OSCC_OK |
| 52 | + * |
| 53 | + */ |
| 54 | +oscc_result_t oscc_init(); |
28 | 55 |
|
29 | 56 | /** |
30 | | - * @brief Use provided CAN channel to open communications |
31 | | - * to CAN bus connected to the OSCC modules. |
| 57 | + * @brief Use provided CAN channel to open communications to CAN bus connected |
| 58 | + * to the OSCC modules. If CAN gateway does not forward Vehicle CAN |
| 59 | + * automatically detect if a CAN channel has Vehicle CAN available. |
32 | 60 | * |
33 | 61 | * @param [in] channel - CAN channel connected to OSCC modules. |
34 | 62 | * |
@@ -176,4 +204,117 @@ oscc_result_t oscc_subscribe_to_fault_reports( void( *callback )( oscc_fault_rep |
176 | 204 | oscc_result_t oscc_subscribe_to_obd_messages( void( *callback )( struct can_frame *frame ) ); |
177 | 205 |
|
178 | 206 |
|
| 207 | +/** |
| 208 | + * @brief Set vehicle right rear wheel speed in kph from CAN frame. (kph) |
| 209 | + * |
| 210 | + * @param [in] frame - A pointer to \ref struct can_frame that contains the raw CAN data associated |
| 211 | + * with wheel speed (CAN ID: \ref KIA_SOUL_OBD_WHEEL_SPEED_CAN_ID) |
| 212 | + * |
| 213 | + * @param [out] wheel_speed_right_rear - A pointer to double. Set to the unpacked and scaled rear |
| 214 | + * right wheel speed reported by the vehicle (kph). |
| 215 | + * |
| 216 | + * @return: |
| 217 | + * \li \ref OSCC_OK on successful unpacking. |
| 218 | + * \li \ref OSCC_ERROR if a parameter is NULL or the CAN frame ID is not |
| 219 | + * \ref KIA_SOUL_OBD_WHEEL_SPEED_CAN_ID |
| 220 | + */ |
| 221 | +oscc_result_t get_wheel_speed_right_rear( |
| 222 | + struct can_frame const * const frame, |
| 223 | + double * wheel_speed_right_rear); |
| 224 | + |
| 225 | +/** |
| 226 | + * @brief Get vehicle left rear wheel speed in kph from CAN frame. (kph) |
| 227 | + * |
| 228 | + * @param [in] frame - A pointer to \ref struct can_frame that contains the raw CAN data associated |
| 229 | + * with wheel speed (CAN ID: \ref KIA_SOUL_OBD_WHEEL_SPEED_CAN_ID) |
| 230 | + * |
| 231 | + * @param [out] wheel_speed_left_rear - A pointer to double. Set to the unpacked and scaled front |
| 232 | + * left wheel speed reported by the vehicle (kph). |
| 233 | + * |
| 234 | + * @return: |
| 235 | + * \li \ref OSCC_OK on successful unpacking. |
| 236 | + * \li \ref OSCC_ERROR if a parameter is NULL or the CAN frame ID is not |
| 237 | + * \ref KIA_SOUL_OBD_WHEEL_SPEED_CAN_ID |
| 238 | + */ |
| 239 | +oscc_result_t get_wheel_speed_left_rear( |
| 240 | + struct can_frame const * const frame, |
| 241 | + double * wheel_speed_left_rear); |
| 242 | + |
| 243 | + |
| 244 | +/** |
| 245 | + * @brief Get vehicle right front wheel speed in kph from CAN frame. (kph) |
| 246 | + * |
| 247 | + * @param [in] frame - A pointer to \ref struct can_frame that contains the raw CAN data associated |
| 248 | + * with wheel speed (CAN ID: \ref KIA_SOUL_OBD_WHEEL_SPEED_CAN_ID) |
| 249 | + * |
| 250 | + * @param [out] wheel_speed_right_front - A pointer to double. Set to the unpacked and scaled front |
| 251 | + * right wheel speed reported by the vehicle (kph). |
| 252 | + * |
| 253 | + * @return: |
| 254 | + * \li \ref OSCC_OK on successful unpacking. |
| 255 | + * \li \ref OSCC_ERROR if a parameter is NULL or the CAN frame ID is not |
| 256 | + * \ref KIA_SOUL_OBD_WHEEL_SPEED_CAN_ID |
| 257 | + */ |
| 258 | +oscc_result_t get_wheel_speed_right_front( |
| 259 | + struct can_frame const * const frame, |
| 260 | + double * wheel_speed_right_front); |
| 261 | + |
| 262 | + |
| 263 | +/** |
| 264 | + * @brief Get vehicle left front wheel speed in kph from CAN frame. (kph) |
| 265 | + * |
| 266 | + * @param [in] frame - A pointer to \ref struct can_frame that contains the raw CAN data associated |
| 267 | + * with wheel speed (CAN ID: \ref KIA_SOUL_OBD_WHEEL_SPEED_CAN_ID) |
| 268 | + * |
| 269 | + * @param [out] wheel_speed_left_front - A pointer to double. Set to the unpacked and scaled rear |
| 270 | + * left wheel speed reported by the vehicle (kph). |
| 271 | + * |
| 272 | + * @return: |
| 273 | + * \li \ref OSCC_OK on successful unpacking. |
| 274 | + * \li \ref OSCC_ERROR if a parameter is NULL or the CAN frame ID is not |
| 275 | + * \ref KIA_SOUL_OBD_WHEEL_SPEED_CAN_ID |
| 276 | + */ |
| 277 | +oscc_result_t get_wheel_speed_left_front( |
| 278 | + struct can_frame const * const frame, |
| 279 | + double * wheel_speed_left_front); |
| 280 | + |
| 281 | + |
| 282 | +/** |
| 283 | + * @brief Get vehicle steering wheel angle from CAN frame. (degrees) |
| 284 | + * |
| 285 | + * @param [in] frame - A pointer to \ref struct can_frame that contains the raw CAN data associated |
| 286 | + * with steering wheel angle (CAN ID: \ref KIA_SOUL_OBD_STEERING_WHEEL_ANGLE_CAN_ID) |
| 287 | + * |
| 288 | + * @param [out] steering_wheel_angle - A pointer to double. Value is set to the unpacked and scaled |
| 289 | + * steering wheel angle reported by the vehicle (degrees). |
| 290 | + * |
| 291 | + * @return: |
| 292 | + * \li \ref OSCC_OK on successful unpacking. |
| 293 | + * \li \ref OSCC_ERROR if a parameter is NULL or the CAN frame ID is not |
| 294 | + * \ref KIA_SOUL_OBD_STEERING_WHEEL_ANGLE_CAN_ID |
| 295 | + */ |
| 296 | +oscc_result_t get_steering_wheel_angle( |
| 297 | + struct can_frame const * const frame, |
| 298 | + double * steering_wheel_angle); |
| 299 | + |
| 300 | + |
| 301 | +/** |
| 302 | + * @brief Get vehicle brake pressure from CAN frame. (bar) |
| 303 | + * |
| 304 | + * @param [in] frame - A pointer to \ref struct can_frame that contains the raw CAN data associated |
| 305 | + * with brake pressure (CAN ID: \ref KIA_SOUL_OBD_BRAKE_PRESSURE_CAN_ID) |
| 306 | + * |
| 307 | + * @param [out] brake_pressure - A pointer to double. Set to the unpacked and scaled brake pressure |
| 308 | + * reported by the vehicle (bar). |
| 309 | + * |
| 310 | + * @return: |
| 311 | + * \li \ref OSCC_OK on successful unpacking. |
| 312 | + * \li \ref OSCC_ERROR if a parameter is NULL or the CAN frame ID is not |
| 313 | + * \ref KIA_SOUL_OBD_BRAKE_PRESSURE_CAN_ID |
| 314 | + */ |
| 315 | +oscc_result_t get_brake_pressure( |
| 316 | + struct can_frame const * const frame, |
| 317 | + double * brake_pressure); |
| 318 | + |
| 319 | + |
179 | 320 | #endif /* _OSCC_H */ |
0 commit comments