New netcomms .so and headers.

CAN isn't fully working yet, but this change is necessary to compile for the v9 image.

Change-Id: Ife99686a7e7a9979c95ec7a395d597011090fa37
This commit is contained in:
thomasclark
2014-06-16 10:24:48 -04:00
parent 58021f7397
commit 85dff7d2ec
19 changed files with 576 additions and 570 deletions

View File

@@ -1,56 +0,0 @@
// JaguarCANDriver.h
//
// Defines the API for building a CAN Interface Plugin to support
// PWM-cable-free CAN motor control on FRC robots. This allows you
// to connect any CAN interface to the secure Jaguar CAN driver.
//
#ifndef __JaguarCANDriver_h__
#define __JaguarCANDriver_h__
#if defined(__vxworks)
#include <vxWorks.h>
#else
#include <stdint.h>
#include <pthread.h>
#endif
#ifdef USE_THRIFT
#include "NetCommRPCComm.h"
#include <vector>
#endif
namespace nJaguarCANDriver
{
void sendMessage_wrapper(uint32_t messageID, const uint8_t *data, uint8_t dataSize, int32_t *status);
void receiveMessage_wrapper(uint32_t *messageID, uint8_t *data, uint8_t *dataSize, uint32_t timeoutMs, int32_t *status);
int32_t receiveMessageStart_wrapper(uint32_t messageID, uint32_t occurRefNum, uint32_t timeoutMs, int32_t *status);
#if defined (__vxworks)
int32_t receiveMessageStart_sem_wrapper(uint32_t messageID, uint32_t semaphoreID, uint32_t timeoutMs, int32_t *status);
#else
int32_t receiveMessageStart_mutex_wrapper(uint32_t messageID, pthread_mutex_t *mutex, uint32_t timeoutMs, int32_t *status);
#endif
void receiveMessageComplete_wrapper(uint32_t *messageID, uint8_t *data, uint8_t *dataSize, int32_t *status);
#ifdef USE_THRIFT
void checkEvent_CAN(std::vector< CANEvent >& events);
#endif
}
#ifdef __cplusplus
extern "C"
{
#endif
void FRC_NetworkCommunication_JaguarCANDriver_sendMessage(uint32_t messageID, const uint8_t *data, uint8_t dataSize, int32_t *status);
void FRC_NetworkCommunication_JaguarCANDriver_receiveMessage(uint32_t *messageID, uint8_t *data, uint8_t *dataSize, uint32_t timeoutMs, int32_t *status);
int32_t FRC_NetworkCommunication_JaguarCANDriver_receiveMessageStart(uint32_t messageID, uint32_t occurRefNum, uint32_t timeoutMs, int32_t *status);
#if defined (__vxworks)
int32_t FRC_NetworkCommunication_JaguarCANDriver_receiveMessageStart_sem(uint32_t messageID, uint32_t semaphoreID, uint32_t timeoutMs, int32_t *status);
#else
int32_t FRC_NetworkCommunication_JaguarCANDriver_receiveMessageStart_mutex(uint32_t messageID, pthread_mutex_t *mutex, uint32_t timeoutMs, int32_t *status);
#endif
void FRC_NetworkCommunication_JaguarCANDriver_receiveMessageComplete(uint32_t *messageID, uint8_t *data, uint8_t *dataSize, int32_t *status);
#ifdef __cplusplus
}
#endif
#endif // __JaguarCANDriver_h__

View File

