Important
For more information about each available TPCANParameter, please refer to the companion PDF documentation PCAN-Parameter_Documentation.pdf.
public static TPCANStatus SetValue(
ushort Channel,
TPCANParameter Parameter,
string StringBuffer,
uint BufferLength
)
Public Shared Function SetValue (
Channel As UShort,
Parameter As TPCANParameter,
StringBuffer As String,
BufferLength As UInteger
) As TPCANStatus
public:
static TPCANStatus SetValue(
unsigned short Channel,
TPCANParameter Parameter,
String^ StringBuffer,
unsigned int BufferLength
)
The return value is a TPCANStatus value. PCAN_ERROR_OK is returned on success. The typical errors in case of failure are:
Use the method SetValue to change the behavior of a PCAN Channel or to set environment values like writing custom messages into the API log file. Take in account that not all parameters are supported for all PCAN Channels. The access's type of the parameters can also be different.
For more information about the possible values that can be used for parameter configuration, see Parameter Value Definitions
The following example shows the use of SetValue(UInt16, TPCANParameter, String, UInt32) method on the channel PCAN_NONEBUS to set (and activate) the path for the log file of a debug session. In case of failure, the returned code will be translated to a text (according with the operating system language) in English, German, Italian, French or Spanish, and it will be shown to the user.
TPCANStatus result;
System.Text.StringBuilder strMsg;
string strBuffer;
strMsg = new System.Text.StringBuilder(256);
// The path for the Log file is set.
// Note that this parameter is set using the
// default Channel value (PCANBasic.PCAN_NONEBUS)
//
strBuffer = "C:\\Users\\Admin\\Desktop";
result = PCANBasic.SetValue(PCANBasic.PCAN_NONEBUS, TPCANParameter.PCAN_LOG_LOCATION, strBuffer, (UInt32)strBuffer.Length);
if (result != TPCANStatus.PCAN_ERROR_OK)
{
// An error occurred, get a text describing the error and show it
//
PCANBasic.GetErrorText(result, 0, strMsg);
Console.WriteLine(strMsg.ToString());
}
else
Console.WriteLine("Log path was successfully set");
Dim result As TPCANStatus
Dim strMsg As System.Text.StringBuilder
Dim strBuffer As String
strMsg = New System.Text.StringBuilder(256)
' The path for the Log file is set.
' Note that this parameter is set using the
' default Channel (PCAN_NONEBUS)
'
strBuffer = "C:\Users\Admin\Desktop"
result = PCANBasic.SetValue(PCANBasic.PCAN_NONEBUS, TPCANParameter.PCAN_LOG_LOCATION, strBuffer, CType(strBuffer.Length, UInteger))
If result <> TPCANStatus.PCAN_ERROR_OK Then
' An error occurred, get a text describing the error and show it
'
PCANBasic.GetErrorText(result, 0, strMsg)
Console.WriteLine(strMsg.ToString())
Else
Console.WriteLine("Log path was successfully set")
End If
TPCANStatus result;
System::Text::StringBuilder^ strMsg;
String^ strBuffer;
strMsg = gcnew System::Text::StringBuilder(256);
// The path for the Log file is set.
// Note that this parameter is set using the
// default Channel (PCAN_NONEBUS)
//
strBuffer = "C:\\Users\\Admin\\Desktop";
result = PCANBasic::SetValue(PCANBasic::PCAN_NONEBUS, TPCANParameter::PCAN_LOG_LOCATION, strBuffer, strBuffer->Length);
if (result != TPCANStatus::PCAN_ERROR_OK)
{
// An error occurred, get a text describing the error and show it
//
PCANBasic::GetErrorText(result, 0, strMsg);
Console::WriteLine(strMsg->ToString());
}
else
Console::WriteLine("Log path was successfully set");