1 # SPDX-License-Identifier: GPL-2.0+
2 # vim: ts=2:sw=2:et:tw=80:nowrap
4 This file helps to extract string names of NI signals as included in comedi.h
5 between NI_NAMES_BASE and NI_NAMES_BASE+NI_NUM_NAMES.
8 # This is simply to aide in creating the entries in the order of the value of
9 # the device-global NI signal/terminal constants defined in comedi.h
23 'NI_CtrArmStartTrigger',
24 'NI_CtrInternalOutput',
32 # load all the static names; start with those that do not begin with NI_
33 name_dict['PXI_Star'] = comedi_h.PXI_Star
34 name_dict['PXI_Clk10'] = comedi_h.PXI_Clk10
36 #load all macro values
38 f = getattr(comedi_h, fun)
40 '{}({})'.format(fun,i):f(i) for i in range(1 + f(-1) - f(0))
43 #load everything else in ni_common_signal_names enum
45 k:v for k,v in comedi_h.__dict__.items()
46 if k.startswith('NI_') and (not callable(v)) and
47 comedi_h.NI_COUNTER_NAMES_MAX < v < (comedi_h.NI_NAMES_BASE + comedi_h.NI_NUM_NAMES)
50 # now create reverse lookup (value -> name)
52 val_dict = {v:k for k,v in name_dict.items()}
54 return name_dict, val_dict
56 name_to_value, value_to_name = get_ni_names()