Hi.

1) you are not calling your leer() function anywhere.
2) it is much better to make an application with threads (but maybe just
fix for #1 will resolve the problem)


On Sat, Jul 6, 2019 at 4:04 AM WILMER CONTRERAS SEPULVEDA <
[email protected]> wrote:

> Hi everyone
>
> I am Wilmer C, i am trying to plot some data which come from a serial port
> (I send it through Bluetooth using an Bluetooth HC05 and an arduino), but
> my code doesn't work.
>
> I am trying to plot in in real time, the frecuency of the data is about
> 800Hz, I design an easy function which take the data from the serial port
> and send it to the update funcion whics is in charge to plot, but sometime
> the graph just doesn't plot nothing and sometimes it plot something but get
> block when are more than 20000 points.
>
> I receive the data from the serial port in a string form as: "S1: 34 S2:
> 345 S3: 245", for this reason i make the things that appear in the function
>
> I leave the program here, and if something can help me, please don't
> hesitate.
>
>
> from pyqtgraph.Qt import QtGui, QtCore
> import numpy as np
> import pyqtgraph as pg
> from pyqtgraph.ptime import time
> import serial
>
> app = QtGui.QApplication([])
>
> p = pg.plot()
> p.setWindowTitle('live plot from serial')
> curve = p.plot()
>
> data = [0]
> raw=serial.Serial("COM8",115200)
> def leer():
>     while True:
>         line = raw.readline()
>         line=str(line)
>         line=line.split(' ')
>         if len(line)>4:
>             line=line[2]
>             line=int(line)
>             return(line)
>         else:
>             continue
>
> def update():
>     global curve, data
>     data.append(int(line))
>     xdata = np.array(data, dtype='float64')
>     curve.setData(xdata)
>     app.processEvents()
>
> timer = QtCore.QTimer()
> timer.timeout.connect(update)
> timer.start(0)
>
> if __name__ == '__main__':
>     import sys
>     if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
>         QtGui.QApplication.instance().exec_()
> raw.close()
>
>
> Thank you so much!
>
> --
> 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/998c60d2-1cab-4aaf-8e3c-06ceb9ebc42d%40googlegroups.com
> <https://groups.google.com/d/msgid/pyqtgraph/998c60d2-1cab-4aaf-8e3c-06ceb9ebc42d%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAD_qyJpsE%3DYjBSbBiHm4e-q%3Dh5-GZu-ZJW%2Bu-CqBrT71LShDCg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to