DUNE: Uniform Navigational Environment  2019.02.1
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)
 
unsigned getPriority (void)
 
State getState (void)
 
bool isCreated (void)
 
bool isStopping (void)
 
bool isRunning (void)
 
bool isStarting (void)
 
bool isDead (void)
 

Protected Types

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)
 
unsigned getPriorityImpl (void)
 

Protected Attributes

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

Additional Inherited Members

- Public Types inherited from DUNE::Concurrency::Runnable

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().

Referenced by isFragment().

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

References m_mutex.

Referenced by ~BasicModem().

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

References m_mutex.

Referenced by flushInput(), and isFragment().

double DUNE::Hardware::BasicModem::getTimeout ( void  )
protected

References m_mutex.

Referenced by isFragment(), and 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.

Referenced by flushInput().

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.

Referenced by ~BasicModem().

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().

Referenced by ~BasicModem().

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.

References expect(), flushInput(), getReadMode(), getTimeout(), readLine(), readRaw(), send(), sendRaw(), setReadMode(), and setTimeout().

Referenced by readRaw().

std::string DUNE::Hardware::BasicModem::readLine ( void  )
protected
std::string DUNE::Hardware::BasicModem::readLine ( Time::Counter< double > &  timer)
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 isFragment(), and send().

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

Reimplemented in DUNE::Hardware::HayesModem.

Referenced by initialize().

void DUNE::Hardware::BasicModem::setBusy ( bool  value)

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

Referenced by ~BasicModem().

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

Set line termination for modem to CPU commands.

Parameters
[in]termline terminator.

References m_mutex.

Referenced by ~BasicModem().

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

Set line termination for CPU to modem commands.

Parameters
[in]strline terminator.

References m_mutex.

Referenced by ~BasicModem().

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.

Referenced by ~BasicModem().

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

Referenced by getTask().

void DUNE::Hardware::BasicModem::setTimeout ( double  timeout)
protected

References m_mutex.

Referenced by isFragment().

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().

Referenced by ~BasicModem().

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