Hi,

Taking a quick look, you are calling your _update() method once during 
initialisation of the plot window, and then that's it. If everything else 
is working, it will only collect the first data point.
You need to be calling your _update() method in a background thread or 
using a QTimer. Take a look at the examples (eg. "updating plot" in Basic 
Plotting) which uses a QTimer to continuously call the update method. 
Specifically, the lines are:

timer = QtCore.QTimer()
timer.timeout.connect(update)
timer.start(50)

If you go the timer route you may also want to change your pass inside the 
while loop to a return so that the Qt thread doesn't get locked up when 
serial data isn't present.

Another tip would be to think about "blocking the pipes" with your flow of 
serial data. That is, if your arduino is trying to continuously pump data 
at some rate, you should try to handle it at that rate on the computer 
side. Either call your QTimer more often than the arduino is sending data, 
and/or in your _update() method, run a loop to completely drain all waiting 
serial data before returning. Sometimes this isn't a problem, but I find 
Windows in particular has some terrible serial buffering/performance issues 
that can cause strange behaviour if your thread stalls for a bit for 
whatever reason.

You may eventually also want to add some try/except blocks to handle 
failures reading from the serial device, or corruption etc that stops you 
from decoding the two floats from the received string.
Patrick
On Saturday, 27 August 2022 at 12:41:10 am UTC+9:30 [email protected] wrote:

> Hello,
>
> I am currently trying to plot manipulated joystick serial data from an 
> Arduino. I am running into the problem that I can create the graph canvas, 
> but there is no real-time plotting occurring.
>

-- 
You received this message because you are subscribed to the Google Groups 
"pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyqtgraph/0a3e4914-6c13-435b-8ffd-b5f83a8ad29an%40googlegroups.com.

Reply via email to