~ubuntu-branches/debian/jessie/gsmlib/jessie

« back to all changes in this revision

Viewing changes to gsmlib/gsm_win32_serial.cc

  • Committer: Package Import Robot
  • Author(s): Andrew Shadura
  • Date: 2013-10-15 13:29:27 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20131015132927-1i5iwvj21wue3uvu
Tags: 1.10+20120414.gita5e5ae9a-0.1
* Non-maintainer upload.
* Update to the latest Git version by Vianney Bouchaud.
* Use 3.0 (quilt) source package format.
* Own the run subdirectory (Closes: #689891).
* Don't remove the system user on package remove.
* Fix init script (LP: #30228).

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#include <gsmlib/gsm_util.h>
20
20
#include <fcntl.h>
21
21
#include <iostream>
22
 
#include <strstream>
 
22
#include <sstream>
23
23
#include <errno.h>
24
24
#include <stdio.h>
25
25
#include <assert.h>
26
26
#include <signal.h>
27
27
 
28
 
using namespace std;
29
28
using namespace gsmlib;
30
29
 
31
30
static long int timeoutVal = TIMEOUT_SECS;
57
56
    if (CancelIoProc)
58
57
      return CancelIoProc(file);
59
58
  }
60
 
                         
 
59
 
61
60
  return TRUE;
62
61
}
63
62
#define CancelIo CancelIoHook
64
63
 
65
64
// Win32SerialPort members
66
65
 
67
 
void Win32SerialPort::throwModemException(string message) throw(GsmException)
 
66
void Win32SerialPort::throwModemException(std::string message) throw(GsmException)
68
67
{
69
68
  ostrstream os;
70
69
  os << message << " (errno: " << errno << "/" << strerror(errno) << ")"
71
70
     << ends;
72
71
  char *ss = os.str();
73
 
  string s(ss);
 
72
  std::string s(ss);
74
73
  delete[] ss;
75
74
  throw GsmException(s, OSError, errno);
76
75
}
155
154
  return c;
156
155
}
157
156
 
158
 
Win32SerialPort::Win32SerialPort(string device, int lineSpeed,
159
 
                               string initString, bool swHandshake)
 
157
Win32SerialPort::Win32SerialPort(std::string device, int lineSpeed,
 
158
                               std::string initString, bool swHandshake)
160
159
  throw(GsmException) :
161
160
  _oldChar(-1)
162
161
{
262
261
      int readTries = 5;
263
262
      while (readTries-- > 0)
264
263
      {
265
 
        string s = getLine();
 
264
        std::string s = getLine();
266
265
        if (s.find("OK") != string::npos ||
267
266
            s.find("CABLE: GSM") != string::npos)
268
267
        {
277
276
        readTries = 5;
278
277
        // !!! no not declare this in loop, compiler error on Visual C++
279
278
        // (without SP and with SP4)
280
 
        string s; 
 
279
        std::string s; 
281
280
        putLine("AT" + initString);
282
281
        do
283
282
        {
308
307
 
309
308
string Win32SerialPort::getLine() throw(GsmException)
310
309
{
311
 
  string result;
 
310
  std::string result;
312
311
  int c;
313
312
  while ((c = readByte()) > 0)
314
313
  {
329
328
  return result;
330
329
}
331
330
 
332
 
void Win32SerialPort::putLine(string line,
 
331
void Win32SerialPort::putLine(std::string line,
333
332
                             bool carriageReturn) throw(GsmException)
334
333
{
335
334
#ifndef NDEBUG
479
478
    CloseHandle(_file);
480
479
}
481
480
 
482
 
int gsmlib::baudRateStrToSpeed(string baudrate) throw(GsmException)
 
481
int gsmlib::baudRateStrToSpeed(std::string baudrate) throw(GsmException)
483
482
{
484
483
  if (baudrate == "300")
485
484
    return 300;