Here is another example where a 16 bit word is decoded into individual pins but the word is also used as a pin
typedef union { struct { unsigned char SwitchOn : 1; // 00 unsigned char EnableVoltage : 1; // 01 unsigned char QuickStop : 1; // 02 unsigned char EnableOperation : 1; // 03 unsigned char StartHome : 1; // 04 not used in CSP or homing unsigned char bit5 : 1; // 05 not used in CSP or homing unsigned char bit6 : 1; // 06 not used in CSP or homing unsigned char Faultreset : 1; // 07 unsigned char Timeout : 1; // 08 unsigned char bit9 : 1; // 09 not used in any mode unsigned char keep : 6; // 10-15 not used in any mode }b; unsigned int Word; }Control_t; Converted to 64 bit variables to contain the bits sounds just awful. I really think typed variables should be retained. I've worked with several languages over the years that use untyped variables and eventually you have to do some gymnastics somewhere to "trick" the compiler into doing what you need to do. If you don't understand data types, there is no place for you to be programming in C. It's designed to do low level stuff, don't prevent that in hal. After all, it is the data abstraction layer we use with linuxcnc. We can't avoid interfacing with hardware, don't put hurdles in our way. Rod Webster *1300 896 832* +61 435 765 611 Vehicle Modifications Network www.vehiclemods.net.au On Wed, 11 Oct 2023 at 20:34, Nicklas SB Karlsson <n...@nksb.eu> wrote: > Den 2023-10-11 kl. 12:13, skrev andy pugh: > > On Wed, 11 Oct 2023 at 10:58, Nicklas SB Karlsson <n...@nksb.eu> wrote: > > > >> Have programmed for many years and some programming languages have quite > >> hard check if data types fit together and think this in general is a > >> good feature. > > And I have programmed _HAL_ for over 10 years, and so think that in > > this case there will probably not be many problems. > > > > One example of a useful simplification is that the pin > > motion.motion-type has an output type of S32. The most common > > components that you might want to connect this to are are "enum" and > > "bitslice", both of which require an unsigned input. > > > > S64 has more than enough bits to cover both situations. > > > I say you could use large numbers on inputs and allow automatic type > casting if fit inside but not the opposite. > > > Nicklas Karlsson > > > > _______________________________________________ > Emc-developers mailing list > Emc-developers@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/emc-developers > _______________________________________________ Emc-developers mailing list Emc-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-developers