DUNE: Uniform Navigational Environment  2016.05.0
DUNE::Hardware::BasicModem Class Reference

Public Member Functions

 BasicModem (Tasks::Task *task, IO::Handle *handle)
 
virtual ~BasicModem (void)
 
void initialize (void)
 
void setLineTermIn (const std::string &term)
 
const std::string & getLineTermIn (void)
 
void setLineTermOut (const std::string &str)
 
const std::string & getLineTermOut (void)
 
void setLineTrim (bool enable)
 
void setTxRateMax (double rate)
 
bool isBusy (void)
 
bool isCooling (void)
 
void setBusy (bool value)
 
- Public Member Functions inherited from DUNE::Concurrency::Thread
 Thread (void)
 
virtual ~Thread (void)
 
int getProcessorUsage (void)
 
- Public Member Functions inherited from DUNE::Concurrency::Runnable
 Runnable (void)
 
virtual ~Runnable (void)
 
void start (void)
 
void stop (void)
 
void join (void)
 
void stopAndJoin (void)
 
void setPriority (Scheduler::Policy policy, unsigned priority)
 
State getState (void)
 
bool isCreated (void)
 
bool isStopping (void)
 
bool isRunning (void)
 
bool isStarting (void)
 
bool isDead (void)
 

Protected Types

enum  ReadMode { READ_MODE_LINE, READ_MODE_RAW }
 

Protected Member Functions

virtual bool handleUnsolicited (const std::string &str)
 
virtual void sendInitialization (void)
 
virtual void sendReset (void)
 
virtual bool isFragment (const std::string &str)
 
void sendRaw (const uint8_t *data, unsigned data_size)
 
void send (const std::string &str)
 
void setTimeout (double timeout)
 
double getTimeout (void)
 
void expect (const std::string &str)
 
void readRaw (Time::Counter< double > &timer, uint8_t *data, unsigned data_size)
 
ReadMode getReadMode (void)
 
void setReadMode (ReadMode mode)
 
void flushInput (void)
 
std::string readLine (void)
 
std::string readLine (Time::Counter< double > &timer)
 
Tasks::TaskgetTask (void)
 
void setSkipLine (const std::string &line)
 
- Protected Member Functions inherited from DUNE::Concurrency::Thread
void startImpl (void)
 
void stopImpl (void)
 
void joinImpl (void)
 
void setPriorityImpl (Scheduler::Policy policy, unsigned priority)
 

Protected Attributes

Concurrency::Mutex m_mutex
 
IO::Handlem_handle
 
std::string m_last_cmd
 

Additional Inherited Members

- Public Types inherited from DUNE::Concurrency::Runnable
enum  State {
  StateStarting, StateRunning, StateStopping, StateDead,
  StateUnknown
}
 

Member Enumeration Documentation

Read mode.

Enumerator
READ_MODE_LINE 

Line oriented input.

READ_MODE_RAW 

Unprocessed sequence of bytes.

Constructor & Destructor Documentation

DUNE::Hardware::BasicModem::BasicModem ( Tasks::Task task,
IO::Handle handle 
)

Constructor.

Parameters
[in]taskparent task.
[in]handleI/O handle.

References DUNE::IO::Handle::flushInput(), and m_handle.

virtual DUNE::Hardware::BasicModem::~BasicModem ( void  )
inlinevirtual

Member Function Documentation

void DUNE::Hardware::BasicModem::expect ( const std::string &  str)
protected

References readLine().

void DUNE::Hardware::BasicModem::flushInput ( void  )
protected
const std::string & DUNE::Hardware::BasicModem::getLineTermIn ( void  )

References m_mutex.

const std::string & DUNE::Hardware::BasicModem::getLineTermOut ( void  )

References m_mutex.

Referenced by DUNE::Hardware::HayesModem::sendAT().

BasicModem::ReadMode DUNE::Hardware::BasicModem::getReadMode ( void  )
protected

References m_mutex.

