Skip to content

Commit

Permalink
feat(sdr): add helper method for dataIndex extraction from SdrPayload
Browse files Browse the repository at this point in the history
  • Loading branch information
asvol committed Nov 8, 2023
1 parent 1e84265 commit fe51e11
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public AsvSdrServer(IMavlinkV2Connection connection,

public void Start()
{
_transponder.Start(TimeSpan.FromMilliseconds(500),TimeSpan.FromMilliseconds(_config.StatusRateMs));
_transponder.Start(TimeSpan.FromMilliseconds(600),TimeSpan.FromMilliseconds(_config.StatusRateMs));
}

public void Set(Action<AsvSdrOutStatusPayload> changeCallback)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,32 +76,38 @@ public static void Write(this IListDataFile<AsvSdrRecordFileMetadata> self, AsvS
{
self.ReadMetadata().Info.CopyTo(record);
}
public static bool Write(this IListDataFile<AsvSdrRecordFileMetadata> self, IPacketV2<IPayload> packet)

public static bool TryReadDataIndex(IPacketV2<IPayload> packet, out uint index)
{
var type = (AsvSdrCustomMode)packet.MessageId;
switch (type)
{
case AsvSdrCustomMode.AsvSdrCustomModeLlz:
var gp = packet as AsvSdrRecordDataLlzPacket;
Debug.Assert(gp != null);
self.Write(gp.Payload);
break;
index = gp.Payload.DataIndex;
return true;
case AsvSdrCustomMode.AsvSdrCustomModeGp:
var llz = packet as AsvSdrRecordDataGpPacket;
Debug.Assert(llz != null);
self.Write(llz.Payload);
break;
index = llz.Payload.DataIndex;
return true;
case AsvSdrCustomMode.AsvSdrCustomModeVor:
var vor = packet as AsvSdrRecordDataVorPacket;
Debug.Assert(vor != null);
self.Write(vor.Payload);
break;
index = vor.Payload.DataIndex;
return true;
case AsvSdrCustomMode.AsvSdrCustomModeIdle:
default:
index = 0;
return false;
}

}

public static bool Write(this IListDataFile<AsvSdrRecordFileMetadata> self, IPacketV2<IPayload> packet)
{
if (TryReadDataIndex(packet, out var dataIndex) == false) return false;
self.Write(dataIndex, packet.Payload);
return true;
}

Expand Down

0 comments on commit fe51e11

Please sign in to comment.