pyusbdux V2 now callback based

15 views
Skip to first unread message

Bernd Porr

unread,
Nov 15, 2022, 10:34:11 AM11/15/22
to comed...@googlegroups.com
Hi all,

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

#!/usr/bin/python3

import pyusbdux as dux

class DataCallback(dux.Callback):

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

cb = 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
languages and swig is managing that. I'm using std::array which is now
fully supported so that the number of elements in an array are no longer
a problem.

Best,

/Bernd

--
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

Ian Abbott

unread,
Nov 15, 2022, 12:19:26 PM11/15/22
to comed...@googlegroups.com
On 15/11/2022 15:33, Bernd Porr wrote:
> Hi all,
>
> I've rewritten pyusbdux now with callbacks. So instead of doing polling
> in python in a loop the python program registers a callback and then
> receives the samples at the requested sampling rate:

Thanks Bernd. I've just listed it on the
<https://www.comedi.org/applications.html> page because it was missing
before.

--
-=( Ian Abbott <abb...@mev.co.uk> || MEV Ltd. is a company )=-
-=( registered in England & Wales. Regd. number: 02862268. )=-
-=( Regd. addr.: S11 & 12 Building 67, Europa Business Park, )=-
-=( Bird Hall Lane, STOCKPORT, SK3 0XA, UK. || www.mev.co.uk )=-

Reply all
Reply to author
Forward
0 new messages