{"id":19554128,"url":"https://github.com/berndporr/pyusbdux","last_synced_at":"2025-06-16T05:07:36.790Z","repository":{"id":57458218,"uuid":"156371626","full_name":"berndporr/pyusbdux","owner":"berndporr","description":"Python API for the USB-DUX data acquisition devices.","archived":false,"fork":false,"pushed_at":"2023-01-27T22:39:37.000Z","size":100,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-08T00:04:55.965Z","etag":null,"topics":["comedi","data-acquisition","oscilloscope","python-library","python3","usb-dux","usbdux"],"latest_commit_sha":null,"homepage":"http://www.linux-usb-daq.co.uk","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/berndporr.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-06T11:13:35.000Z","updated_at":"2023-08-22T00:29:48.000Z","dependencies_parsed_at":"2023-02-15T13:15:27.085Z","dependency_job_id":null,"html_url":"https://github.com/berndporr/pyusbdux","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"purl":"pkg:github/berndporr/pyusbdux","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/berndporr%2Fpyusbdux","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/berndporr%2Fpyusbdux/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/berndporr%2Fpyusbdux/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/berndporr%2Fpyusbdux/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/berndporr","download_url":"https://codeload.github.com/berndporr/pyusbdux/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/berndporr%2Fpyusbdux/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260101969,"owners_count":22959043,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["comedi","data-acquisition","oscilloscope","python-library","python3","usb-dux","usbdux"],"created_at":"2024-11-11T04:26:00.250Z","updated_at":"2025-06-16T05:07:36.739Z","avatar_url":"https://github.com/berndporr.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"==========================\nPython API for the USB-DUX\n==========================\n\nUSB-DUX are open source \u0026 hardware data acquisition boxes designed for Linux\n\nhttps://github.com/glasgowneuro/usbdux\n\npyusbdux supports the USB-DUX-sigma: 16 analogue inputs (isolated, 24 bit, 1 kHz), 4 analogue out (isolated, 8 bit) and 8 digital I/O\n\n\nInstallation instructions\n=========================\n\nMake sure that you have all `comedi` libraries,\n`swig` and `python3` installed (both runtime and development).\nUse your favourite package manager to install the packages.\n\nThen install `pyusbdux` by typing::\n  \n      pip3 install pyusbdux [--user] [--upgrade]\n\nor\n\n      ./setup install [--user]\n\n\nQuick start guide\n=================\n\nHere are the basic steps how to use the API::\n\n      # load the module\n      import pyusbdux as dux\n\n      # create a callback interface\n      class DataCallback(dux.Callback):\n          def hasSample(self,sample): # sample arrived\n              print(\"s:\",sample) # process sample\n\n      cb = DataCallback()\n\n      # opens the 1st USBDUX device (autodetect)\n      dux.open()\n\n      # Start asynchronous data acquisition in the background: one channel, fs=250Hz\n      dux.start(cb,1,250)\n\n      # do nothing or run a gui\n      input() # do nothing here\n\n      # shutdown\n      dux.stop()\n      dux.close()\n\n\nAPI documentation\n==================\n\nThese are the commands which allow you to access the analogue inputs asynchronously\nand the analogue outputs, digital input and outputs synchronously::\n\n      # opens the comedi device with comediDeviceNumber\n      open(comediDeviceNumber)\n      open()                      # opens 1st USB-DUX device (autodetect)\n\n      # Callback interface\n      class DataCallback(dux.Callback):\n          def hasSample(self,sample): # sample arrived\n              # implement your callback handler here\n\n      # Starts acquisition of n_channels at the sampling rate of fs.\n      # Expects an instance of Callback with overloaded hasSample(self,sample).\n      start(Callback,n_channels, fs)\n      start(Callback,n_channels)           # at fs=250\n\n      # gets the actual sampling rate of the running acquisition\n      getSamplingRate()\n\n      # stops the background acquisition\n      stop()\n\n      # writes to a digital pin the value 0 or 1\n      digital_out(channel, value)\n\n      # reads from a digital pin\n      digital_in(channel)\n\n      # writes to an analogue output pin (raw ADC values)\n      analoge_out(channel, value)\n\n      # gets the max raw value of the analogue output\n      get_analogue_out_max_raw_value()\n\n      # closes the comedi device\n      close()\n\n      # returns the name of the board connected\n      get_board_name()\n\nAny error in comedi throws an exception in python.\n\n\nExample / demo programs\n=======================\n\nIn the folder https://github.com/berndporr/pyusbdux/tree/master/examples are example\nscripts which show you how to sample data from the analogue and digital ports.\n\n\nTroubleshooting\n===============\n\nSpyder\n------\n\nStart your program from the terminal and never within Spyder. Here is\nan example::\n\n    ~/pyusbdux$ cd examples\n    ~/pyusbdux/examples$ python3 ./realtime_plot.py\n\nThe problem with Spyder is that it won't let your Python program terminate properly so\nthat you can examine variables etc. However, this means that\nthe USB-DUX board keeps running even if it seems that execution has finished.\nIf you then re-run your program\nit won't be able to talk to your USB-DUX.\n\nBottomline: Use Spyder only for editing, instead run your program from the terminal. Never start\nyour program from within Spyder.\n\n\nAfter an update still the old version is being used\n---------------------------------------------------\n\nIf you use the `--user` option to install / update packages Python might keep older versions.\n\nSolution: Do a `pip uninstall pyusbdux` multiple times until no version is left \non your computer. Then install it again as described above.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fberndporr%2Fpyusbdux","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fberndporr%2Fpyusbdux","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fberndporr%2Fpyusbdux/lists"}