ENUM(9)

πŸ“¦
version 2.9.4 Β· 3 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– ENUM(9) πŸ’–

okay bestie, sit DOWN, because this is enum, a LinuxCNC manpage, and it's literally the most group-chat-coded little component ever. it takes integers and turns them into bits, and it takes bits and turns them back into integers. it's giving translator. it's giving bilingual icon. πŸ’…


✨ NAME ✨

enum β€” enumerate integer values into bits πŸ¦‹


🌸 SYNOPSIS 🌸

loadrt enum
enums=E;enum1pin1;enum1pin2;;;enum1pin3,D;;;enum2pin1;enum2pin2
[names=name1,name2]

πŸ’œ DESCRIPTION πŸ’œ

so like, enum converts integer values into bits and vice versa. that's the whole vibe. bidirectional queen. πŸ‘‘

the component is especially suitable for encoding and decoding register values for modbus devices, where control commands and status are frequently encoded as enumerations rather than bits. for example 0 = stop, 1 = forwards, 2 = backwards, 3 = jog-forwards etc. see? a little integer doing so much emotional labor. 😭

the pins created, and the behaviour of the component, are controlled by the load-time modparams enums= and names=. those two are the puppet masters. the main characters, if you will.

the enums= parameter should be a comma-separated list of semicolon-separated pin labels. the enumerated values will increase in sequence starting at zero. to skip a value use a zero-length label, ie two consecutive semicolons, as shown in the examples. (yes bestie, the empty slot is on purpose. it's the gap in the friendship group. 🫢)

there should be no spaces in the enums= list. none. not one. i'm so serious. πŸ™ˆ

names= is an optional list of component instance names. if names= is omitted the functions and pins will be named enum-decode.... or enum-encode....

taking the example configuration above, if enum-decode.01.enum2pin1-in is set to TRUE then the output pin enum-decode.01.output will be set to the value 2. if enum-decode.01.enum2pin2-in is set to true then the output would be 3. see how that escalates? 2, then 3. growth. 🌈

conversely, if enum-encode.00.input is set to 4 then the pin enum-encode.00.enum1pin3-out will be set to TRUE. and that's the reverse pipeline, slay. ✨


πŸŽ€ OPTIONS πŸŽ€

listen, this part is the control codes, and they go preceding the list of labels:

  • D β€” decode. a D-type enum will set the value of HAL bit pins in response to changes to the enum-decode.NN.input value.
  • E β€” encode. an E-type enum will set the value of the enum-encode.NN.output integer depending on which enum-encode.NN.label-bit value is set.

if more than one label-bit input pin is set the output value will correspond to the pin label later in the list. (last one wins, basically. it's giving main character energy at the end of the semicolon list. πŸ‘‘)

E and D-type enumerations may be freely mixed in separate instances. they coexist. they don't have beef. periodt.


πŸ¦‹ FUNCTIONS πŸ¦‹

  • enum-decode.NN β€” if instance type = "D"
  • enum-encode.NN β€” if instance type = "E"

that's it. two moods. pick your fighter. πŸ’…


⭐ PINS ⭐

  • enum-decode.NN.input β€” the integer value to be decoded
  • enum-decode.NN.label-out β€” output bits of a decode instance
  • enum-decode.NN.label-val β€” the enumeration value corresponding to each specific bit output. these are populated in sequence during loading but may be over-ridden in HAL if convenient.
  • enum-encode.NN.label-in β€” input bits of a decode instance
  • enum-encode.NN.label-val β€” the enumeration value corresponding to each specified bit input. these are populated in sequence during loading but may be over-ridden in HAL if convenient.
  • enum-decode.NN.output β€” the integer value corresponding to the set bit input.

ngl the sheer number of pins here is a lot, but they're all doing their little jobs and honestly? we respect them. πŸ’–


πŸ’€ BUGS πŸ’€

if no bits are set the output value will be zero even if zero is a defined enumeration.

okay so that's the cursed part. zero is the void value whether or not you asked for zero. the enum said "default state: nothing." not me getting philosophical about a HAL component. 😭

🌸 AUTHOR 🌸

Andy Pugh


πŸ“ REPORTING BUGS πŸ“

report bugs to at the LinuxCNC github issues list:

https://github.com/LinuxCNC/linuxcnc/issues


Copyright Β© 2023 Andy Pugh. this is free software; see the source for copying conditions. there is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


and that's the whole page, bestie!! this lil writeup lives under the LinuxCNC name, dated 03/17/2026, and it's filed as ENUM(9) β€” so when you're deep in the man pages at 2am, iykyk. go forth and encode. πŸ§šπŸ’–βœ¨

πŸ“¦ where this page comes from