title: Perform task with NI-DAQMX Python library
body: <p>I'm trying to read a led state and a led blinking with the NI device and board. My code consists of an init task which reads port/line that I choose as parameter of a class. When I call this class and set parameters, a task is created and runs to detect change detection. For one port/line it's okay, but when I'm trying to define another object with this with others parameters (other port/line) I can't. And this error occurs:</p>
  <blockquote>
  <p>The specified resource is reserved. The operation could not be completed as specified.</p>
  </blockquote>
  <p>Please help me, and if you can tell me something about task creation and conflict between two of us. Thanks you in advance.</p>
  <p>This my code:</p>
  <pre><code>class Digital:
      def __init__(self, port_num=None, line_num=None, board_name=None, mode='INPUT', init=False,
                   txt_logger=None, debug=False):
          &quot;&quot;&quot;
          ChannelAnalog constructor
          :param self
          :param port_num: specifies the number of the port. range : [0;11]
          :param line_num: specifies the number of the line, range : [0;7]. Tt is possible to select 
          a single line by
          specifying a single number or to select several adjacent lines by specifying the list of bounds (ex : [2,7]).
          :param board_name : private board name
          :param mode : specifies the I/O mode, (INPUT, OUTPUT)
          :param init : specifies the init state of the line if it is in INPUT mode
          :param txt_logger
          :param debug : used for test program without NI instrument
          &quot;&quot;&quot;
          # Private/Ni port name
          self.port_num = port_num
          # Private/NI line name
          self.line_num = line_num
          # Object line linked National instrument board name
          self.board_name = board_name
          # I/O mode
          self.mode = mode
          # Initial state for output channel
          self.init_val = init
  
          # Initial counter
          self.counter_led = 0
  
          # Init led state
          self.led_state = False
          
          # Parameters used for design test
          self.txt_logger = txt_logger
          self.debug = debug
          self.state = init
          if self.txt_logger:
              self.txt_logger.debug('ChannelAnalog initialization')
  
          if isinstance(self.line_num, list):
              if len(self.line_num) == 2:
                  line_name = f'{self.line_num[0]}:{self.line_num[1]}'
              else:
                  raise ValueError('The number of the line is not correctly defined')
          else:
              line_name = f'{self.line_num}'
  
          if debug:
              self.debug_state = True
              self.txt_logger.info(f'Creation of the digital line {self.board_name}/port{self.port_num}/'
                                   f'line{line_name} in {self.mode.lower()} mode')
          else:
              # Declaration of the line to generate voltage
              self.digital_task = nidaqmx.Task(new_task_name=f'{self.board_name}_port{self.port_num}_line{line_name}')
              pass
  
          self.digital_task.di_channels.add_di_chan(f'{self.board_name}/port{self.port_num}/line{line_name}' 
                                               , line_grouping=LineGrouping.CHAN_PER_LINE)
  
          self.led_state = self.digital_task.read()
  
          self.digital_task.timing.cfg_change_detection_timing(
              rising_edge_chan=f'{self.board_name}/port{self.port_num}/'
                               f'line{line_name}',
              falling_edge_chan=f'{self.board_name}/port{self.port_num}/'
                                f'line{line_name}',
              sample_mode=nidaqmx.constants.AcquisitionType.CONTINUOUS)
  
          def callback(task_handle=None, signal_type=nidaqmx.constants.Signal.CHANGE_DETECTION_EVENT,
                       callback_data=1):
              logging.debug(&quot;CALLBACK CALLED&quot;)
              logging.debug(&quot;task_handle {}&quot;.format(task_handle))
              logging.debug(&quot;signal_type {}&quot;.format(signal_type))
              logging.debug(&quot;callback_data {}&quot;.format(callback_data))
  
              # Read led state
              self.led_state = self.digital_task.read()
  
              # Counter incrementation to show blink state
              self.counter_led += 1
              return 0
  
          self.digital_task.register_signal_event(signal_type=nidaqmx.constants.Signal.CHANGE_DETECTION_EVEN 
                                          T, callback_method=callback)
  
          self.digital_task.start()
  
      def __del__(self):
          if self.debug:
              self.txt_logger.info(f'Delete digital channel {self.port_num}.{self.line_num}')
          else:
              print(&quot;task name: {},{}&quot;.format(self.port_num, self.line_num))
              self.digital_task.stop()
              self.digital_task.close()
         
      def read_led_state(self):
          &quot;&quot;&quot;
          This function is used to read the state of the selected digital line\n
          :param self:
          :return state:
          &quot;&quot;&quot;
          if self.debug:
              self.txt_logger.info(f'Read the channel {self.port_num}.{self.line_num} : {self.debug_state}')
          else:
              if self.led_state:
                  print(&quot;LED ON&quot;)
                  status = True
              else:
                  print('LED OFF')
                  status = False
  
              return status
  
      def detect_led_blinking(self):
          &quot;&quot;&quot;
          This function is used to read the state of the selected digital line\n
          :param self:
          :return state:
          &quot;&quot;&quot;
          if self.debug:
              self.txt_logger.info(f'Read the channel {self.port_num}.{self.line_num} : {self.debug_state}')
          else:
              start_counter = self.counter_led
  
              sleep(0.5)
  
              if self.counter_led != start_counter:
                  print(&quot;Led is blinking&quot;)
                  status = True
              else:
                  print(&quot;Led is not blinking&quot;)
                  status = False
  
              return status
  
  
  if __name__ == &quot;__main__&quot;:
  
      digital = Digital(port_num=2, line_num=7, board_name='PXI1Slot3')
  
      digital2 = Digital(port_num=2, line_num=6, board_name='PXI1Slot3')
  
      while True:
          # Detect blinking and read the led 1 state on port 2 line 7
          digital.detect_led_blinking()
          digital.read_led_state()
  
          # Detect blinking and read the led 2 state on port 2 line 6
          digital2.detect_led_blinking()
          digital2.read_led_state()
  </code></pre>