mtbfilecommunicator.cpp
Go to the documentation of this file.
1 
2 // Copyright (c) 2003-2021 Xsens Technologies B.V. or subsidiaries worldwide.
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification,
6 // are permitted provided that the following conditions are met:
7 //
8 // 1. Redistributions of source code must retain the above copyright notice,
9 // this list of conditions, and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright notice,
12 // this list of conditions, and the following disclaimer in the documentation
13 // and/or other materials provided with the distribution.
14 //
15 // 3. Neither the names of the copyright holders nor the names of their contributors
16 // may be used to endorse or promote products derived from this software without
17 // specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
24 // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
26 // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS
28 // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES
29 // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE
30 // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES.
31 //
32 
33 
34 // Copyright (c) 2003-2021 Xsens Technologies B.V. or subsidiaries worldwide.
35 // All rights reserved.
36 //
37 // Redistribution and use in source and binary forms, with or without modification,
38 // are permitted provided that the following conditions are met:
39 //
40 // 1. Redistributions of source code must retain the above copyright notice,
41 // this list of conditions, and the following disclaimer.
42 //
43 // 2. Redistributions in binary form must reproduce the above copyright notice,
44 // this list of conditions, and the following disclaimer in the documentation
45 // and/or other materials provided with the distribution.
46 //
47 // 3. Neither the names of the copyright holders nor the names of their contributors
48 // may be used to endorse or promote products derived from this software without
49 // specific prior written permission.
50 //
51 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
52 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
53 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
54 // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
56 // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
58 // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
59 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS
60 // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES
61 // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE
62 // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES.
63 //
64 
65 #include "mtbfilecommunicator.h"
66 #include "xsdevice_def.h"
67 #include "xsdeviceconfiguration.h"
68 
69 #include <xscommon/threading.h>
70 #include <xscommon/xprintf.h>
73 #include <xstypes/xsportinfo.h>
74 #include "iointerfacefile.h"
75 #include "messageextractor.h"
76 
77 using namespace xsens;
78 
82 {
83 }
84 
92 {
93  return new MtbFileCommunicator;
94 }
95 
99  : Communicator()
100  , m_abortLoadLogFile(false)
101  , m_loadFileTaskId(0)
102  , m_extractor(nullptr)
103  , m_extractedMessages(new std::deque<XsMessage>)
104 {
106  for (auto p : *protocolManager())
107  p->ignoreMaximumMessageSize(true);
108 }
109 
112 MtbFileCommunicator::MtbFileCommunicator(std::shared_ptr<IoInterfaceFile> const& ioInterfaceFile)
113  : Communicator()
114  , m_ioInterfaceFile(ioInterfaceFile)
115  , m_abortLoadLogFile(false)
116  , m_loadFileTaskId(0)
117  , m_extractor(nullptr)
118  , m_extractedMessages(new std::deque<XsMessage>)
119 {
121  for (auto p : *protocolManager())
122  p->ignoreMaximumMessageSize(true);
123 }
124 
128 {
129  delete m_extractor;
130  delete m_extractedMessages;
131 }
132 
136 {
137  return timeout / 20; // 100 ms corresponds to 5 messages. Reasonable, no?
138 }
139 
148 {
149  XsXbusMessageId expected = static_cast<XsXbusMessageId>(msg.getMessageId() + 1);
150  std::deque<XsMessage> messages = readMessagesFromStartOfFile(expected, (int) timeoutToMaxMessages(timeout));
151  rcv.clear();
152  for (const XsMessage& r : messages)
153  {
154  if (r.getBusId() != msg.getBusId())
155  continue;
156 
157  if (msg.getMessageId() == XMID_ReqFrameRates && msg.getDataShort() != r.getDataShort()) // data identifier
158  continue;
159 
160  rcv = r;
161  return true;
162  }
163  return (lastResult() == XRV_OK && !rcv.empty());
164 }
165 
169 {
172 
173  m_abortLoadLogFile = true;
175 
177 }
178 
182 {
183  ThreadPool::instance()->waitForCompletion(m_loadFileTaskId);
184 }
185 
191 {
193 }
194 
195 /* \brief Closes the log file
196 */
198 {
199  m_ioInterfaceFile.reset();
200 }
201 
212 {
213  if (!m_ioInterfaceFile)
214  {
216  return XsMessage();
217  }
218 
219  // store current read state and make sure we reset to it when we're done
220  auto oldPos = logFileReadPosition();
222  auto exm = m_extractedMessages;
224  m_extractedMessages = new std::deque<XsMessage>;
225  JanitorStdFunc0<> resetExtractor([this, ex, exm, oldPos]()
226  {
227  delete this->m_extractor;
228  this->m_extractor = ex;
229  this->m_extractedMessages = exm;
230  this->m_ioInterfaceFile->setReadPosition(oldPos);
231  });
232 
233  // start reading from start of file
234  m_ioInterfaceFile->setReadPosition(0);
235 
236  if (maxMsgs == 0)
237  return readMessage(msgId);
238 
239  for (int count = 0; count < maxMsgs; ++count)
240  {
242  if (msgId == 0 || msg.getMessageId() == msgId)
243  return msg;
244  if (m_ioInterfaceFile->getLastResult() != XRV_OK)
245  {
246  setLastResult(m_ioInterfaceFile->getLastResult());
247  return XsMessage();
248  }
249  }
250 
252  return XsMessage();
253 }
254 
264 std::deque<XsMessage> MtbFileCommunicator::readMessagesFromStartOfFile(uint8_t msgId, int maxMsgs)
265 {
266  std::deque<XsMessage> rv;
267 
268  if (!m_ioInterfaceFile)
269  {
271  return rv;
272  }
273 
274  // store current read state and make sure we reset to it when we're done
275  auto oldPos = logFileReadPosition();
277  auto exm = m_extractedMessages;
279  m_extractedMessages = new std::deque<XsMessage>;
280  JanitorStdFunc0<> resetExtractor([this, ex, exm, oldPos]()
281  {
282  delete this->m_extractedMessages;
283  delete this->m_extractor;
284  this->m_extractor = ex;
285  this->m_extractedMessages = exm;
286  this->m_ioInterfaceFile->setReadPosition(oldPos);
287  });
288 
289  // start reading from start of file
290  m_ioInterfaceFile->setReadPosition(0);
291 
292  if (maxMsgs)
293  {
294  for (int count = 0; count < maxMsgs; ++count)
295  {
297  if (lastResult() != XRV_OK)
298  break;
299  else if (msgId == 0 || msg.getMessageId() == msgId)
300  rv.push_back(msg);
301  }
302  }
303  else
304  {
305  XsMessage msg = readMessage(msgId);
306  while (lastResult() == XRV_OK)
307  {
308  if (msgId == 0 || msg.getMessageId() == msgId)
309  rv.push_back(msg);
310  msg = readMessage(msgId);
311  }
312  }
313 
314  if (lastResult() == XRV_OTHER || (lastResult() == XRV_ENDOFFILE && m_ioInterfaceFile->getFileSize()))
316  if (lastResult() == XRV_ENDOFFILE)
318 
319  return rv;
320 }
321 
329 {
330 public:
331 
334  : ThreadPoolTask()
335  , m_loader(inf)
336  , m_device(device)
337  , m_thread(this)
338  {
339  assert(m_loader != 0);
340  assert(m_device != 0);
341  }
342 
345  bool exec() override
346  {
347  // short sleep to prevent thread starvation
348  XsTime::msleep(1);
349 
350  if (m_thread.m_done)
351  return true;
352 
353  if (!m_thread.isRunning())
354  {
355  JLDEBUGG("Starting dedicated read thread");
357  }
358 
359  // reschedule
360  return false;
361  }
362 
364  virtual ~Xs4FileTask()
365  {
366  if (m_thread.isAlive())
368  }
369 
370 private:
373 
375  {
376  public:
377  ReaderThread(Xs4FileTask* task);
378  int32_t innerFunction(void) override;
380  bool m_done;
381  } m_thread;
382 
383  friend class ReaderThread;
384 };
385 
387  : m_task(task)
388  , m_done(false)
389 {
390 }
391 
393 {
394 #ifndef ANDROID // Invoking XsDevice::logFileName() results in a crash on Android for some reason...
395  {
396  XsString filename = m_task->m_device->logFileName();
397  std::string name = xprintf("FileReader: %s", filename.c_str());
398  xsNameThisThread(name.c_str());
399  JLDEBUGG("Loading file " << filename);
400  }
401 #endif
402 
403  try
404  {
405  m_task->m_loader->readLogFile(m_task->m_device);
406  }
407  catch (XsException const& e)
408  {
409  m_task->m_device->onError(m_task->m_device, e.code());
410  JLALERTG(e.what());
411  }
412  m_done = true;
413  stopThread();
414  return 0;
415 }
416 
420 {
421  assert(device != 0);
422 
423  abortLoadLogFile();
424  waitForLastTaskCompletion();
425 
426  m_abortLoadLogFile = false;
427  Xs4FileTask* tsk = new Xs4FileTask(this, device);
428  m_loadFileTaskId = ThreadPool::instance()->addTask(tsk, m_loadFileTaskId);
429 }
430 
438 {
439  assert(device != 0);
440  JLDEBUGG("");
441 
442  XsResultValue res = XRV_OK;
443  XsFilePos prevFilePos = -1;
444  XsString id = logFileName();
445 
446  do
447  {
448  try
449  {
450  res = readSinglePacketFromFile();
451  }
452  catch (...)
453  {
454  // Simply ignore the error and continue.
455  continue;
456  }
457  // Only emit progress updates at complete percentages, once per percentage
458  XsFilePos pos = logFileReadPosition();
459  XsFilePos size = logFileSize();
460 
461  if (size)
462  {
463  const int percentage = (int)(pos * 100 / size);
464  if (prevFilePos != percentage && percentage < 100)
465  {
466  onProgressUpdated(device, percentage < 100 ? percentage : 99, 100, &id); // never report 100% until we're really done
467  prevFilePos = percentage;
468  }
469  }
470  } while (!m_abortLoadLogFile && (res == XRV_OK || res == XRV_OTHER));
471 
472  if (!m_abortLoadLogFile)
473  {
474  masterDevice()->onEofReached();
475  onProgressUpdated(device, 100, 100, &id);
476  }
477 
478  return setAndReturnLastResult(res);
479 }
480 
486 {
487  JLTRACEG("Reading from file");
488  XsMessage msg = readMessage(0);
489  if (lastResult())
490  return lastResult();
491 
492  handleMessage(msg);
493  return lastResult();
494 }
495 
500 {
501  m_abortLoadLogFile = true;
502 }
503 
512 {
513  if (m_ioInterfaceFile)
514  {
516  if (filename == logFileName())
517  return true;
518  return false;
519  }
520  m_ioInterfaceFile = std::shared_ptr<IoInterfaceFile>(new IoInterfaceFile, [](IoInterfaceFile * f)
521  {
522  f->close();
523  });
524 
525  setLastResult(m_ioInterfaceFile->open(filename, false, true));
526  if (lastResult() != XRV_OK)
527  {
528  m_ioInterfaceFile.reset();
529  return false;
530  }
531 
532  // start with a sanity check on the file
533  XsByteArray hdrBuf;
534  XsResultValue rv;
535 
536  // Is the file readable and does it at least start with 0xFA marker?
537  rv = m_ioInterfaceFile->readData(1, hdrBuf);
538  if (rv != XRV_OK || hdrBuf.size() < 1 || hdrBuf[0] != 0xFA)
539  {
541  m_ioInterfaceFile.reset();
542  return false;
543  }
544 
545  resetLogFileReadPosition();
546 
547  // try to read any message from the start
548  XsMessage check = readMessage();
549  if (check.getMessageId() == XMID_InvalidMessage)
550  {
552  m_ioInterfaceFile.reset();
553  return false;
554  }
555 
556  resetLogFileReadPosition();
557 
558  // Now let's try to find the actual message we are looking for somewhere...
560 
561  if (rcv.getMessageId() != XMID_Configuration)
562  {
564  m_ioInterfaceFile.reset();
565  return false;
566  }
567 
568  XsDeviceConfiguration config;
569  config.readFromMessage(rcv);
570  setMasterDeviceId(XsDeviceId((char*)config.masterInfo().m_productCode, 0, 0, config.masterInfo().m_masterDeviceId));
571 
572  return true;
573 }
574 
578 {
579  XsString retString;
580  if (!m_ioInterfaceFile)
581  return retString;
582 
583  if (m_ioInterfaceFile->getName(retString) != XRV_OK)
584  return XsString();
585  return retString;
586 }
587 
591 {
592  if (!m_ioInterfaceFile)
593  return 0;
594 
595  return m_ioInterfaceFile->getFileSize();
596 }
597 
601 {
602  if (!m_ioInterfaceFile)
603  return XsTimeStamp();
604 
605  return m_ioInterfaceFile->getFileDate();
606 }
607 
618 {
619  if (!m_ioInterfaceFile)
620  return 0;
621 
622  auto pos = m_ioInterfaceFile->getReadPosition();
623  if (pos < m_ioInterfaceFile->getFileSize())
624  return pos;
625 
626  if (m_extractedMessages->empty())
627  return pos;
628 
629  return pos > 0 ? pos - 1 : 0;
630 }
631 
637 {
638  if (m_ioInterfaceFile)
639  {
640  m_extractor->clearBuffer();
641  m_extractedMessages->clear();
642  setLastResult(m_ioInterfaceFile->setReadPosition(0));
643  }
644  else
646 }
647 
650 {
651  return true;
652 }
653 
663 {
664  if (!m_ioInterfaceFile)
665  {
667  return XsMessage();
668  }
669 
670  XsMessage msg;
671 
672  do
673  {
674  msg = readNextMessage();
675  } while (!msg.empty() && msgId != 0 && msg.getMessageId() != msgId);
676 
677  if (msgId == 0 || msg.getMessageId() == msgId)
678  return msg;
679 
681  return XsMessage();
682 }
683 
688 {
689  while (m_extractedMessages->empty())
690  {
691  XsByteArray raw;
692  XsResultValue res = m_ioInterfaceFile->readDataBlocks(1, raw);
693  (void)res;
694  if (raw.empty())
695  {
696  // end of file really reached
698  return XsMessage();
699  }
700  m_extractor->processNewData(masterDevice(), raw, *m_extractedMessages);
701  }
702 
704  XsMessage msg = *m_extractedMessages->begin();
705  m_extractedMessages->pop_front();
706  return msg;
707 }
708 
712 {
713  return ThreadPool::instance()->doesTaskExist(m_loadFileTaskId);
714 }
715 
720 {
721  handler->ignoreMaximumMessageSize(true);
723 }
724 
725 /* Now the disabled stuff starts */
726 
729 {
730  (void)detectRs485;
731  return XRV_UNSUPPORTED;
732 }
733 
735 {
736  return XRV_UNSUPPORTED;
737 }
738 
740 {
741  return XRV_UNSUPPORTED;
742 }
743 
745 {
746  (void)timeout;
747 }
748 
749 bool MtbFileCommunicator::writeMessage(const XsMessage& message)
750 {
751  (void)message;
752  return false;
753 }
754 
756 {
757 }
758 
760 {
761 }
762 
764 {
765  return false;
766 }
767 
769 {
770  return XsPortInfo();
771 }
772 
773 bool MtbFileCommunicator::openPort(const XsPortInfo& portInfo, OpenPortStage stage, bool detectRs485)
774 {
775  (void)portInfo;
776  (void)stage;
777  (void)detectRs485;
778  return false;
779 }
780 
781 bool MtbFileCommunicator::reopenPort(OpenPortStage stage, bool skipDeviceIdCheck)
782 {
783  (void)stage;
784  (void)skipDeviceIdCheck;
785  return false;
786 }
787 
789 {
790  (void)other;
791  return false;
792 }
793 
794 void MtbFileCommunicator::setKeepAlive(bool enable)
795 {
796  (void)enable;
797 }
Xs4FileTask::ReaderThread
Definition: mtbfilecommunicator.cpp:374
check
ROSCPP_DECL bool check()
XsString
struct XsString XsString
Definition: xsstring.h:87
MtbFileCommunicator::logFileReadPosition
XsFilePos logFileReadPosition() const override
Retrieve the read position of the log file.
Definition: mtbfilecommunicator.cpp:617
MtbFileCommunicator::isPortOpen
bool isPortOpen() const override
MtbFileCommunicator::reopenPort
bool reopenPort(OpenPortStage stage=OPS_Full, bool skipDeviceIdCheck=false) override
Reopens the port.
Xs4FileTask::m_loader
FileLoader * m_loader
The Communicator object that contains information on calibration and filtering.
Definition: mtbfilecommunicator.cpp:371
xsens::ThreadPoolTask
A generic task implementation for the thread pool.
Definition: xsens_threadpool.h:82
messageextractor.h
msg
msg
XsMessage
struct XsMessage XsMessage
Definition: xsmessage.h:85
XsByteArray
A list of uint8_t values.
MtbFileCommunicator::m_loadFileTaskId
xsens::ThreadPool::TaskId m_loadFileTaskId
Definition: mtbfilecommunicator.h:135
OpenPortStage
OpenPortStage
Port opening stages.
Definition: openportstage.h:76
XMID_InvalidMessage
@ XMID_InvalidMessage
Definition: xsxbusmessageid.h:75
IProtocolHandler::ignoreMaximumMessageSize
virtual void ignoreMaximumMessageSize(bool ignore)
Tells the protocol handler to ignore/expand its maximum message size.
Definition: iprotocolhandler.h:132
xsens::StandardThread::isRunning
bool isRunning(void) volatile const noexcept
Returns whether the thread is currently running.
Definition: threading.cpp:160
MtbFileCommunicator::openPort
bool openPort(const XsPortInfo &portInfo, OpenPortStage stage=OPS_Full, bool detectRs485=false) override
Opens a port.
Communicator::protocolManager
std::shared_ptr< ProtocolManager > protocolManager() const
Definition: communicator.cpp:142
XsDeviceConfiguration
Structure containing a full device configuration as returned by the ReqConfig message.
Definition: xsdeviceconfiguration.h:143
MtbFileCommunicator::readLogFile
virtual XsResultValue readLogFile(XsDevice *device) override
Read a log file into cache.
Definition: mtbfilecommunicator.cpp:437
MtbFileCommunicator::m_ioInterfaceFile
std::shared_ptr< IoInterfaceFile > m_ioInterfaceFile
Definition: mtbfilecommunicator.h:133
MtbFileCommunicator::logFileDate
XsTimeStamp logFileDate() const override
Retrieve the date of the open log file.
Definition: mtbfilecommunicator.cpp:600
xsNameThisThread
void XSTYPES_DLL_API xsNameThisThread(const char *threadName)
Set the name of the current thread to threadName.
Definition: xsthread.c:140
xsens_janitors.h
XRV_ENDOFFILE
@ XRV_ENDOFFILE
270: End of file is reached
Definition: xsresultvalue.h:140
MtbFileCommunicator::doTransaction
bool doTransaction(const XsMessage &msg, XsMessage &rcv, uint32_t timeout) override
Pretend to be a live system.
Definition: mtbfilecommunicator.cpp:147
MtbFileCommunicator::readMessageFromStartOfFile
XsMessage readMessageFromStartOfFile(uint8_t msgId, int maxMsgs=0) override
Read a message from the start of the open file.
Definition: mtbfilecommunicator.cpp:211
MtbFileCommunicator
A class that is used for the communcation with a mtb file.
Definition: mtbfilecommunicator.h:79
Xs4FileTask::ReaderThread::m_done
bool m_done
Definition: mtbfilecommunicator.cpp:380
JLALERTG
#define JLALERTG(msg)
Definition: journaller.h:281
IoInterfaceFile
The low-level file communication class.
Definition: iointerfacefile.h:74
XRV_ALREADYOPEN
@ XRV_ALREADYOPEN
269: An I/O device is already opened with this object
Definition: xsresultvalue.h:139
XRV_NOFILEOPEN
@ XRV_NOFILEOPEN
287: No file opened for reading/writing
Definition: xsresultvalue.h:158
xsportinfo.h
MtbFileCommunicator::MtbFileCommunicator
MtbFileCommunicator()
Default constructor.
Definition: mtbfilecommunicator.cpp:98
f
f
xsens_debugtools.h
XRV_OK
@ XRV_OK
0: Operation was performed successfully
Definition: xsresultvalue.h:85
MtbFileCommunicator::readMessagesFromStartOfFile
std::deque< XsMessage > readMessagesFromStartOfFile(uint8_t msgId, int maxMsgs=0) override
Read multiple similar messages from the start of the open file.
Definition: mtbfilecommunicator.cpp:264
xsens::StandardThread::startThread
bool startThread(const char *name=NULL)
Starts the thread.
Definition: threading.cpp:281
Xs4FileTask::ReaderThread::ReaderThread
ReaderThread(Xs4FileTask *task)
Definition: mtbfilecommunicator.cpp:386
Communicator::addProtocolHandler
virtual void addProtocolHandler(IProtocolHandler *handler)
Adds a protocol handler.
Definition: communicator.cpp:303
MtbFileCommunicator::resetLogFileReadPosition
void resetLogFileReadPosition(void) override
Restart reading from the start of the open log file.
Definition: mtbfilecommunicator.cpp:636
MtbFileCommunicator::construct
static Communicator * construct()
Constructs new MtbFileCommunicator.
Definition: mtbfilecommunicator.cpp:91
XsResultValue
XsResultValue
Xsens result values.
Definition: xsresultvalue.h:82
Communicator::lastResult
XsResultValue lastResult() const
Get the result value of the last operation.
Definition: communicator.cpp:167
Xs4FileTask::ReaderThread::innerFunction
int32_t innerFunction(void) override
Virtual inner function.
Definition: mtbfilecommunicator.cpp:392
MtbFileCommunicator::timeoutToMaxMessages
uint32_t timeoutToMaxMessages(uint32_t timeout) const
A rather stupid function that tries to convert a live timeout into a number of messages.
Definition: mtbfilecommunicator.cpp:135
MtbFileCommunicator::closePort
void closePort() override
Closes the open port.
MtbFileCommunicator::gotoConfig
XsResultValue gotoConfig(bool detectRs485=false) override
Request a device to go to config mode.
MtbFileCommunicator::portInfo
XsPortInfo portInfo() const override
Communicator
A base struct for a communication interface.
Definition: communicator.h:95
XsPortInfo
struct XsPortInfo XsPortInfo
Definition: xsportinfo.h:83
uint32_t
unsigned int uint32_t
Definition: pstdint.h:485
MtbFileCommunicator::setKeepAlive
void setKeepAlive(bool enable) override
Either disable or enable (default) the keep alive mechanism (if supported by the device)
MtbFileCommunicator::prepareForDestruction
void prepareForDestruction() override
Prepares for the destruction.
Definition: mtbfilecommunicator.cpp:168
MtbFileCommunicator::m_extractedMessages
std::deque< XsMessage > * m_extractedMessages
Definition: mtbfilecommunicator.h:138
MtbFileCommunicator::writeMessage
bool writeMessage(const XsMessage &message) override
Write message to the device.
XsPortInfo
Contains a descriptor for opening a communication port to an Xsens device.
Definition: xsportinfo.h:128
MtbFileCommunicator::isDockedAt
bool isDockedAt(Communicator *other) const override
Returns true if the other device is docked at this device.
IProtocolHandler
Interface class for protocol handlers.
Definition: iprotocolhandler.h:78
XRV_NODATA
@ XRV_NODATA
272: No data is available
Definition: xsresultvalue.h:142
JLTRACEG
#define JLTRACEG(msg)
Definition: journaller.h:279
MtbFileCommunicator::openLogFile
bool openLogFile(const XsString &filename) override
Open a log file for input.
Definition: mtbfilecommunicator.cpp:511
FileLoader
A class that loads file.
Definition: fileloader.h:73
xsdevice_def.h
MtbFileCommunicator::readMessage
XsMessage readMessage(uint8_t msgId=0) override
Read a message from the open file.
Definition: mtbfilecommunicator.cpp:662
xsens::JanitorStdFunc0
Function calling janitor class for std::function with 0 parameters.
Definition: xsens_janitors.h:514
FileLoader::~FileLoader
virtual ~FileLoader()
Definition: mtbfilecommunicator.cpp:81
XsXbusMessageId
XsXbusMessageId
Xsens Xbus Message Identifiers.
Definition: xsxbusmessageid.h:73
MtbFileCommunicator::isLoadLogFileInProgress
bool isLoadLogFileInProgress() const override
Definition: mtbfilecommunicator.cpp:711
XsDeviceId
struct XsDeviceId XsDeviceId
Definition: xsdeviceid.h:912
Xs4FileTask::m_device
XsDevice * m_device
Definition: mtbfilecommunicator.cpp:372
XsMessage
Structure for storing a single message.
Definition: xsmessage.h:202
MtbFileCommunicator::logFileSize
XsFilePos logFileSize() const override
Retrieve the size of the open log file in bytes.
Definition: mtbfilecommunicator.cpp:590
MtbFileCommunicator::closeLogFile
void closeLogFile() override
Close the log file.
Definition: mtbfilecommunicator.cpp:197
MtbFileCommunicator::completeAllThreadedWork
void completeAllThreadedWork()
Completes all threaded work.
Definition: mtbfilecommunicator.cpp:181
MtbFileCommunicator::isReadingFromFile
bool isReadingFromFile() const override
Return whether we are reading from file.
Definition: mtbfilecommunicator.cpp:649
XMID_Configuration
@ XMID_Configuration
Definition: xsxbusmessageid.h:97
threading.h
MtbFileCommunicator::m_extractor
MessageExtractor * m_extractor
Definition: mtbfilecommunicator.h:137
MtbFileCommunicator::loadLogFile
void loadLogFile(XsDevice *device) override
Load a log file with thread pool.
Definition: mtbfilecommunicator.cpp:419
MtbFileCommunicator::~MtbFileCommunicator
~MtbFileCommunicator()
Definition: mtbfilecommunicator.cpp:127
XRV_OTHER
@ XRV_OTHER
286: Something else was received than was requested
Definition: xsresultvalue.h:156
XMID_ReqFrameRates
@ XMID_ReqFrameRates
Definition: xsxbusmessageid.h:448
Communicator::configurationMessageSearchLimit
static int configurationMessageSearchLimit()
Definition: communicator.h:316
MtbFileCommunicator::setGotoConfigTimeout
void setGotoConfigTimeout(uint32_t timeout) override
Set the timeout for the gotoConfig function.
std
xsens::StandardThread
A class for a standard thread that has to perform the same action repeatedly.
Definition: threading.h:83
MessageExtractor
Definition: messageextractor.h:75
MtbFileCommunicator::getDeviceId
XsResultValue getDeviceId() override
Request a device to get device ID.
Communicator::prepareForDestruction
virtual void prepareForDestruction()
Prepares communicator for destruction.
Definition: communicator.cpp:114
Xs4FileTask
A class for handling file loading process in a separate thread.
Definition: mtbfilecommunicator.cpp:328
MtbFileCommunicator::readNextMessage
virtual XsMessage readNextMessage()
Read the next message from the open file.
Definition: mtbfilecommunicator.cpp:687
JLDEBUGG
#define JLDEBUGG(msg)
Definition: journaller.h:280
xsens::StandardThread::stopThread
void stopThread(void) noexcept
Tells the thread to stop and waits for it to end.
Definition: threading.cpp:334
iointerfacefile.h
mtbfilecommunicator.h
int32_t
signed int int32_t
Definition: pstdint.h:515
Xs4FileTask::exec
bool exec() override
Check if the file load is complete.
Definition: mtbfilecommunicator.cpp:345
xprintf.h
xsens::StandardThread::isAlive
bool isAlive(void) volatile const noexcept
Definition: threading.cpp:140
MtbFileCommunicator::m_abortLoadLogFile
bool m_abortLoadLogFile
Definition: mtbfilecommunicator.h:134
MtbFileCommunicator::abortLoadLogFile
void abortLoadLogFile() override
Abort a process that takes a long time to complete.
Definition: mtbfilecommunicator.cpp:499
XRV_UNSUPPORTED
@ XRV_UNSUPPORTED
303: The requested functionality is not supported by the device
Definition: xsresultvalue.h:178
Xs4FileTask::Xs4FileTask
Xs4FileTask(FileLoader *inf, XsDevice *device)
Construct a file task, but does not schedule it.
Definition: mtbfilecommunicator.cpp:333
MtbFileCommunicator::flushPort
void flushPort() override
Flushes all remaining data on the open port.
Communicator::setLastResult
void setLastResult(XsResultValue lastResult, XsString const &text=XsString()) const
Sets the last result.
Definition: communicator.cpp:238
setLastResult
static XsResultValue setLastResult(XsSocket *thisPtr, XsResultValue retval, int systemError)
Definition: xssocket.c:171
MtbFileCommunicator::waitForLastTaskCompletion
void waitForLastTaskCompletion() override
Wait for the last processing task to complete in the threadpool.
Definition: mtbfilecommunicator.cpp:190
Xs4FileTask::ReaderThread::m_task
Xs4FileTask * m_task
Definition: mtbfilecommunicator.cpp:379
XRV_INVALIDOPERATION
@ XRV_INVALIDOPERATION
265: Operation is invalid at this point
Definition: xsresultvalue.h:135
xsdeviceconfiguration.h
MtbFileCommunicator::readSinglePacketFromFile
virtual XsResultValue readSinglePacketFromFile() override
Read a single XsDataPacket from an open log file.
Definition: mtbfilecommunicator.cpp:485
Xs4FileTask::~Xs4FileTask
virtual ~Xs4FileTask()
Destroy this process task.
Definition: mtbfilecommunicator.cpp:364
MtbFileCommunicator::logFileName
XsString logFileName() const override
Retrieve the name of the open log file or an empty string if no log file is open.
Definition: mtbfilecommunicator.cpp:577
XsFilePos
int64_t XsFilePos
The type that is used for positioning inside a file.
Definition: xsfilepos.h:102
XsString
A 0-terminated managed string of characters.
XsDevice
Definition: xsdevice_def.h:164
xsens
Definition: threading.cpp:78
XsTimeStamp
struct XsTimeStamp XsTimeStamp
Definition: xstimestamp.h:458
MtbFileCommunicator::gotoMeasurement
XsResultValue gotoMeasurement() override
Request a device to go to measurement mode.
XRV_DATACORRUPT
@ XRV_DATACORRUPT
278: A trusted data stream proves to contain corrupted data
Definition: xsresultvalue.h:148
MtbFileCommunicator::addProtocolHandler
void addProtocolHandler(IProtocolHandler *handler) override
Add the protocol handler.
Definition: mtbfilecommunicator.cpp:719
XsTimeStamp
This class contains method to set, retrieve and compare timestamps.
Definition: xstimestamp.h:115
Xs4FileTask::m_thread
Xs4FileTask::ReaderThread m_thread


xsens_mti_driver
Author(s):
autogenerated on Sun Sep 3 2023 02:43:20