VectorNav C++ Library
ezasyncdata.h
1 #ifndef _VNSENSORS_EZASYNCDATA_H_
2 #define _VNSENSORS_EZASYNCDATA_H_
3 
4 #include <string>
5 
6 #include "vn/int.h"
7 #include "vn/nocopy.h"
8 #include "vn/sensors.h"
9 #include "vn/compositedata.h"
10 #include "vn/criticalsection.h"
11 #include "vn/event.h"
12 #include "vn/export.h"
13 
14 namespace vn {
15 namespace sensors {
16 
19 class vn_proglib_DLLEXPORT EzAsyncData : private util::NoCopy
20 {
21 private:
22  explicit EzAsyncData(VnSensor* sensor);
23 
24 public:
26  ~EzAsyncData();
27 
30  VnSensor* sensor();
31 
38  static EzAsyncData* connect(std::string portName, uint32_t baudrate);
39 
41  void disconnect();
42 
47  CompositeData currentData();
48 
53  CompositeData getNextData();
54 
61  CompositeData getNextData(int timeoutMs);
62 
63 private:
64  static void asyncPacketReceivedHandler(void* userData, protocol::uart::Packet& p, size_t index);
65 
66 private:
67  VnSensor* _sensor;
68  xplat::CriticalSection _mainCS, _copyCS;
69  CompositeData _persistentData, _nextData;
70  xplat::Event _newDataEvent;
71 };
72 
73 }
74 }
75 
76 #endif
Represents a cross-platform critical section.
Definition: criticalsection.h:16
Represents a cross-platform event.
Definition: event.h:12
Composite structure of all data types available from VectorNav sensors.
Definition: compositedata.h:15
Provides easy and reliable access to asynchronous data from a VectorNav sensor at the cost of a sligh...
Definition: ezasyncdata.h:19
Helpful class for working with VectorNav sensors.
Definition: sensors.h:58
Identifies a derived class as being unable to be copied and prevents copy attempts.
Definition: nocopy.h:21
Definition: attitude.h:8
Structure representing a UART packet received from the VectorNav sensor.
Definition: packet.h:16