Skip to content

Commit

Permalink
Make sure each buffer is zero'd out before reading bytes. Remove unne…
Browse files Browse the repository at this point in the history
…cessary metadata from mavlink messages and make tooltips show on top of close box in the charts.
  • Loading branch information
lovettchris committed May 5, 2021
1 parent ef5a6a6 commit 6db5c7f
Show file tree
Hide file tree
Showing 6 changed files with 203 additions and 191 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -386,4 +386,3 @@ build_docs/

# api docs
PythonClient/docs/_build
/LogViewer/LogViewer/publish.cmd
19 changes: 11 additions & 8 deletions LogViewer/LogViewer/Controls/SimpleLineChart.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@
<Canvas Grid.Row="0" VerticalAlignment="Top">
<Path x:Name="Graph" StrokeThickness="5" VerticalAlignment="Top" SnapsToDevicePixels="True" StrokeLineJoin="Bevel">
</Path>
<Path x:Name="Pointer" Fill="{StaticResource TooltipForeground}" Data="M0,-5 L 5,0 0,5 -5 0z" Visibility="Collapsed"/>
<local:PointerBorder x:Name="PointerBorder" Visibility="Collapsed" Padding="2" HorizontalAlignment="Left" VerticalAlignment="Top" BorderThickness="1"
CornerRadius="3" BorderBrush="{StaticResource TooltipForeground}" Background="#80303030">
<TextBlock x:Name="PointerLabel" Foreground="{StaticResource TooltipForeground}"/>
</local:PointerBorder>
<Canvas x:Name="AdornerCanvas">

</Canvas>
</Canvas>

<Grid>
Expand All @@ -54,5 +46,16 @@
</Grid>

<local:CloseBox HorizontalAlignment="Right" VerticalAlignment="Top" Margin="5" Click="CloseBoxClick"/>

<Canvas Grid.Row="0" VerticalAlignment="Top">
<Path x:Name="Pointer" Fill="{StaticResource TooltipForeground}" Data="M0,-5 L 5,0 0,5 -5 0z" Visibility="Collapsed"/>
<local:PointerBorder x:Name="PointerBorder" Visibility="Collapsed" Padding="2" HorizontalAlignment="Left" VerticalAlignment="Top" BorderThickness="1"
CornerRadius="3" BorderBrush="{StaticResource TooltipForeground}" Background="#80303030">
<TextBlock x:Name="PointerLabel" Foreground="{StaticResource TooltipForeground}"/>
</local:PointerBorder>
<Canvas x:Name="AdornerCanvas">

</Canvas>
</Canvas>
</Grid>
</UserControl>
2 changes: 1 addition & 1 deletion LogViewer/LogViewer/LogViewer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<SuiteName>PX4 Log Viewer</SuiteName>
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.htm</WebPage>
<ApplicationRevision>62</ApplicationRevision>
<ApplicationRevision>63</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
Expand Down
8 changes: 6 additions & 2 deletions LogViewer/LogViewer/Model/MavlinkLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,8 @@ public async Task Load(string file, ProgressUtility progress)
this.duration = TimeSpan.Zero;
bool first = true;
// QT time is milliseconds from the following epoch.
byte[] msgBuf = new byte[256];
const int BUFFER_SIZE = 8000;
byte[] msgBuf = new byte[BUFFER_SIZE];
GCHandle handle = GCHandle.Alloc(msgBuf, GCHandleType.Pinned);
IntPtr ptr = handle.AddrOfPinnedObject();

Expand All @@ -605,14 +606,17 @@ await Task.Run(() =>
{
MavLinkMessage header = new MavLinkMessage();
header.ReadHeader(reader);

Array.Clear(msgBuf, 0, BUFFER_SIZE);
int read = s.Read(msgBuf, 0, header.Length);

if (read == header.Length)
{
int id = (int)header.MsgId;
header.Crc = reader.ReadUInt16();

bool checkCrc = true;
if ((int)header.MsgId == MAVLink.mavlink_telemetry.MessageId)
if (id == MAVLink.mavlink_telemetry.MessageId)
{
if (header.Crc == 0) // telemetry has no crc.
{
Expand Down
6 changes: 6 additions & 0 deletions LogViewer/LogViewer/publish.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@echo off
cd %~dp0

echo Uploading ClickOnce installer for Px4LogViewer
AzurePublishClickOnce %~dp0publish downloads/Px4LogViewer "%LOVETTSOFTWARE_STORAGE_CONNECTION_STRING%"
if ERRORLEVEL 1 goto :eof
Loading

0 comments on commit 6db5c7f

Please sign in to comment.