Skip to content

Commit f0dbb1b

Browse files
committed
update linux build
1 parent 5b4ebe5 commit f0dbb1b

File tree

3 files changed

+9
-25
lines changed

3 files changed

+9
-25
lines changed

MavLinkCom/src/impl/AdHocConnectionImpl.cpp

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ std::shared_ptr<AdHocConnection> AdHocConnectionImpl::connectRemoteUdp(const std
4848
if (remoteAddr == "127.0.0.1") {
4949
local = "127.0.0.1";
5050
}
51-
5251
std::shared_ptr<UdpClientPort> socket = std::make_shared<UdpClientPort>();
5352
socket->connect(local, 0, remoteAddr, remotePort);
5453
return createConnection(nodeName, std::static_pointer_cast<Port>(socket));
@@ -61,7 +60,6 @@ std::shared_ptr<AdHocConnection> AdHocConnectionImpl::connectTcp(const std::stri
6160
if (remoteIpAddr == "127.0.0.1") {
6261
local = "127.0.0.1";
6362
}
64-
6563
std::shared_ptr<TcpClientPort> socket = std::make_shared<TcpClientPort>();
6664
socket->connect(local, 0, remoteIpAddr, remotePort);
6765
return createConnection(nodeName, std::static_pointer_cast<Port>(socket));
@@ -71,10 +69,9 @@ std::shared_ptr<AdHocConnection> AdHocConnectionImpl::connectSerial(const std::s
7169
int baudRate, const std::string initString) {
7270
std::shared_ptr<SerialPort> serial = std::make_shared<SerialPort>();
7371
int hr = serial->connect(name.c_str(), baudRate);
74-
75-
if (hr != 0)
72+
if (hr != 0) {
7673
throw std::runtime_error(Utils::stringf("Could not open the serial port %s, error=%d", name.c_str(), hr));
77-
74+
}
7875
// send this right away just in case serial link is not already configured
7976
if (initString.size() > 0) {
8077
serial->write(reinterpret_cast<const uint8_t *>(initString.c_str()), static_cast<int>(initString.size()));
@@ -102,7 +99,6 @@ void AdHocConnectionImpl::close() {
10299
port->close();
103100
port = nullptr;
104101
}
105-
106102
if (read_thread.joinable()) {
107103
read_thread.join();
108104
}
@@ -122,7 +118,6 @@ void AdHocConnectionImpl::sendMessage(const std::vector<uint8_t> &msg) {
122118
if (closed) {
123119
return;
124120
}
125-
126121
try {
127122
port->write(msg.data(), static_cast<int>(msg.size()));
128123
} catch (std::exception &e) {
@@ -166,40 +161,31 @@ void AdHocConnectionImpl::readPackets() {
166161
std::this_thread::sleep_for(std::chrono::milliseconds(10));
167162
continue;
168163
}
169-
170164
int count = safePort->read(buffer, MAXBUFFER);
171165
if (count <= 0) {
172166
// error? well let's try again, but we should be careful not to spin too fast and kill the CPU
173167
std::this_thread::sleep_for(std::chrono::milliseconds(1));
174168
continue;
175169
}
176-
177170
if (count >= MAXBUFFER) {
178-
179171
std::cerr << "GAH KM911 message size (" << std::to_string(count)
180172
<< ") is bigger than max buffer size! Time to support frame breaks, Moffitt" << std::endl;
181-
182173
// error? well let's try again, but we should be careful not to spin too fast and kill the CPU
183174
std::this_thread::sleep_for(std::chrono::milliseconds(1));
184175
continue;
185176
}
186-
187177
// queue event for publishing.
188178
{
189179
std::lock_guard<std::mutex> guard(msg_queue_mutex_);
190180
std::vector<uint8_t> message(count);
191181
memcpy(message.data(), buffer, count);
192182
msg_queue_.push(message);
193183
}
194-
195184
if (waiting_for_msg_) {
196185
msg_available_.post();
197186
}
198-
199187
} // while
200-
201188
delete[] buffer;
202-
203189
} // readPackets
204190

205191
void AdHocConnectionImpl::drainQueue() {
@@ -231,7 +217,6 @@ void AdHocConnectionImpl::drainQueue() {
231217
snapshot_stale = false;
232218
}
233219
auto end = snapshot.end();
234-
235220
auto startTime = std::chrono::system_clock::now();
236221
std::shared_ptr<AdHocConnection> sharedPtr = std::shared_ptr<AdHocConnection>(this->con_);
237222
for (auto ptr = snapshot.begin(); ptr != end; ptr++) {
@@ -250,9 +235,7 @@ void AdHocConnectionImpl::publishPackets() {
250235
// CurrentThread::setMaximumPriority();
251236
CurrentThread::setThreadName("MavLinkThread");
252237
while (!closed) {
253-
254238
drainQueue();
255-
256239
waiting_for_msg_ = true;
257240
msg_available_.wait();
258241
waiting_for_msg_ = false;

MavLinkCom/src/serial_com/Port.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@
44
#ifndef PORT_H
55
#define PORT_H
66

7-
#include <stdint.h>
7+
#include <cstdint>
88

99
class Port {
1010
public:
1111
// write to the port, return number of bytes written or -1 if error.
12-
virtual int write(const uint8_t *ptr, int count) = 0;
12+
virtual int write(const uint8_t *ptr, int count){};
1313

1414
// read a given number of bytes from the port (blocking until the requested bytes are available).
1515
// return the number of bytes read or -1 if error.
16-
virtual int read(uint8_t *buffer, int bytesToRead) = 0;
16+
virtual int read(uint8_t *buffer, int bytesToRead){};
1717

1818
// close the port.
19-
virtual void close() = 0;
19+
virtual void close(){};
2020

21-
virtual bool isClosed() = 0;
21+
virtual bool isClosed(){};
2222

23-
virtual int getRssi(const char *ifaceName) = 0;
23+
virtual int getRssi(const char *ifaceName){};
2424

2525
virtual ~Port() = default;
2626
};

MavLinkCom/src/serial_com/SerialPort.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <Wbemidl.h>
1010
#include <comdef.h>
1111
#include <string>
12+
1213
#ifndef ONECORE
1314
#pragma comment(lib, "wbemuuid.lib")
1415
#endif

0 commit comments

Comments
 (0)