File: datacontroller.h

package info (click to toggle)
serialdv 1.1.4-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 540 kB
  • sloc: cpp: 1,553; makefile: 2
file content (66 lines) | stat: -rw-r--r-- 2,506 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2019 Edouard Griffiths, F4EXB.                                  //
//                                                                               //
// This program is free software; you can redistribute it and/or modify          //
// it under the terms of the GNU General Public License as published by          //
// the Free Software Foundation as version 3 of the License, or                  //
//                                                                               //
// This program is distributed in the hope that it will be useful,               //
// but WITHOUT ANY WARRANTY; without even the implied warranty of                //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the                  //
// GNU General Public License V3 for more details.                               //
//                                                                               //
// You should have received a copy of the GNU General Public License             //
// along with this program. If not, see <http://www.gnu.org/licenses/>.          //
///////////////////////////////////////////////////////////////////////////////////

#ifndef DATACONTROLLER_H_
#define DATACONTROLLER_H_

#include <string>
#include "serialdv_export.h"

namespace SerialDV
{

const unsigned int MBE_AUDIO_BLOCK_SIZE_INTERNAL  = 160U;
const unsigned int MBE_AUDIO_BLOCK_BYTES_INTERNAL = MBE_AUDIO_BLOCK_SIZE_INTERNAL * 2U;
const unsigned int MBE_FRAME_MAX_LENGTH_BYTES_INTERNAL = 18U;

enum SERIAL_SPEED {
	SERIAL_NONE   = 0,
    SERIAL_1200   = 1200,
    SERIAL_2400   = 2400,
    SERIAL_4800   = 4800,
    SERIAL_9600   = 9600,
    SERIAL_19200  = 19200,
    SERIAL_38400  = 38400,
    SERIAL_76800  = 76800,
    SERIAL_115200 = 115200,
    SERIAL_230400 = 230400,
    SERIAL_460800 = 460800
};

class SERIALDV_API DataController {
public:
    DataController();
    virtual ~DataController();

    virtual bool open(const std::string& device, SERIAL_SPEED speed) = 0;

    virtual bool initResponse() = 0;
    virtual int  read(unsigned char* buffer, unsigned int lengthInBytes) = 0;
    virtual int  write(const unsigned char* buffer, unsigned int lengthInBytes) = 0;

    virtual void closeIt() = 0;

#ifdef __WINDOWS__
    static const unsigned int BUFFER_LENGTH = 1000U;
#else
    static const unsigned int BUFFER_LENGTH = 400U;
#endif
};

} // namespace SerialDV

#endif // DATACONTROLLER_H_