File: serialport.h

package info (click to toggle)
freedv 1.3.1-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,440 kB
  • sloc: cpp: 8,723; ansic: 3,564; python: 42; makefile: 10; sh: 7
file content (42 lines) | stat: -rw-r--r-- 968 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef SERIALPORT_H
#define SERIALPORT_H

#ifdef _WIN32
#include <windows.h>
#else
#include <termios.h>
#include <sys/ioctl.h>
#include <dlfcn.h>
#endif

// Serial ports called com port for historic reasons, especially on Windows machines 

#ifdef _WIN32
#define COM_HANDLE_INVALID			INVALID_HANDLE_VALUE
typedef HANDLE      com_handle_t;
#else
#define COM_HANDLE_INVALID			-1
typedef int         com_handle_t;
#endif

class Serialport {

    public:
        Serialport();
        ~Serialport();
        bool openport(const char port[], bool useRTS, bool RTSPos, bool useDTR, bool DTRPos);
        bool isopen() {return (com_handle != COM_HANDLE_INVALID);}
        void closeport();
        void ptt(bool tx);

    private:
        com_handle_t  com_handle;
        bool          m_useRTS, m_RTSPos, m_useDTR, m_DTRPos;

        void raiseDTR(void);
        void lowerDTR(void);
        void raiseRTS(void);
        void lowerRTS(void);
};

#endif /* SERIALPORT_H */