Go to the documentation of this file.
87 : m_thread(*this, *this)
88 , m_firmwareRevision(0, 0, 0)
89 , m_hardwareRevision(0, 0)
160 JLDEBUGG(
"Fail: " << rcv.getMessageId());
168 rcv = reply2->message(100);
174 JLTRACEG(
"Ok: " << rcv.getMessageId());
253 return (this->
portInfo() == portInfo);
330 bool detected =
false;
332 while (!detected && count < 3)
342 JLDEBUGG(
"openPort failed, attempt: " << count);
380 return thisHub.parentPathMatches(otherHub);
397 const int maxSz = 8192;
464 snd.setDataByte(0, 0);
#define XS_BID_MASTER
The bus identifier of the master device.
@ XRV_NOPORTOPEN
288: No serial port opened for reading/writing
void flushPort() override
Flushes all remaining data on the open port.
XsVersion m_firmwareRevision
XsResultValue writeRawData(const XsByteArray &data) override
Write raw data to the open COM or USB port.
XsResultValue processBufferedData(const XsByteArray &rawIn, std::deque< XsMessage > &messages) override
Read all messages from the buffered read data after adding new data supplied in rawIn.
virtual uint32_t defaultInterfaceTimeout() const
A list of uint8_t values.
virtual XsPortInfo portInfo() const =0
OpenPortStage
Port opening stages.
uint32_t defaultTimeout() const
virtual bool doTransaction(const XsMessage &msg, XsMessage &rcv, uint32_t timeout) override
Write a message and await the reply.
void handleMessage(const XsMessage &message) override
Handles a message.
void setDoGotoConfig(bool doit)
Sets do go to config in a thread.
XsPortInfo portInfo() const override
XsDeviceId masterDeviceId() const
XsResultValue extractMessages(const XsByteArray &rawIn, std::deque< XsMessage > &messages, RxChannelId channel=0)
Read all messages available in the incoming data stream after adding new data supplied in rawIn.
XsResultValue gotoConfig(bool) override
Request a device to go to config mode.
A class which re-detects a device with a certain device Id.
std::shared_ptr< ReplyObject > addReplyObject(uint8_t mid)
Add a MidReplyObject.
uint32_t gotoConfigTimeout() const
std::shared_ptr< StreamInterface > m_streamInterface
virtual std::shared_ptr< StreamInterface > createStreamInterface(const XsPortInfo &pi)=0
Creates a stream interface.
struct XsVersion XsVersion
void handleMessage(const XsMessage &msg) override
Handles a message.
bool isDockedAt(Communicator *other) const override
XsVersion hardwareRevision()
@ XRV_ALREADYOPEN
269: An I/O device is already opened with this object
void setDoGotoConfig(bool doit)
Set whether we should send gotoconfig here.
void startPollThread()
Starts polling the thread.
void stopPollThread()
Stops polling the thread.
@ XRV_OK
0: Operation was performed successfully
bool startThread(const char *name=NULL)
Starts the thread.
XsResultValue
Xsens result values.
XsResultValue lastResult() const
Get the result value of the last operation.
bool redetect(const XsDeviceId &deviceId, XsPortInfo &portInfo, bool skipDeviceIdCheck=false)
Base redetect function which calls the appropriate redetect based on deviceId.
@ XRV_UNEXPECTED_DISCONNECT
312: Motion tracker disconnected unexpectedly
A base struct for a communication interface.
struct XsPortInfo XsPortInfo
XsResultValue gotoConfig(bool detectRs485=false) override
Request a device to go to config mode.
@ XRV_NOFILEORPORTOPEN
289: No file or serial port opened for reading/writing
Contains a descriptor for opening a communication port to an Xsens device.
XsVersion m_hardwareRevision
MessageExtractor & messageExtractor(RxChannelId=0)
Returns the message extractor for the given rx channel.
virtual XsResultValue getFirmwareRevision()
Requests the firmware revision from the connected device.
XsDevice * masterDevice() const
#define XS_DID_TYPEL_COMM_MASK
SerialCommunicator()
Default constructor.
A class to store version information.
void closePort() override
Closes the port.
Structure for storing a single message.
A structure that wraps USB hub information.
XsPortInfo m_activePortInfo
The information about the port this communicator is currently connected to.
XsVersion firmwareRevision()
virtual XSNOEXPORT void onConnectionLost()
#define XS_DID_TYPEL_RS485
XsResultValue gotoMeasurement() override
Request a device to go to measurement mode.
virtual void prepareForDestruction()
Prepares communicator for destruction.
void stopThread(void) noexcept
Tells the thread to stop and waits for it to end.
virtual void prepareForDestruction() override
Prepares for a destruction.
@ XRV_CONFIGCHECKFAIL
293: A configuration-time check of the device failed
XsResultValue getDeviceId() override
Request a device to get device ID.
bool isAlive(void) volatile const noexcept
bool openPort(const XsPortInfo &portInfo, OpenPortStage stage=OPS_Full, bool detectRs485=false) override
Open a serial port and return the main device connected to it.
virtual XsResultValue getHardwareRevision()
Requests the hardware revision from the connected device.
virtual ~SerialCommunicator()
void setLastResult(XsResultValue lastResult, XsString const &text=XsString()) const
Sets the last result.
XsResultValue gotoMeasurement() override
Request a device to go to measurement mode.
XsResultValue readDataToBuffer(XsByteArray &raw) override
Read available data from the open IO device.
@ XRV_INVALIDOPERATION
265: Operation is invalid at this point
@ XRV_COULDNOTREADSETTINGS
271: A required settings file could not be opened or is missing some data
XsResultValue setAndReturnLastResult(XsResultValue lastResult, XsString const &text=XsString()) const
Sets the last result and returns it.
bool isPortOpen() const override
void terminate()
Terminates the thread.
bool reopenPort(OpenPortStage stage=OPS_Full, bool skipDeviceIdCheck=false) override
Reopens the port.
@ XMID_ReqFirmwareRevision