28 CNTRIPEmitter::CNTRIPEmitter()
32 m_transmit_to_server(true),
65 "[NTRIP %s] Rate: %.02f B/s\n",
74 "[NTRIP %s] RX (%u bytes)\n",
76 (
unsigned int)buf.size());
82 "[NTRIP %s] RX: %u bytes\n",
84 (
unsigned)buf.size());
91 reinterpret_cast<const char*>(&buf[0]), buf.size());
99 const size_t nReadActual =
m_out_COM.
Read(rxbuf,
sizeof(rxbuf) - 1);
102 rxbuf[nReadActual] = 0;
105 "[NTRIP %s] TX (%u bytes)\n",
108 (
unsigned int)nReadActual);
112 std::this_thread::sleep_for(1ms);
144 fil.c_str(), std::ofstream::out | std::ofstream::binary);
147 "Error opening output raw file: `%s`", fil.c_str());
153 "ERROR trying to connect to NTRIP caster: %s", errstr.c_str());
162 #ifdef MRPT_OS_WINDOWS 172 "At least one of either raw file output or serial COM file must be " 173 "specified in configuration file!");
void initialize()
Set up the NTRIP communications, raising an exception on fatal errors.
bool open(const NTRIPArgs ¶ms, std::string &out_errmsg)
Tries to open a given NTRIP stream and, if successful, launches a thread for continuously reading fro...
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
mrpt::utils::CTicTac m_rate_timer
std::vector< uint8_t > vector_byte
std::string m_com_port
If set to non-empty, the serial port will be attempted to be opened automatically when this class is ...
CNTRIPClient m_client
The NTRIP comms object.
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
void WriteBuffer(const void *Buffer, size_t Count)
Writes a block of bytes to the stream from Buffer.
void open()
Open the port.
mrpt::system::TTimeStamp now()
A shortcut for system::getCurrentTime.
Contains classes for various device interfaces.
std::string fileNameStripInvalidChars(const std::string &filename, const char replacement_to_invalid_chars='_')
Replace invalid filename chars by underscores ('_') or any other user-given char. ...
void close()
Closes the connection.
void setConfig(int baudRate, int parity=0, int bits=8, int nStopBits=1, bool enableFlowControl=false)
Changes the configuration of the port.
void readAndClear(vector_byte &d)
Read the whole buffer and empty it.
void Tic()
Starts the stopwatch.
This class allows loading and storing values and vectors of different types from a configuration text...
std::string m_raw_output_file_prefix
bool isOpen() const
Returns if port has been correctly open.
This namespace contains representation of robot actions and observations.
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
void purgeBuffers()
Purge tx and rx buffers.
GLsizei const GLchar ** string
#define IMPLEMENTS_GENERIC_SENSOR(class_name, NameSpace)
This must be inserted in all CGenericSensor classes implementation files:
void close()
Close the port.
void setTimeouts(int ReadIntervalTimeout, int ReadTotalTimeoutMultiplier, int ReadTotalTimeoutConstant, int WriteTotalTimeoutMultiplier, int WriteTotalTimeoutConstant)
Changes the timeouts of the port, in milliseconds.
void loadConfig_sensorSpecific(const mrpt::utils::CConfigFileBase &configSource, const std::string &iniSection)
See the class documentation at the top for expected parameters.
CNTRIPClient::NTRIPArgs m_ntrip_args
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
std::ofstream m_raw_output_file_stream
void doProcess()
The main loop, which must be called in a timely fashion in order to process the incomming NTRIP data ...
virtual ~CNTRIPEmitter()
Destructor.
std::string timeLocalToString(const mrpt::system::TTimeStamp t, unsigned int secondFractionDigits=6)
Convert a timestamp into this textual form (in local time): HH:MM:SS.MMMMMM.
bool m_transmit_to_server
double Tac()
Stops the stopwatch.
std::string trim(const std::string &str)
Removes leading and trailing spaces.
mrpt::comms::CSerialPort m_out_COM
The output serial port.
mrpt::synch::MT_buffer stream_data
The buffer with all the bytes so-far read from the NTRIP server stream.
std::string dateTimeLocalToString(const mrpt::system::TTimeStamp t)
Convert a timestamp into this textual form (in local time): YEAR/MONTH/DAY,HH:MM:SS.MMM.
This "virtual driver" encapsulates a NTRIP client (see CNTRIPClient) but adds the functionality of du...
#define ASSERTMSG_(f, __ERROR_MSG)
size_t Read(void *Buffer, size_t Count)
Implements the virtual method responsible for reading from the stream - Unlike CStream::ReadBuffer, this method will not raise an exception on zero bytes read, as long as there is not any fatal error in the communications.