93 lines
1.7 KiB
C++
93 lines
1.7 KiB
C++
//
|
|
// Serial Daemon
|
|
// Neal Probert
|
|
//
|
|
|
|
/* prevent multiple inclusions */
|
|
#ifndef __SerialDaemon__
|
|
#define __SerialDaemon__
|
|
|
|
/* includes *****************************************************************/
|
|
|
|
#include "bzlib.h"
|
|
|
|
#include "TcpDaemon.h"
|
|
#include "TcpClient.h"
|
|
#include "UdpClient.h"
|
|
#include "UdpCaster.h"
|
|
|
|
#include "LogData.h"
|
|
|
|
/* defines ******************************************************************/
|
|
|
|
#define SERIALD_NAME "seriald"
|
|
#define SERIALD_SERVICE "seriald"
|
|
#define SERIALD_PORT "2942"
|
|
|
|
/* macros *******************************************************************/
|
|
|
|
/* structs & typedefs *******************************************************/
|
|
|
|
/* c class definitions ******************************************************/
|
|
|
|
//
|
|
// Uses the Peak Systems CAN Linux driver and Nissan CAN data
|
|
//
|
|
class SerialDaemon : public TcpDaemon {
|
|
// public data
|
|
public:
|
|
|
|
// private data
|
|
private:
|
|
// FDs
|
|
int m_SerialIn;
|
|
int m_RemoteIn;
|
|
int m_DgramIn;
|
|
|
|
// TCP client
|
|
TcpClient Client;
|
|
|
|
// UDP listen
|
|
UdpClient Dgram;
|
|
|
|
// UDP broadcast
|
|
UdpCaster Bcast;
|
|
|
|
// misc
|
|
int m_framed;
|
|
char m_Framing[8];
|
|
|
|
// private methods
|
|
|
|
// static data
|
|
|
|
// public methods
|
|
public:
|
|
// constructors
|
|
SerialDaemon();
|
|
|
|
// destructor
|
|
virtual ~SerialDaemon();
|
|
|
|
// virtual functions
|
|
int ServerSocket(void);
|
|
int ClientIn( int sock, const char *buf, int n );
|
|
void ClientCast( const char *buf, int n );
|
|
|
|
// public methods
|
|
int SerialOpen( const char *dev, int baud );
|
|
int TcpConnect( const char *uri );
|
|
|
|
int UdpBroadcast( const char *uri );
|
|
int UdpListen( const char *uri );
|
|
|
|
void SetFrame( const char *frame, int n=0 );
|
|
|
|
// static methods
|
|
|
|
// private methods
|
|
private:
|
|
};
|
|
|
|
#endif
|