mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-28 02:11:43 +00:00
Adds a HAL wrapper around the CAN API's (#623)
Can someday be added to the simulator. Removes the last use case for the ni headers directly.
This commit is contained in:
committed by
Peter Johnson
parent
c572e6a307
commit
2249a8bac0
28
hal/src/main/native/sim/CAN.cpp
Normal file
28
hal/src/main/native/sim/CAN.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "HAL/CAN.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
void HAL_CAN_SendMessage(uint32_t messageID, const uint8_t* data,
|
||||
uint8_t dataSize, int32_t periodMs, int32_t* status) {}
|
||||
void HAL_CAN_ReceiveMessage(uint32_t* messageID, uint32_t messageIDMask,
|
||||
uint8_t* data, uint8_t* dataSize,
|
||||
uint32_t* timeStamp, int32_t* status) {}
|
||||
void HAL_CAN_OpenStreamSession(uint32_t* sessionHandle, uint32_t messageID,
|
||||
uint32_t messageIDMask, uint32_t maxMessages,
|
||||
int32_t* status) {}
|
||||
void HAL_CAN_CloseStreamSession(uint32_t sessionHandle) {}
|
||||
void HAL_CAN_ReadStreamSession(uint32_t sessionHandle,
|
||||
struct HAL_CANStreamMessage* messages,
|
||||
uint32_t messagesToRead, uint32_t* messagesRead,
|
||||
int32_t* status) {}
|
||||
void HAL_CAN_GetCANStatus(float* percentBusUtilization, uint32_t* busOffCount,
|
||||
uint32_t* txFullCount, uint32_t* receiveErrorCount,
|
||||
uint32_t* transmitErrorCount, int32_t* status) {}
|
||||
}
|
||||
@@ -20,15 +20,6 @@ typedef enum {
|
||||
// full.
|
||||
} CTR_Code;
|
||||
|
||||
// CAN Errors
|
||||
|
||||
#define ERR_CANSessionMux_InvalidBuffer -44086
|
||||
#define ERR_CANSessionMux_MessageNotFound -44087
|
||||
#define WARN_CANSessionMux_NoToken 44087
|
||||
#define ERR_CANSessionMux_NotAllowed -44088
|
||||
#define ERR_CANSessionMux_NotInitialized -44089
|
||||
#define ERR_CANSessionMux_SessionOverrun 44050
|
||||
|
||||
// VISA Error
|
||||
#define _VI_ERROR (-2147483647L - 1)
|
||||
#define VI_ERROR_SYSTEM_ERROR (_VI_ERROR + 0x3FFF0000L)
|
||||
|
||||
@@ -102,15 +102,15 @@ const char* HAL_GetErrorMessage(int32_t code) {
|
||||
return PARAMETER_OUT_OF_RANGE_MESSAGE;
|
||||
case HAL_COUNTER_NOT_SUPPORTED:
|
||||
return HAL_COUNTER_NOT_SUPPORTED_MESSAGE;
|
||||
case ERR_CANSessionMux_InvalidBuffer:
|
||||
case HAL_ERR_CANSessionMux_InvalidBuffer:
|
||||
return ERR_CANSessionMux_InvalidBuffer_MESSAGE;
|
||||
case ERR_CANSessionMux_MessageNotFound:
|
||||
case HAL_ERR_CANSessionMux_MessageNotFound:
|
||||
return ERR_CANSessionMux_MessageNotFound_MESSAGE;
|
||||
case WARN_CANSessionMux_NoToken:
|
||||
case HAL_WARN_CANSessionMux_NoToken:
|
||||
return WARN_CANSessionMux_NoToken_MESSAGE;
|
||||
case ERR_CANSessionMux_NotAllowed:
|
||||
case HAL_ERR_CANSessionMux_NotAllowed:
|
||||
return ERR_CANSessionMux_NotAllowed_MESSAGE;
|
||||
case ERR_CANSessionMux_NotInitialized:
|
||||
case HAL_ERR_CANSessionMux_NotInitialized:
|
||||
return ERR_CANSessionMux_NotInitialized_MESSAGE;
|
||||
case VI_ERROR_SYSTEM_ERROR:
|
||||
return VI_ERROR_SYSTEM_ERROR_MESSAGE;
|
||||
|
||||
Reference in New Issue
Block a user