ID and Timestamp are always 0
Code and output is listed below.
ID and Timestamp are always 0.
Project Code:
` using Candle;
namespace ConsoleApp1 { internal class Program { static void Main(string[] args) { Console.WriteLine("Hello, World!");
var devices = Device.ListDevices();
Console.WriteLine("canable device count: " + devices.Count);
foreach (var device in devices) {
device.Open();
Console.WriteLine("open device");
Console.WriteLine("device[0] channel count: " + device.Channels.Count);
foreach (var keyValue in device.Channels) {
var channel = keyValue.Value;
channel.Start(500000);
// Send frame
{
var frame = new Frame();
frame.ID = 0x60b;
frame.Extended = false;
frame.Data = new byte[] { 0x03 };
channel.Send(frame);
Console.WriteLine("send frame");
Console.WriteLine(frame.ToString());
}
Thread.Sleep(500);
// Receive frames
var receivedFrames = channel.Receive();
Console.WriteLine("receive frames");
foreach (var frame in receivedFrames) {
Console.WriteLine(frame.ToString());
}
channel.Stop();
}
var errors = device.ReceiveErrors();
foreach (var error in errors) {
Console.WriteLine(error);
}
device.Close();
}
}
}
} `
OUTPUT from code:
Hello, World! canable device count: 1 open device device[0] channel count: 1 send frame ID : 1547, Data : 03, Time : 0us receive frames ID : 0, Data : 03, Time : 0us ID : 0, Data : 00-00-00-00-00, Time : 0us ID : 0, Data : 09-00-00-00-00-00, Time : 0us ID : 0, Data : 05, Time : 0us ID : 0, Data : 01-1A-B2-07-16-37-32, Time : 0us ID : 0, Data : 0A-00-51-B1-D3-42, Time : 0us ID : 0, Data : 0B-00-00-00-00-00, Time : 0us ID : 0, Data : 0C-00-00-00-00-00, Time : 0us ID : 0, Data : 00-00-00-00-05-0A-00-00, Time : 0us ID : 0, Data : 00-00-00-00-00-00, Time : 0us ID : 0, Data : 0D-00-00-00-00-00, Time : 0us ID : 0, Data : F6-37-22-00, Time : 0us ID : 0, Data : 00-00-00-00-00-00, Time : 0us
C:\Users...\bin\Release\net8.0\ConsoleApp1.exe (process 15172) exited with code 0. To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops. Press any key to close this window . . .
Relevant line of code seems to be: https://github.com/elliotwoods/Candle.NET/blob/9930228366a06095cf592b3776417fe58309d36d/Candle.NET/Device.cs#L332
And you can see in the underlying Candle library...
https://github.com/elliotwoods/Candle.NET/blob/9930228366a06095cf592b3776417fe58309d36d/Candle/candle.c#L347
I'm not calling this in my receive, but you could try to add a call to that before line 332 in Device.cs
Concerning the id coming up as 0 perhaps it's to do with this line: https://github.com/elliotwoods/Candle.NET/blob/9930228366a06095cf592b3776417fe58309d36d/Candle/candle.c#L492
Where echoed packets have an id of 0?
I was able to get this to work by changing build configurations and targeted frameworks. Thanks for your efforts here, this project will be very useful for us.
glad to hear it is useful. Good luck with the project