C# -> WPF -> .NET 6
Windows 10 64-bit, Visual Studio Community 2022 v17.9.2
I am writing a program in which I want to see the current from a 3-phase brushless DC Motor. Each phase will be displayed in a different colour to differentiate them. I have managed to get this to work to some extent.
I have a PIC32 MCU which sends a 57 byte data packet (8x16-bit value for each phase, 9 byte header) out at 115,200 bps, I send a full motor revolution of data and then skip 50 revolutions so the data rate is not ridiculous. The motor speed is 200 RPS.
My C# WPF program receives and parses this data very well but when I want to display the data using either LiveCharts or other program it slows down considerably, therefore I want to know if I can do this another way.
Method
I create a serial class which I have a background worker thread receiving my data into a 5k byte buffer, the head.
Another background worker thread, the tail, will attempt to parse and decode the data and if the checksum is good then it will fire an event to store this data in a serialised class so it can be saved. The data is then marshalled in to the UI Thread so it can be displayed.
I was thinking of simply setting a separate thread on a timer which will display the data in chunks instead of .
If I simply do not display the data on a chart then I can receive over 10k data packets without a single bad packet.
The UI Thread chart seems to be the bottleneck, obviously.
Am I running to many threads on a single process?
Should I send more data in a single packet as displaying more data in one go might be more preferable to less data more often?
Any help is appreciated.
DM