• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.12
  • kdeedu
  • marble
  • src
  • plugins
  • render
  • aprs
AprsTTY.cpp
Go to the documentation of this file.
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2010 Wes Hardaker <hardaker@users.sourceforge.net>
9 //
10 
11 #include "AprsTTY.h"
12 
13 #include <qextserialport.h>
14 
15 #include "MarbleDebug.h"
16 
17 #include "AprsGatherer.h"
18 
19 using namespace Marble;
20 
21 AprsTTY::AprsTTY( QString ttyName )
22  : m_ttyName( ttyName ),
23  m_numErrors( 0 )
24 {
25 }
26 
27 AprsTTY::~AprsTTY()
28 {
29 }
30 
31 QString
32 AprsTTY::sourceName() const
33 {
34  return QString( "TTY" );
35 }
36 
37 bool
38 AprsTTY::canDoDirect() const
39 {
40  return true;
41 }
42 
43 QIODevice *
44 AprsTTY::openSocket()
45 {
46  QextSerialPort *m_port =
47  new QextSerialPort( m_ttyName, QextSerialPort::Polling );
48  m_port->setBaudRate( BAUD9600 );
49  m_port->setParity( PAR_NONE );
50  m_port->setDataBits( DATA_8 );
51  m_port->setStopBits( STOP_1 );
52  m_port->setTimeout( 60000 ); // ms
53  m_port->open( QIODevice::ReadWrite );
54  mDebug() << "opened TTY socket";
55  if ( m_port->isOpen() ) {
56  mDebug() << "connected to " << m_ttyName.toLocal8Bit().data();
57  } else {
58  delete m_port;
59  m_port = 0;
60  mDebug() << "**** failed to open terminal " << m_ttyName.toLocal8Bit().data() << " ****";
61  }
62  return m_port;
63 }
64 
65 void
66 AprsTTY::checkReadReturn( int length, QIODevice **socket,
67  AprsGatherer *gatherer )
68 {
69  if ( length < 0 || ( length == 0 && m_numErrors > 5 ) ) {
70  // hard error. try reopening
71  mDebug() << "**** restarting TTY socket";
72  delete *socket;
73  gatherer->sleepFor( 1 );
74  *socket = openSocket();
75  return;
76  }
77  if ( length == 0 ) {
78  ++m_numErrors;
79  mDebug() << "**** Odd: read zero bytes from TTY socket";
80  return;
81  }
82  return;
83 }
84 
Marble::AprsTTY::sourceName
QString sourceName() const
Definition: AprsTTY.cpp:32
MarbleDebug.h
AprsGatherer.h
AprsTTY.h
Marble::AprsTTY::openSocket
QIODevice * openSocket()
Definition: AprsTTY.cpp:44
Marble::AprsTTY::checkReadReturn
void checkReadReturn(int length, QIODevice **socket, AprsGatherer *gatherer)
Definition: AprsTTY.cpp:66
Marble::AprsTTY::canDoDirect
bool canDoDirect() const
Definition: AprsTTY.cpp:38
Marble::AprsTTY::~AprsTTY
~AprsTTY()
Definition: AprsTTY.cpp:27
Marble::AprsTTY::AprsTTY
AprsTTY(QString ttyName)
Definition: AprsTTY.cpp:21
Marble::AprsGatherer::sleepFor
void sleepFor(int seconds)
Definition: AprsGatherer.cpp:285
Marble::AprsSource::socket
QIODevice * socket()
Definition: AprsSource.cpp:25
Marble::AprsGatherer
Definition: AprsGatherer.h:26
Marble::mDebug
QDebug mDebug()
a function to replace qDebug() in Marble library code
Definition: MarbleDebug.cpp:31
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:49 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal