[comedi] pyusbdux V2 now callback based

Bernd Porr <[email protected]> Tue, 15 Nov 2022 15:33:59 +0000
Newsgroups gmane.linux.comedi
Message-ID <[email protected]>
Hi all,

I've rewritten pyusbdux now with callbacks. So instead of doing polling=20
in python in a loop the python program registers a callback and then=20
receives the samples at the requested sampling rate:

#!/usr/bin/python3

import pyusbdux as dux

class DataCallback(dux.Callback):

 =C2=A0=C2=A0=C2=A0 def hasSample(self,s): # <-- sample arrives here
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 print("s:",s)

cb =3D DataCallback()

# open default USBDUX
dux.open()

# sampling from 8 channels
# at a sampling rate of 250Hz.
dux.start(cb,8,250)

# Just idles till the user presses return.
input()

# Stops the data acquisition.
dux.stop()

https://github.com/berndporr/pyusbdux

https://pypi.org/project/pyusbdux/

Coding-wise it's an interesting twist with an interface between two=20
languages and swig is managing that. I'm using std::array which is now=20
fully supported so that the number of elements in an array are no longer=20
a problem.

Best,

/Bernd

--=20
www:    http://www.berndporr.me.uk
         http://www.tinnitustailor.tech
         http://www.attys.tech
Mobile: +44 (0)7840 340069
Work:   +44 (0)141 330 5237
         University of Glasgow
         School of Engineering
         Rankine Building, Oakfield Avenue,
         Glasgow, G12 8LT

--=20
You received this message because you are subscribed to the Google Groups "=
Comedi: Linux Control and Measurement Device Interface" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/=
comedi_list/87a2df4f-f981-0909-7fa9-5f339b42cd56%40berndporr.me.uk.