consistency with logviewer logging and add docs.

This commit is contained in:
Chris Lovett 2021-04-28 11:32:08 -07:00
Родитель f72de5fe90
Коммит 62b08da606
3 изменённых файлов: 39 добавлений и 9 удалений

Просмотреть файл

@ -832,15 +832,30 @@ public:
MavLinkLogViewerLog(std::shared_ptr<mavlinkcom::MavLinkNode> proxy) {
proxy_ = proxy;
}
~MavLinkLogViewerLog() {
proxy_ = nullptr;
}
void write(const mavlinkcom::MavLinkMessage& msg, uint64_t timestamp = 0) override {
unused(timestamp);
mavlinkcom::MavLinkMessage copy;
::memcpy(&copy, &msg, sizeof(mavlinkcom::MavLinkMessage));
proxy_->sendMessage(copy);
if (proxy_ != nullptr) {
unused(timestamp);
mavlinkcom::MavLinkMessage copy;
::memcpy(&copy, &msg, sizeof(mavlinkcom::MavLinkMessage));
try {
proxy_->sendMessage(copy);
}
catch (std::exception&) {
failures++;
if (failures == 100) {
// hmmm, doesn't like the proxy, bad socket perhaps, so stop trying...
proxy_ = nullptr;
}
}
}
}
private:
std::shared_ptr<mavlinkcom::MavLinkNode> proxy_;
int failures = 0;
};
@ -873,6 +888,8 @@ protected: //methods
setNormalMode();
}
connection_->stopLoggingSendMessage();
connection_->stopLoggingReceiveMessage();
connection_->close();
}
@ -884,6 +901,7 @@ protected: //methods
auto c = mav_vehicle_->getConnection();
if (c != nullptr) {
c->stopLoggingSendMessage();
c->stopLoggingReceiveMessage();
}
mav_vehicle_->close();
mav_vehicle_ = nullptr;
@ -1139,7 +1157,13 @@ private: //methods
logviewer_out_proxy_ = nullptr;
}
else if (mav_vehicle_ != nullptr) {
mav_vehicle_->getConnection()->startLoggingSendMessage(std::make_shared<MavLinkLogViewerLog>(logviewer_out_proxy_));
auto proxylog = std::make_shared<MavLinkLogViewerLog>(logviewer_out_proxy_);
mav_vehicle_->getConnection()->startLoggingSendMessage(proxylog);
mav_vehicle_->getConnection()->startLoggingReceiveMessage(proxylog);
if (connection_ != nullptr) {
connection_->startLoggingSendMessage(proxylog);
connection_->startLoggingReceiveMessage(proxylog);
}
}
}
return logviewer_proxy_ != nullptr;

Просмотреть файл

@ -20,7 +20,7 @@ log files so you can compare the data from each.
### Realtime
You can also get a realtime view if you connect the LogViewer `before` you run the simulation.
You can also get a realtime view if you connect the LogViewer `before` you run the simulation.
![connect](images/log_viewer_connect.png)
@ -38,9 +38,13 @@ For this to work you need to configure the `settings.json` with the following se
}
}
```
Note: do not use the "Logs" setting when you want realtime LogViewer logging. Logging to
a file using "Logs" is mutually exclusive. with LogViewer logging.
Simply press the blue connector button on the top right corner of the window, select the Socket
`tab`, enter the port number `14388`, and your `localhost` network. If you are using WSL 2 on
Windows then select `vEthernet (WSL)`.
`tab`, enter the port number `14388`, and your `localhost` network. If you are using WSL 2 on
Windows then select `vEthernet (WSL)`.
If you do choose `vEthernet (WSL)` then make sure you also set `LocalHostIp` and
`LogViewerHostIp` to the matching WSL ethernet address, something like `172.31.64.1`.

Просмотреть файл

@ -25,10 +25,12 @@ You will then see log files organized by date in d:\temp\logs, specifically *inp
## MavLink LogViewer
For MavLink enabled drones, you can also use our [Log Viewer](log_viewer.md) to visualize the streams of data.
If you enable this form of realtime logging you should not use the "Logs" setting above, these two forms of logging
are mutually exclusive.
## PX4 Log in SITL Mode
In SITL mode, please a log file is produced when drone is armed. The SITL terminal will contain the path to the log file, it should look something like this
In SITL mode, please a log file is produced when drone is armed. The SITL terminal will contain the path to the log file, it should look something like this
```
INFO [logger] Opened log file: rootfs/fs/microsd/log/2017-03-27/20_02_49.ulg
```