@@ -15,6 +15,8 @@
#include "LiveWindow/LiveWindowSendable.h"
#include "tables/ITable.h"
#include <utility>
/**
* Luminary Micro Jaguar Speed Control
*/
@@ -43,7 +45,6 @@ public:
// SpeedController interface
virtual float Get();
virtual void Set(float value, uint8_t syncGroup=0);
void SetNoAck(float value, uint8_t syncGroup=0);
virtual void Disable();
// PIDOutput interface
@@ -71,7 +72,6 @@ public:
bool GetForwardLimitOK();
bool GetReverseLimitOK();
uint16_t GetFaults();
bool GetPowerCycled();
void SetVoltageRampRate(double rampRate);
virtual uint32_t GetFirmwareVersion();
uint8_t GetHardwareVersion();
@@ -105,18 +105,52 @@ protected:
int16_t unpackint16_t(uint8_t *buffer);
int32_t unpackint32_t(uint8_t *buffer);
virtual void setTransaction(uint32_t messageID, const uint8_t *data, uint8_t dataSize);
virtual void getTransaction(uint32_t messageID, uint8_t *data, uint8_t *dataSize);
virtual bool getTransaction(uint32_t messageID, uint8_t *data, uint8_t *dataSize);
static int32_t sendMessage(uint32_t messageID, const uint8_t *data, uint8_t dataSize);
//#define kTimeoutCan 0.02
#define kTimeoutCan 0.0
static int32_t receiveMessage(uint32_t *messageID, uint8_t *data, uint8_t *dataSize, float timeout = kTimeoutCan);
static int32_t receiveMessage(uint32_t *messageID, uint8_t *data, uint8_t *dataSize);
uint8_t m_deviceNumber;
ControlMode m_controlMode;
MUTEX_ID m_transactionSemaphore;
double m_maxOutputVoltage;
enum CANValue {
CAN_VALUE = 0x1,
CAN_SPEED_REFERENCE = 0x2,
CAN_POSITION_REFERENCE = 0x4,
CAN_P = 0x8, CAN_I = 0x10, CAN_D = 0x20,
CAN_BUS_VOLTAGE = 0x40,
CAN_OUTPUT_VOLTAGE = 0x80,
CAN_OUTPUT_CURRENT = 0x100,
CAN_TEMPERATURE = 0x200,
CAN_POSITION = 0x400,
CAN_SPEED = 0x800,
CAN_LIMITS = 0x1000,
CAN_FAULTS = 0x2000,
CAN_FIRMWARE_VERSION = 0x4000,
CAN_HARDWARE_VERSION = 0x8000,
CAN_EVERYTHING = 0xffff
};
bool isUnverified(CANValue value) const;
void verifyCANValues();
// Keep track of what cached CAN values have been verified.
CANValue m_verified_values;
// Cached CAN data
float m_value;
SpeedReference m_speedReference;
PositionReference m_positionReference;
double m_p, m_i, m_d;
float m_busVoltage, m_outputVoltage, m_outputCurrent, m_temperature;
double m_position, m_speed;
uint8_t m_limits;
uint16_t m_faults;
uint32_t m_firmwareVersion;
uint8_t m_hardwareVersion;
MotorSafetyHelper *m_safetyHelper;
void ValueChanged(ITable* source, const std::string& key, EntryValue value, bool isNew);
@@ -126,7 +160,7 @@ protected:
std::string GetSmartDashboardType();
void InitTable(ITable *subTable);
ITable * GetTable();
ITable *m_table;
private:

View File

