You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.3 KiB
59 lines
1.3 KiB
#ifndef __SERIALPORT_H_INCL__
|
|
#define __SERIALPORT_H_INCL__
|
|
|
|
#include <errno.h> // Error number definitions
|
|
#include <fcntl.h> // File control definitions
|
|
#include <stdio.h> // standard input / output functions
|
|
#include <stdlib.h>
|
|
#include <string.h> // string function definitions
|
|
#ifdef __linux__
|
|
#include <termios.h> // POSIX terminal control definitions
|
|
#include <unistd.h> // UNIX standard function definitions
|
|
#else
|
|
|
|
#endif
|
|
|
|
#include "../../data/transport/transportSerial.h"
|
|
#ifdef DEBUG_EXTRA
|
|
// #ifdef DEBUG_COMMUNICATION
|
|
// #define DEBUG_SERIAL_COMMUNICATION
|
|
// #endif
|
|
#endif
|
|
|
|
/**
|
|
* TODO: Add class description
|
|
*
|
|
* @author gagua
|
|
*/
|
|
class serialPort : public transportSerial
|
|
{
|
|
private:
|
|
|
|
basicLogCollection * m_pLog;
|
|
#ifdef __linux__
|
|
struct termios m_sTTY;
|
|
int m_iInFID;
|
|
int m_iOutFID;
|
|
#else
|
|
DCB PortDCB;
|
|
HANDLE m_ioFID;
|
|
#endif
|
|
CSTR m_sDevicePath;
|
|
int m_iLineSpeed;
|
|
bool m_bInitComplete;
|
|
bool HW_init(CSTR DevicePath, int Speed);
|
|
|
|
protected:
|
|
|
|
int sendBlock(unsigned char * Data, int DataSize);
|
|
int recptBlock(unsigned char * Buffer, int * BufferLength);
|
|
|
|
public:
|
|
|
|
serialPort();
|
|
serialPort(CSTR DevicePath, int Speed);
|
|
virtual ~serialPort();
|
|
bool create(CSTR DevicePath, int Speed);
|
|
};
|
|
|
|
#endif // __SERIALPORT_H_INCL__
|