File: gsm_port.h

package info (click to toggle)
gsmlib 1.10+20120414.gita5e5ae9a-0.3
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 3,468 kB
  • ctags: 1,907
  • sloc: cpp: 12,315; sh: 11,376; ansic: 2,366; makefile: 263; sed: 93
file content (56 lines) | stat: -rw-r--r-- 1,561 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
// *************************************************************************
// * GSM TA/ME library
// *
// * File:    gsm_port.h
// *
// * Purpose: Abstract port definition
// *
// * Author:  Peter Hofmann (software@pxh.de)
// *
// * Created: 3.5.1999
// *************************************************************************

#ifndef GSM_PORT_H
#define GSM_PORT_H

#include <gsmlib/gsm_error.h>
#include <gsmlib/gsm_util.h>
#include <string>

namespace gsmlib
{
  // TA defaults
  const int TIMEOUT_SECS = 60;
  const char DEFAULT_INIT_STRING[] = "E0";
  const int DEFAULT_BAUD_RATE = 38400;

  class Port : public RefBase
  {
  public:
    // read line from port(including eol characters)
    virtual std::string getLine() throw(GsmException) =0;
    
    // write line to port
    virtual void putLine(std::string line,
                         bool carriageReturn = true) throw(GsmException) =0;

    // wait for new data to become available, return after timeout
    // if timeout == 0, wait forever
    // return true if data available
    virtual bool wait(GsmTime timeout) throw(GsmException) =0;

    // put back one byte that can be read by a subsequent call to readByte()
    virtual void putBack(unsigned char c) =0;

    // read a single byte, return -1 if error or file closed
    virtual int readByte() throw(GsmException) =0;

    // set timeout for the readByte(), getLine(), and putLine() functions
    // (globally for ALL ports)
    virtual void setTimeOut(unsigned int timeout) =0;

    virtual ~Port() {}
  };
};

#endif // GSM_PORT_H