Error -307665: Channel Does Not Have Write Access Occurs when Using VeriStand Python API

Updated Sep 28, 2024

Reported In

Software

  • VeriStand

Programming Language

  • Python

Issue Details

I am using the VeriStand Python API to set channel values in my deployed VeriStand project. I am able to create a Channel Reference to most channels in my project and write to the value property of the object to set the channel value as shown in the API reference examples. However, when I use this method to write to a parameter of a model, I get the following error:

The call into the C# API failed with error code -307665. Message: NI VeriStand: Channel does not have write access.

Solution

Model parameters are not like other channels in a VeriStand project and cannot be written to using the ChannelReference.value method. Instead, you must open a ModelManager2 session and use the methods from the ModelManager2 API to set parameter values. Refer to the ModelManager2 methods in the NIVeriStand Legacy Python API Refence

For example, here is a Python script that could be used to set the Idle_Speed_RPM parameter of the Engine Demo model that is included with VeriStand. Before running this code, open the Engine Demo example project in VeriStand and deploy it. 
 
from niveristand.legacy import NIVeriStand

def set_parameter_value():
    
    # Open a ModelManager2 reference using "localhost" as the gateway address.
    modelRef = NIVeriStand.ModelManager2("localhost")
	
    #Here we use the the SetSingleParameterValue(target, name, value) method from the ModelManager2 API. Target is the name of the controller where the model is running. Name is the name or expression of the model parameter you wish to set. 
    modelRef.SetSingleParameterValue("Controller","Idle_Speed_RPM", 1500)

if __name__ == '__main__':
    set_parameter_value()
ModelManager2 includes many different methods for reading and writing single or multiple parameters.
 

Additional Information

The Model Manager is an asynchronous process that allows you to read and write model parameters in batches so that it does not impact the performance on the loop running the model.

Refer to Setting Model Parameters for more details on ways to interact with parameters.