Skip to content

Commit

Permalink
DroneCan: fix update request method to send at 1hz until file read re…
Browse files Browse the repository at this point in the history
…quest
  • Loading branch information
meee1 committed May 21, 2024
1 parent 5cedb78 commit 9b30458
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions ExtLibs/DroneCAN/DroneCAN.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,7 @@ public void Update(byte nodeid, string devicename, double hwversion, string firm
else
{
Console.WriteLine("Got BeginFirmwareUpdate_res " + frame.SourceNode);
acceptbegin = true;
// move acceptbegin to uavcan_protocol_file_Read_req
}
}
else if (msg.GetType() == typeof(DroneCAN.uavcan_protocol_GetNodeInfo_res))
Expand All @@ -1143,15 +1143,16 @@ public void Update(byte nodeid, string devicename, double hwversion, string firm
{
image_file_remote_path = new DroneCAN.uavcan_protocol_file_Path()
{
path = firmware_namebytes, path_len = (byte) firmware_namebytes.Length
path = firmware_namebytes,
path_len = (byte)firmware_namebytes.Length
},
source_node_id = SourceNode
};
var slcan = PackageMessageSLCAN(frame.SourceNode, frame.Priority, transferID++, req_msg);
WriteToStreamSLCAN(slcan);
Console.WriteLine("Send uavcan_protocol_file_BeginFirmwareUpdate_req");
WriteToStreamSLCAN(slcan);
Console.WriteLine("Send uavcan_protocol_file_BeginFirmwareUpdate_req");
}
else
{
Expand Down Expand Up @@ -1182,6 +1183,10 @@ public void Update(byte nodeid, string devicename, double hwversion, string firm
return;
}
}
else if (msg.GetType() == typeof(DroneCAN.uavcan_protocol_file_Read_req))
{
acceptbegin = true;
}
};
MessageReceived += updatedelegate;

Expand Down Expand Up @@ -1223,7 +1228,7 @@ public void Update(byte nodeid, string devicename, double hwversion, string firm
int b = 0;
while (!done)
{
Thread.Sleep(2000);
Thread.Sleep(1000);

if (exception != null || cancel.IsCancellationRequested)
{
Expand All @@ -1235,7 +1240,7 @@ public void Update(byte nodeid, string devicename, double hwversion, string firm
var lastrxts = NodeList.First(a => a.Key == nodeid).Value.uptime_sec;
if(lastrxts != timestamp)
b = 0;
if (b > 5)
if (b > 10)
{
Console.WriteLine("Possible update issue " + nodeid + " (no nodestatus) ");
}
Expand All @@ -1256,7 +1261,7 @@ public void Update(byte nodeid, string devicename, double hwversion, string firm
}

b++;
if (b > 30)
if (b > 60)
{
break;
}
Expand Down

0 comments on commit 9b30458

Please sign in to comment.