@@ -11,7 +11,9 @@
#include <stdint.h>
#define CAN_IS_FRAME_REMOTE 0x80000000
#define CAN_MESSAGE_ID_MASK 0x1FFFFFFF
#define CAN_IS_FRAME_11BIT 0x40000000
#define CAN_29BIT_MESSAGE_ID_MASK 0x1FFFFFFF
#define CAN_11BIT_MESSAGE_ID_MASK 0x000007FF
class CANInterfacePlugin
{
@@ -56,6 +58,6 @@ public:
* @param interface A pointer to an object that inherits from CANInterfacePlugin and implements
* the pure virtual interface. If NULL, unregister the current plugin.
*/
void FRC_NetworkCommunication_JaguarCANDriver_registerInterface(CANInterfacePlugin* interface);
void FRC_NetworkCommunication_CANSessionMux_registerInterface(CANInterfacePlugin* interface);
#endif // __CANInterfacePlugin_h__

View File

@@ -0,0 +1,61 @@
// CANSessionMux.h
//
// Defines the API for building a CAN Interface Plugin to support
// PWM-cable-free CAN motor control on FRC robots. This allows you
// to connect any CAN interface to the secure Jaguar CAN driver.
//
#ifndef __CANSessionMux_h__
#define __CANSessionMux_h__
#if defined(__vxworks)
#include <vxWorks.h>
#else
#include <stdint.h>
#endif
#define CAN_SEND_PERIOD_NO_REPEAT 0
#define CAN_SEND_PERIOD_STOP_REPEATING -1
/* Flags in the upper bits of the messageID */
#define CAN_IS_FRAME_REMOTE 0x80000000
#define CAN_IS_FRAME_11BIT 0x40000000
#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
struct tCANStreamMessage{
uint32_t messageID;
uint32_t timeStamp;
uint8_t data[8];
uint8_t dataSize;
};
namespace nCANSessionMux
{
void sendMessage_wrapper(uint32_t messageID, const uint8_t *data, uint8_t dataSize, int32_t periodMs, int32_t *status);
void receiveMessage_wrapper(uint32_t *messageID, uint32_t messageIDMask, uint8_t *data, uint8_t *dataSize, uint32_t *timeStamp, int32_t *status);
void openStreamSession(uint32_t *sessionHandle, uint32_t messageID, uint32_t messageIDMask, uint32_t maxMessages, int32_t *status);
void closeStreamSession(uint32_t sessionHandle);
void readStreamSession(uint32_t sessionHandle, struct tCANStreamMessage *messages, uint32_t messagesToRead, uint32_t *messagesRead, int32_t *status);
}
#ifdef __cplusplus
extern "C"
{
#endif
void FRC_NetworkCommunication_CANSessionMux_sendMessage(uint32_t messageID, const uint8_t *data, uint8_t dataSize, int32_t periodMs, int32_t *status);
void FRC_NetworkCommunication_CANSessionMux_receiveMessage(uint32_t *messageID, uint32_t messageIDMask, uint8_t *data, uint8_t *dataSize, uint32_t *timeStamp, int32_t *status);
void FRC_NetworkCommunication_CANSessionMux_openStreamSession(uint32_t *sessionHandle, uint32_t messageID, uint32_t messageIDMask, uint32_t maxMessages, int32_t *status);
void FRC_NetworkCommunication_CANSessionMux_closeStreamSession(uint32_t sessionHandle);
void FRC_NetworkCommunication_CANSessionMux_readStreamSession(uint32_t sessionHandle, struct tCANStreamMessage *messages, uint32_t messagesToRead, uint32_t *messagesRead, int32_t *status);
#ifdef __cplusplus
}
#endif
#endif // __CANSessionMux_h__

View File

@@ -1,56 +0,0 @@
// JaguarCANDriver.h
//
// Defines the API for building a CAN Interface Plugin to support
// PWM-cable-free CAN motor control on FRC robots. This allows you
// to connect any CAN interface to the secure Jaguar CAN driver.
//
#ifndef __JaguarCANDriver_h__
#define __JaguarCANDriver_h__
#if defined(__vxworks)
#include <vxWorks.h>
#else
#include <stdint.h>
#include <pthread.h>
#endif
#ifdef USE_THRIFT
#include "NetCommRPCComm.h"
#include <vector>
#endif
namespace nJaguarCANDriver
{
void sendMessage_wrapper(uint32_t messageID, const uint8_t *data, uint8_t dataSize, int32_t *status);
void receiveMessage_wrapper(uint32_t *messageID, uint8_t *data, uint8_t *dataSize, uint32_t timeoutMs, int32_t *status);
int32_t receiveMessageStart_wrapper(uint32_t messageID, uint32_t occurRefNum, uint32_t timeoutMs, int32_t *status);
#if defined (__vxworks)
int32_t receiveMessageStart_sem_wrapper(uint32_t messageID, uint32_t semaphoreID, uint32_t timeoutMs, int32_t *status);
#else
int32_t receiveMessageStart_mutex_wrapper(uint32_t messageID, pthread_mutex_t *mutex, uint32_t timeoutMs, int32_t *status);
#endif
void receiveMessageComplete_wrapper(uint32_t *messageID, uint8_t *data, uint8_t *dataSize, int32_t *status);
#ifdef USE_THRIFT
void checkEvent_CAN(std::vector< CANEvent >& events);
#endif
}
#ifdef __cplusplus
extern "C"
{
#endif
void FRC_NetworkCommunication_JaguarCANDriver_sendMessage(uint32_t messageID, const uint8_t *data, uint8_t dataSize, int32_t *status);
void FRC_NetworkCommunication_JaguarCANDriver_receiveMessage(uint32_t *messageID, uint8_t *data, uint8_t *dataSize, uint32_t timeoutMs, int32_t *status);
int32_t FRC_NetworkCommunication_JaguarCANDriver_receiveMessageStart(uint32_t messageID, uint32_t occurRefNum, uint32_t timeoutMs, int32_t *status);
#if defined (__vxworks)
int32_t FRC_NetworkCommunication_JaguarCANDriver_receiveMessageStart_sem(uint32_t messageID, uint32_t semaphoreID, uint32_t timeoutMs, int32_t *status);
#else
int32_t FRC_NetworkCommunication_JaguarCANDriver_receiveMessageStart_mutex(uint32_t messageID, pthread_mutex_t *mutex, uint32_t timeoutMs, int32_t *status);
#endif
void FRC_NetworkCommunication_JaguarCANDriver_receiveMessageComplete(uint32_t *messageID, uint8_t *data, uint8_t *dataSize, int32_t *status);
#ifdef __cplusplus
}
#endif
#endif // __JaguarCANDriver_h__

View File

@@ -26,7 +26,7 @@ namespace nUsageReporting
kResourceType_CANPlugin,
kResourceType_Accelerometer,
kResourceType_ADXL345,
kResourceType_AnalogInput,
kResourceType_AnalogChannel,
kResourceType_AnalogTrigger,
kResourceType_AnalogTriggerOutput,
kResourceType_CANJaguar,