mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
CMake Changes
This is the changes made by Patrick Plenefisch converting the native code to use CMake and the CMake Maven Plugin, as opposed to the native Maven plugin. This is to allow for compatibility with newer versions of the GCC toolchain. All the cpp sources were moved from maven style directories to cpp style directories for CMake. Change-Id: I67f5e3608948f37c83b0990d232105a3784f8593
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* BadMessageException.h
|
||||
*
|
||||
* Created on: Sep 16, 2012
|
||||
* Author: Mitchell Wills
|
||||
*/
|
||||
|
||||
#ifndef BADMESSAGEEXCEPTION_H_
|
||||
#define BADMESSAGEEXCEPTION_H_
|
||||
|
||||
#include <exception>
|
||||
#include <string>
|
||||
|
||||
class BadMessageException : public std::exception
|
||||
{
|
||||
public:
|
||||
BadMessageException(const char* message);
|
||||
~BadMessageException() throw ();
|
||||
const char* what();
|
||||
private:
|
||||
std::string message;
|
||||
};
|
||||
|
||||
#endif /* BADMESSAGEEXCEPTION_H_ */
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* ConnectionAdapter.h
|
||||
*
|
||||
* Created on: Sep 16, 2012
|
||||
* Author: Mitchell Wills
|
||||
*/
|
||||
|
||||
#ifndef CONNECTIONADAPTER_H_
|
||||
#define CONNECTIONADAPTER_H_
|
||||
|
||||
class ConnectionAdapter;
|
||||
|
||||
#include "networktables2/NetworkTableEntry.h"
|
||||
#include "networktables2/connection/BadMessageException.h"
|
||||
#include "networktables2/util/IOException.h"
|
||||
#include "tables/ITable.h"
|
||||
|
||||
class ConnectionAdapter
|
||||
{
|
||||
public:
|
||||
virtual ~ConnectionAdapter()
|
||||
{
|
||||
}
|
||||
//returns true if the connection should still be alive
|
||||
virtual bool keepAlive() = 0;
|
||||
virtual void clientHello(ProtocolVersion protocolRevision) = 0;
|
||||
virtual void serverHelloComplete() = 0;
|
||||
virtual void protocolVersionUnsupported(ProtocolVersion protocolRevision) = 0;
|
||||
virtual void offerIncomingAssignment(NetworkTableEntry* newEntry) = 0;
|
||||
virtual void offerIncomingUpdate(NetworkTableEntry* newEntry, SequenceNumber sequenceNumber, EntryValue value) = 0;
|
||||
virtual NetworkTableEntry* GetEntry(EntryId) = 0;
|
||||
|
||||
/**
|
||||
* called if a bad message exception is thrown
|
||||
* @param e
|
||||
*/
|
||||
virtual void badMessage(BadMessageException& e) = 0;
|
||||
|
||||
/**
|
||||
* called if an io exception is thrown
|
||||
* @param e
|
||||
*/
|
||||
virtual void ioException(IOException& e) = 0;
|
||||
};
|
||||
|
||||
#endif /* CONNECTIONADAPTER_H_ */
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* ConnectionMonitorThread.h
|
||||
*
|
||||
* Created on: Sep 22, 2012
|
||||
* Author: Mitchell Wills
|
||||
*/
|
||||
|
||||
#ifndef CONNECTIONMONITORTHREAD_H_
|
||||
#define CONNECTIONMONITORTHREAD_H_
|
||||
|
||||
|
||||
class ConnectionMonitorThread;
|
||||
|
||||
#include "networktables2/connection/ConnectionAdapter.h"
|
||||
#include "networktables2/connection/NetworkTableConnection.h"
|
||||
#include "networktables2/thread/PeriodicRunnable.h"
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A periodic thread that repeatedly reads from a connection
|
||||
* @author Mitchell
|
||||
*
|
||||
*/
|
||||
class ConnectionMonitorThread : public PeriodicRunnable{
|
||||
private:
|
||||
ConnectionAdapter& adapter;
|
||||
NetworkTableConnection& connection;
|
||||
|
||||
public:
|
||||
/**
|
||||
* create a new monitor thread
|
||||
* @param adapter
|
||||
* @param connection
|
||||
*/
|
||||
ConnectionMonitorThread(ConnectionAdapter& adapter, NetworkTableConnection& connection);
|
||||
//This can be used it identify which connection adapter instance the thread procedure is running (read-only)
|
||||
const NetworkTableConnection *GetNetworkTableConnection() const {return &connection;}
|
||||
|
||||
void run();
|
||||
};
|
||||
|
||||
|
||||
#endif /* CONNECTIONMONITORTHREAD_H_ */
|
||||
@@ -0,0 +1,51 @@
|
||||
#ifndef DATAIOSTREAM_H_
|
||||
#define DATAIOSTREAM_H_
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "networktables2/stream/IOStream.h"
|
||||
#include <exception>
|
||||
#include <string>
|
||||
|
||||
#ifndef _WRS_KERNEL
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <memory>
|
||||
|
||||
//WindRiver is 3.4 GCC. Recent GCC can do 0b01010101 style format, WR cannot
|
||||
|
||||
#define TO_HEX__(n) 0x##n##LU // LU for unsigned long
|
||||
#define BINARY_LITERAL_VIA_HEX__(n) (((n & 0x00000001LU) ? 1 : 0)\
|
||||
+ ((n & 0x00000010LU) ? 2 : 0) \
|
||||
+ ((n & 0x00000100LU) ? 4 : 0) \
|
||||
+ ((n & 0x00001000LU) ? 8 : 0) \
|
||||
+ ((n & 0x00010000LU) ? 16 : 0) \
|
||||
+ ((n & 0x00100000LU) ? 32 : 0) \
|
||||
+ ((n & 0x01000000LU) ? 64 : 0) \
|
||||
+ ((n & 0x10000000LU) ? 128 : 0))
|
||||
|
||||
#define b(n) ((unsigned char)BINARY_LITERAL_VIA_HEX__(TO_HEX__(n)))
|
||||
|
||||
class DataIOStream{
|
||||
public:
|
||||
DataIOStream(IOStream* stream);
|
||||
virtual ~DataIOStream();
|
||||
void writeByte(uint8_t b);
|
||||
void write2BytesBE(uint16_t s);
|
||||
void writeString(std::string& str);
|
||||
void flush();
|
||||
|
||||
uint8_t readByte();
|
||||
uint16_t read2BytesBE();
|
||||
std::string* readString();
|
||||
|
||||
void close();
|
||||
void SetIOStream(IOStream* stream);
|
||||
|
||||
//private:
|
||||
IOStream *iostream;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* An abstraction for the NetworkTable protocol
|
||||
*
|
||||
* @author mwills
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef NETWORK_TABLE_CONNECTION_H_
|
||||
#define NETWORK_TABLE_CONNECTION_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "OSAL/Synchronized.h"
|
||||
#ifndef _WRS_KERNEL
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
class NetworkTableConnection;
|
||||
typedef uint16_t ProtocolVersion;
|
||||
|
||||
#include "networktables2/connection/DataIOStream.h"
|
||||
#include "networktables2/NetworkTableEntry.h"
|
||||
#include "networktables2/type/NetworkTableEntryType.h"
|
||||
#include "networktables2/type/NetworkTableEntryTypeManager.h"
|
||||
#include "networktables2/connection/ConnectionAdapter.h"
|
||||
#include "networktables2/NetworkTableMessageType.h"
|
||||
|
||||
|
||||
class NetworkTableConnection{
|
||||
public:
|
||||
static const ProtocolVersion PROTOCOL_REVISION = 0x0200;
|
||||
|
||||
NetworkTableConnection(IOStream* stream, NetworkTableEntryTypeManager& typeManager);
|
||||
~NetworkTableConnection();
|
||||
void close();
|
||||
void flush();
|
||||
void sendKeepAlive();
|
||||
void sendClientHello();
|
||||
void sendServerHelloComplete();
|
||||
void sendProtocolVersionUnsupported();
|
||||
void sendEntryAssignment(NetworkTableEntry& entry);
|
||||
void sendEntryUpdate(NetworkTableEntry& entry);
|
||||
void read(ConnectionAdapter& adapter);
|
||||
void SetIOStream(IOStream* stream);
|
||||
private:
|
||||
NTReentrantSemaphore WRITE_LOCK;
|
||||
DataIOStream* const ioStream;
|
||||
NetworkTableEntryTypeManager& typeManager;
|
||||
bool isValid;
|
||||
|
||||
void sendMessageHeader(NetworkTableMessageType messageType);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user