Hello,
You can use the underlying PCANBasic and its functions for this.
I'd recommend to download the PCANbasic package using the following link:
This way we are both refeering to the same dcomuentation and examples.
1)
"PCAN_DEVICE_ID" is a hardware-parameter, it can be GET/SET using the
CAN_GetValue/CAN_SetValue functions. More information on this parameter can be found in the PCANBasic Parameter docuemntation on page 11.
"PCAN_ATTACHED_CHANNELS" is also a parameter, which can be get using the CAN-GetValue parameter. This parameter is used to get information about all existing PCAN channels on a system in a single call, regardless of their current availability.
The PCANBasic example application showcases its usage, it is
used to get information for all channels currently present, furthermore each channel
is checked for availability and FD-capability:
Code: Select all
// Includes all no-Plug&Play Handles
for (int i = 0; i < (sizeof(m_NonPnPHandles) /sizeof(TPCANHandle)) ; i++)
cbbChannel.AddString(FormatChannelName(m_NonPnPHandles[i]));
stsResult = m_objPCANBasic->GetValue(PCAN_NONEBUS, PCAN_ATTACHED_CHANNELS_COUNT, (void*)&iChannelsCount, sizeof(iChannelsCount));
if (stsResult == PCAN_ERROR_OK)
{
info = new TPCANChannelInformation[iChannelsCount];
stsResult = m_objPCANBasic->GetValue(PCAN_NONEBUS, PCAN_ATTACHED_CHANNELS, (void*)info, iChannelsCount * sizeof(TPCANChannelInformation));
if (stsResult == PCAN_ERROR_OK)
// Include only connectable channels
//
for (int i=0; i < (int)iChannelsCount; i++)
if (info[i].channel_condition & PCAN_CHANNEL_AVAILABLE)
{
bIsFD = info[i].device_features & FEATURE_FD_CAPABLE;
cbbChannel.AddString(FormatChannelName(info[i].channel_handle, bIsFD));
}
delete [] info;-
}
CAN_SetValue and CAN_GetValue
The PCANBasic example has plenty of examples for setting and getting parameters:
Here an example for setting "PCAN_CHANNEL_IDENTIFYING":
Code: Select all
iBuffer = bActivate ? PCAN_PARAMETER_ON : PCAN_PARAMETER_OFF;
stsResult = m_objPCANBasic->SetValue(m_PcanHandle, PCAN_CHANNEL_IDENTIFYING, (void*)&iBuffer, sizeof(iBuffer));
if(stsResult == PCAN_ERROR_OK)
{
info.Format("The procedure for channel identification was successfully %s", bActivate ? "activated" : "deactivated");
IncludeTextMessage(info);
}
break;
as well as gettting the status of the parameter:
Code: Select all
stsResult = m_objPCANBasic->GetValue(m_PcanHandle, PCAN_CHANNEL_IDENTIFYING, (void*)&iBuffer, sizeof(iBuffer));
if(stsResult == PCAN_ERROR_OK)
{
info.Format("The identification procedure of the selected channel is %s", (iBuffer == PCAN_PARAMETER_ON) ? "ON" : "OFF");
IncludeTextMessage(info);
}
break;
Please check the Example-Application, PCANBasic documentation and PCANBasic Parameter docuemntation for reference.
2)
You could for example use the Device-ID to identify a device in software, for a phyiscal
identification you could use the aformentioned parameter "PCAN_CHANNEL_IDENTIFYING" to
have the LED of the device blink.
The former could be handled with If-conditions,
,for example using "PCAN_ATTACHED_CHANNELS" which also returns the device-id,
to identify a specific device and use it.
3)
You can use PCAN-UDS handles as well to get the
CHANNEL_Condition" parameter.
4)
See the aformentioned Example for "PCAN_ATTACHED_CHANNELS", this is basically what the shown code will do. If you check the example you'll see that the returned info will be added as a string to a GUI element. The same could also be done in a console context.
For further questions feel free to contact us again.
Best Regards
Marvin