COMEDI_FROM_PHYS(3)

πŸ’– COMEDI_FROM_PHYS(3) β€” comedi reference, bestie edition πŸ’–

okay so real talk, this is a page from the Comedi reference (section 3, library functions, iykyk) and it's about exactly one thing: turning your cute little physical-unit numbers into raw sample data. let's go πŸ¦‹


✨ NAME ✨

comedi_from_phys β€” convert physical units to sample. that's it. that's the whole job. and it ate. πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <comedilib.h>

lsampl_t comedi_from_phys(double data, comedi_range * range,
                          lsampl_t maxdata);

so you pull in comedilib.h and you call the girl with three things. no cap.


🌸 DESCRIPTION 🌸

Bestie, listen. This function takes a data value that you've got in physical units (that's a double, bestie, floating point, take the decimals) and converts it into a sample value β€” which comes back as an lsampl_t, and that lil guy is gonna land somewhere between 0 and maxdata. Inclusive vibes only.

  • The range parameter is your conversion cheat sheet β€” it's the info it uses to do the mapping.
  • The maxdata parameter is the max possible data value for the channel you're gonna write data into.

and the mapping between physical units and raw data? it's linear, and it assumes the converter has ideal characteristics. like, it's giving perfect fantasy converter. main character energy, zero flaws. ✨

🚨 Important-ish, pay attention: conversion is not affected by out-of-range behavior. out-of-range data parameters get silently truncated to the range 0 to maxdata. no warning, no drama, no error thrown. it just quietly clamps you and moves on. lowkey iconic of it, highkey terrifying if you weren't expecting it. 😭

πŸ‘‘ AUTHORS πŸ‘‘

the legends that made this happen, in order:

  • David Schleef <ds@schleef.org> β€” Author.
  • Frank Mori Hess <fmhess@users.sourceforge.net> β€” Author.
  • Herman Bruyninckx <Herman.Bruyninckx@mech.kuleuven.ac.be> β€” Author.
  • Bernd Porr <tech@linux-usb-daq.co.uk> β€” Author.
  • Ian Abbott <abbotti@mev.co.uk> β€” Author.
  • Γ‰ric Piel <piel@delmic.com> β€” Author.

all of them. Authors. every single one. we love a full roster 🫢


the legal bits, verbatim because we do NOT mess with license text:

Copyright Β© 1998-2003 David Schleef
Copyright Β© 2001-2003, 2005, 2008 Frank Mori Hess
Copyright Β© 2002-2003 Herman Bruyninckx
Copyright Β© 2012 Bernd Porr
Copyright Β© 2012 Ian Abbott
Copyright Β© 2012, 2015 Γ‰ric Piel

This document is part of Comedilib. In the context of this document, the term "source code" as defined by the license is interpreted as the XML source.

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, version 2.1 of the License.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.

πŸŽ€ yes bestie, the all-caps parts are load-bearing. that's the "we are not liable and you cannot pretend you didn't know" font.

🌈 and that's the whole page!! written by Comedi, stamped 03/20/2026, page number COMEDI_FROM_PHYS(3) β€” mwah, go convert something, you've got this πŸ’œπŸ§š

πŸ“¦ where this page comes from