MotionLib  1.0.0
SamBuCa motion library
Public Member Functions | Public Attributes | Static Public Attributes | Protected Attributes | List of all members
grbl::GrblDeviceBase Class Referenceabstract
Inheritance diagram for grbl::GrblDeviceBase:
Inheritance graph
[legend]

Public Member Functions

void fetch (const std::chrono::milliseconds &timeout)
 wait for data and process it More...
 
virtual void write (const std::string &data)=0
 raw write some bytes More...
 
virtual grbl::ErrorCode send (const std::string &cmd, std::function< bool(const std::string &)> msg={}, const std::chrono::milliseconds &timeout=defaultSendTimeout)
 send a command wait for reply More...
 
virtual grbl::ErrorCode sendRealtime (const std::string &cmd, std::function< bool(const std::string &)> msg={}, const std::chrono::milliseconds &timeout=defaultSendTimeout)
 send a realtime-command wait for reply More...
 
virtual void wake ()=0
 wake thread waiting for input
 
virtual void read ()=0
 fill LineBuffer with incoming bytes
 
virtual bool wait (const std::chrono::milliseconds &timeout)=0
 wait for input More...
 
virtual bool takeLine (std::string &line)
 consume line from buffer More...
 

Public Attributes

ccut::Signal< std::string > dataSignal
 

Static Public Attributes

static const std::chrono::milliseconds defaultSendTimeout
 

Protected Attributes

ccut::LineBuffer m_buffer
 

Detailed Description

Definition at line 43 of file GrblDeviceBase.hpp.

Member Function Documentation

◆ fetch()

void GrblDeviceBase::fetch ( const std::chrono::milliseconds &  timeout)

wait for data and process it

Parameters
timeoutwait timeout @emits dataSignal for each line received
Exceptions
Exception(IO)on IO error

Definition at line 42 of file GrblDeviceBase.cpp.

◆ send()

grbl::ErrorCode GrblDeviceBase::send ( const std::string &  cmd,
std::function< bool(const std::string &)>  msg = {},
const std::chrono::milliseconds &  timeout = defaultSendTimeout 
)
virtual

send a command wait for reply

Parameters
[in]cmdcommand to send
[in][msg]message handler (for commands with replies)
[in][timeout]command timeout
Returns
0 on success, error-code on error (device specific)

callback function must return true if line has been processed

callback function may throw grbl::ErrorCode to stop processing grbl::ErrorCode::Ok may be used to properly exit

Reimplemented in grbl::MGrblDeviceWrapper.

Definition at line 56 of file GrblDeviceBase.cpp.

Here is the call graph for this function:

◆ sendRealtime()

grbl::ErrorCode GrblDeviceBase::sendRealtime ( const std::string &  cmd,
std::function< bool(const std::string &)>  msg = {},
const std::chrono::milliseconds &  timeout = defaultSendTimeout 
)
virtual

send a realtime-command wait for reply

Parameters
[in]cmdcommand to send
[in][msg]message handler
[in][timeout]command timeout
Returns
0 on success, error-code on error (device specific)

callback function must return true if line has been processed

callback function may throw grbl::ErrorCode to stop processing grbl::ErrorCode::Ok may be used to properly exit

this method is slightly different from send, it won't append carriage return and not parse any "ok" or "error" messages.

Reimplemented in grbl::MGrblDeviceWrapper.

Definition at line 122 of file GrblDeviceBase.cpp.

◆ takeLine()

bool GrblDeviceBase::takeLine ( std::string &  line)
virtual

consume line from buffer

Parameters
[out]linedata line
Returns
true if a line was fetched

Reimplemented in mgrbl::MGrblSim.

Definition at line 167 of file GrblDeviceBase.cpp.

◆ wait()

virtual bool grbl::GrblDeviceBase::wait ( const std::chrono::milliseconds &  timeout)
pure virtual

wait for input

Parameters
timeoutwait timeout
Returns
true if data is available
Exceptions
Exception(IO)on IO error

Implemented in mgrbl::MGrblSim, grbl::MGrblDeviceWrapper, grbl::GrblSim, and edge::EdgeGrblDeviceBase.

◆ write()

virtual void grbl::GrblDeviceBase::write ( const std::string &  data)
pure virtual

raw write some bytes

Parameters
[in]databytes to write

Implemented in mgrbl::MGrblSim, grbl::MGrblDeviceWrapper, grbl::GrblSim, and edge::EdgeGrblDeviceBase.


The documentation for this class was generated from the following files: