STRUCT COMEDI_CMD(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ 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 the COMEDI_CMD ioctl return error EAGAIN instead 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 fr
  • CMDF_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 a stop_src value, because sometimes the answer is "we don't" 🚫
  • TRIG_NOW β€” trigger after _arg nanoseconds.
  • TRIG_FOLLOW β€” trigger follows another event. she's a follower, but make it ✨synchronized✨
  • TRIG_TIMER β€” trigger every _arg nanoseconds.
  • TRIG_COUNT β€” trigger when count _arg is 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 _arg values go with their matching _src field, 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