Tasks::Task* DUNE::Hardware::BasicModem::getTask ( void  )
inlineprotected
double DUNE::Hardware::BasicModem::getTimeout ( void  )
protected

References m_mutex.

Referenced by readLine().

virtual bool DUNE::Hardware::BasicModem::handleUnsolicited ( const std::string &  str)
inlineprotectedvirtual

Handle unsolicited or asynchronous commands.

Parameters
[in]strcommand string.
Returns
true if command was handled, false otherwise.
bool DUNE::Hardware::BasicModem::isBusy ( void  )

Test if the modem is busy.

Test if ISU is busy performing an SBD session.

Returns
true if the modem is busy, false otherwise.
true if ISU is busy, false otherwise.

References m_mutex.

bool DUNE::Hardware::BasicModem::isCooling ( void  )

Test if the modem is cooling down.

Test if ISU is cooling down.

Returns
true if the modem is cooling down, false otherwise.
true if ISU is cooling down, false otherwise.

References m_mutex, and DUNE::Time::Counter< T >::overflow().

virtual bool DUNE::Hardware::BasicModem::isFragment ( const std::string &  str)
inlineprotectedvirtual

Test if command is not complete (i.e.

is a fragment). This method is useful when the protocol allows mixing ASCII with binary data.

Parameters
[in]strcommand string.
Returns
true if command is a fragment, false otherwise.
std::string DUNE::Hardware::BasicModem::readLine ( void  )
protected
std::string DUNE::Hardware::BasicModem::readLine ( Time::Counter< double > &  timer)
protected
void DUNE::Hardware::BasicModem::readRaw ( Time::Counter< double > &  timer,
uint8_t *  data,
unsigned  data_size 
)
protected
void DUNE::Hardware::BasicModem::send ( const std::string &  str)
protected
virtual void DUNE::Hardware::BasicModem::sendInitialization ( void  )
inlineprotectedvirtual

Reimplemented in DUNE::Hardware::HayesModem.

Referenced by initialize().

void DUNE::Hardware::BasicModem::sendRaw ( const uint8_t *  data,
unsigned  data_size 
)
protected

References m_handle, and DUNE::IO::Handle::write().

Referenced by send().

virtual void DUNE::Hardware::BasicModem::sendReset ( void  )
inlineprotectedvirtual

Reimplemented in DUNE::Hardware::HayesModem.

Referenced by initialize().

void DUNE::Hardware::BasicModem::setBusy ( bool  value)
void DUNE::Hardware::BasicModem::setLineTermIn ( const std::string &  term)

Set line termination for modem to CPU commands.

Parameters
[in]termline terminator.

References m_mutex.

void DUNE::Hardware::BasicModem::setLineTermOut ( const std::string &  str)

Set line termination for CPU to modem commands.

Parameters
[in]strline terminator.

References m_mutex.

void DUNE::Hardware::BasicModem::setLineTrim ( bool  enable)

Remove leading and trailing blank characters from lines.

Parameters
[in]enabletrue to enable trimming, false otherwise.

References m_mutex.

void DUNE::Hardware::BasicModem::setReadMode ( BasicModem::ReadMode  mode)
protected
void DUNE::Hardware::BasicModem::setSkipLine ( const std::string &  line)
protected
void DUNE::Hardware::BasicModem::setTimeout ( double  timeout)
protected

References m_mutex.

void DUNE::Hardware::BasicModem::setTxRateMax ( double  rate)

Set maximum transmission rate.

Parameters
[in]ratetransmission rate in second. Negative values will disable transmission rate control.
[in]ratetransmission rate in second. Negative values will disable transmission rate cap.

References m_mutex, and DUNE::Time::Counter< T >::setTop().

Member Data Documentation

IO::Handle* DUNE::Hardware::BasicModem::m_handle
protected
std::string DUNE::Hardware::BasicModem::m_last_cmd
protected

Last command sent to modem.

Referenced by readLine(), and DUNE::Hardware::HayesModem::sendAT().

Collaboration diagram for DUNE::Hardware::BasicModem:
Collaboration graph