No device connected error using write command to USB connected AFG3022C #441
-
| 
         While I'm able to connect to the device, it appears I am not able to write commands to the device and am prompted with the following error message: tm_devices.commands.helpers.generic_commands.NoDeviceProvidedError: No PIControl object was provided, the .write() method cannot be used. Code below: from tm_devices import DeviceManager, register_additional_usbtmc_mapping
from tm_devices.drivers import AFG3KC
register_additional_usbtmc_mapping("AFG3KC",model_id="0x034A",vendor_id="0x0699")
with DeviceManager(verbose=True) as device_manager:
    fungen :AFG3KC= device_manager.add_afg("AFG3KC-C012949",connection_type="USB")
fungen.commands.source1.burst._ncycles.write('8') | 
  
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
| 
         Can you provide the logfile or full console output? That will help us understand what exactly is happening here. I believe that the issue is your indentation, the call to the command is happening outside your context manager, which means that the Device Manager has closed all connections to all devices by that point. That is why the code says there is no device provided. The corrected code should look like this: from tm_devices import DeviceManager, register_additional_usbtmc_mapping
from tm_devices.drivers import AFG3KC
register_additional_usbtmc_mapping("AFG3KC", model_id="0x034A", vendor_id="0x0699")
with DeviceManager(verbose=True) as device_manager:
    fungen: AFG3KC = device_manager.add_afg("AFG3KC-C012949", connection_type="USB")
    fungen.commands.source1.burst.ncycles.write('8')Note the extra tab on the command call, bringing it inside the context manager.  | 
  
Beta Was this translation helpful? Give feedback.
Can you provide the logfile or full console output? That will help us understand what exactly is happening here.
I believe that the issue is your indentation, the call to the command is happening outside your context manager, which means that the Device Manager has closed all connections to all devices by that point. That is why the code says there is no device provided.
The corrected code should look like this: