STRUCT COMEDI_CMD(9)
β¨ struct comedi_cmd(9) β¨
okay so bestie, welcome to struct comedi_cmd from the Kernel API Manual β this is literally the blueprint for a COMEDI asynchronous acquisition command and i'm obsessed π
π NAME π
struct comedi_cmd β the deets for a COMEDI asynchronous acquisition command. it's giving "everything you need to tell the kernel what to sample" energy β¨
π¦ SYNOPSIS π¦
struct comedi_cmd {
unsigned int subdev;
unsigned int flags;
unsigned int start_src;
unsigned int start_arg;
unsigned int scan_begin_src;
unsigned int scan_begin_arg;
unsigned int convert_src;
unsigned int convert_arg;
unsigned int scan_end_src;
unsigned int scan_end_arg;
unsigned int stop_src;
unsigned int stop_arg;
unsigned int *chanlist;
unsigned int chanlist_len;
short __user *data;
unsigned int data_len;
};
π Members π
so like, every single field, no skips, periodt:
subdevβ the subdevice index. which little chunk of the device we're talking to π«Άflagsβ command flags (CMDF_xxx). the vibe switches β¨start_srcβ the "start acquisition" trigger source (TRIG_xxx).start_argβ the "start acquisition" trigger argument.scan_begin_srcβ the "scan begin" trigger source.scan_begin_argβ the "scan begin" trigger argument.convert_srcβ the "convert" trigger source.convert_argβ the "convert" trigger argument.scan_end_srcβ the "scan end" trigger source.scan_end_argβ the "scan end" trigger argument.stop_srcβ the "stop acquisition" trigger source.stop_argβ the "stop acquisition" trigger argument.chanlistβ pointer to an array of"chanspec"values, holding a sequence of channel numbers packed together with the analog range index, etc. this is the itinerary bestie πΊοΈchanlist_lenβ number of channels in the sequence.dataβ pointer to miscellaneous set-up data (not used β literally just sitting there, main character energy but no lines π).data_lenβ length of that miscellaneous set-up data.
π₯ Description π₯
so this struct is what you pass to the COMEDI_CMD or COMEDI_CMDTEST ioctl to set up or validate an asynchronous acquisition command. lowkey important: the ioctl may modify the struct comedi_cmd and copy it back to the caller. so don't clutch your original values too hard, they might come back different ngl π
β optional command flags (OR them together, bestie) β
CMDF_BOGUSβ makes theCOMEDI_CMDioctl return errorEAGAINinstead of starting the command. it's a fake-out, a little bit iconic honestly πCMDF_PRIORITYβ requests "hard real-time" processing β which is not supported in this version of COMEDI. so like, ask away, but she's not answering πCMDF_WAKE_EOSβ requests that the command makes data available for reading after every "scan" period. wake up babe, new scan dropped π£οΈCMDF_WRITEβ marks the command as being in the "write" (to device) direction. you don't need to specify this unless the subdevice supports commands in either direction. pick a lane only when there are two lanes fr frCMDF_RAWDATAβ prevents the command from "munging" the data between the COMEDI sample format and the raw hardware sample format. no munging. none. raw as intended β¨CMDF_ROUND_NEARESTβ requests timing periods be rounded to nearest supported values.CMDF_ROUND_DOWNβ requests timing periods be rounded down to supported values (frequencies rounded up). yes that's the opposite direction, yes that's the whole joke πCMDF_ROUND_UPβ requests timing periods be rounded up to supported values (frequencies rounded down).
π trigger source values π
these apply to start_src, scan_begin_src, convert_src, scan_end_src, and stop_src β the whole trigger friend group:
TRIG_ANYβ the "all ones" value, used to test which trigger sources are supported. the vibe check of triggers πTRIG_INVALIDβ the "all zeroes" value, used to say that all requested trigger sources are invalid. not it πTRIG_NONEβ never trigger. often used as astop_srcvalue, because sometimes the answer is "we don't" π«TRIG_NOWβ trigger after_argnanoseconds.TRIG_FOLLOWβ trigger follows another event. she's a follower, but make it β¨synchronizedβ¨TRIG_TIMERβ trigger every_argnanoseconds.TRIG_COUNTβ trigger when count_argis reached.TRIG_EXTβ trigger on an external signal specified by_arg.TRIG_INTβ trigger on an internal, software trigger specified by_arg.TRIG_OTHERβ trigger on some other, driver-defined signal specified by_arg. mysterious. we love her π§
reminder bestie: the_argvalues go with their matching_srcfield, so keep them paired up or the whole command gets messy π
π SEE ALSO π
the whole kernel-file friend group, all of them, no gatekeeping:
- Kernel file
./include/uapi/linux/comedi.h enum comedi_subdevice_type(9)enum comedi_io_direction(9)enum configuration_ids(9)enum comedi_digital_trig_op(9)enum comedi_support_level(9)enum comedi_counter_status_flags(9)struct comedi_insn(9)struct comedi_insnlist(9)struct comedi_chaninfo(9)struct comedi_rangeinfo(9)struct comedi_krange(9)struct comedi_subdinfo(9)struct comedi_devinfo(9)struct comedi_devconfig(9)struct comedi_bufconfig(9)struct comedi_bufinfo(9)
aaaand that's the page, bestie π«Ά this one lives in ./include/uapi/linux, dated October 2026 β go set up some asynchronous acquisition commands, slay, and remember: the ioctl might hand your struct back looking different, and that's just the circle of life π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms