Skip to content

Commit

Permalink
UAVCan: add toggle checking
Browse files Browse the repository at this point in the history
  • Loading branch information
meee1 committed Apr 28, 2020
1 parent 5df2f2c commit ed5ed76
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions ExtLibs/UAVCAN/UAVCan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,22 @@ public void ReadMessage(string line)

transfer[(packet_id, payload.TransferID)].AddRange(payload.Payload);

//todo check toggle
{
var totalbytes = transfer[(packet_id, payload.TransferID)].Count;

var current = (totalbytes / 7) % 2;

if((current == 1) == payload.Toggle)
{
if (!payload.EOT)
{
transfer.Remove((packet_id, payload.TransferID));
Console.WriteLine("Bad Toggle {0}", frame.MsgTypeID);
return;
//error here
}
}
}

if (payload.SOT && !payload.EOT)
{
Expand Down Expand Up @@ -1331,7 +1346,7 @@ public void ReadMessage(string line)

if (crc != payload_crc)
{
Console.WriteLine("Bad Message " + frame.MsgTypeID);
Console.WriteLine("Bad Message CRC Fail " + frame.MsgTypeID);
return;
}
}
Expand Down

0 comments on commit ed5ed76

Please sign in to comment.