code: def get_sdr_data_helper(reserve_fn, get_fn, record_id, reservation_id=None):
      
  
      if reservation_id is None:
          reservation_id = reserve_fn()
  
      (next_id, data) = get_fn(reservation_id, record_id, 0, 5)
  
      header = ByteBuffer(data)
      record_id = header.pop_unsigned_int(2)
      record_version = header.pop_unsigned_int(1)
      record_type = header.pop_unsigned_int(1)
      record_payload_length = header.pop_unsigned_int(1)
      record_length = record_payload_length + 5
      record_data = ByteBuffer(data)
  
      offset = len(record_data)
      max_req_len = 20
      retry = 20
  
      # now get the other record data
      while True:
          retry -= 1
          if retry == 0:
              raise RetryError()
  
          length = max_req_len
          if (offset + length) > record_length:
              length = record_length - offset
  
          try:
              (next_id, data) = get_fn(reservation_id, record_id, offset, length)
          except CompletionCodeError as e:
              if e.cc == constants.CC_CANT_RET_NUM_REQ_BYTES:
                  # reduce max lenght
                  max_req_len -= 4
                  if max_req_len <= 0:
                      retry = 0
              else:
                  raise CompletionCodeError(e.cc)
  
          record_data.extend(data[:])
          offset = len(record_data)
          if len(record_data) >= record_length:
              break
  
      return (next_id, record_data)
docs: Helper function to retrieve the sdr data using the specified
      functions.
  
      This can be used for SDRs from the Sensor Device or form the SDR
      repository.