Ad-Hoc network always created in the "internal" card
Posted: Fri 8. Dec 2017, 13:43
I am using the PCAN-Devloper 4 dll in an flasher application. There are no CAN networks prepared. So, my proposed workflow was:
All of the above succeeds without error. But first, an already existing network of this name is not removed from the driver. And second, the created network is attached to the 'intern' PCAN USB and not the real one.
Different values of hwHandle give the same results.
Any suggestions on what I am doing wrong here?
- connect the client
- see if there was already a network with my settings?
- remove this network
- create a network with my settings to the device I want
- connect to this network
Code: Select all
// create client
checkResult(CAN_RegisterClient(pcan_usb, "TCanCardPeak4", 0, &clientHandle));
// check to see if we already have a network configured
res = CAN_ConnectToNet(pcan_usb, clientHandle, (LPSTR)&netName[0], &netHandle); // netName is 'TCanCardPeak4Net@256'
if (CAN_ERR_OK == res)
{
// if yes, disconnect and remove this network
res = CAN_DisconnectFromNet(pcan_usb, clientHandle, netHandle);
res = CAN_RemoveNet(pcan_usb, netHandle);
}
// try to register a network for our pcan_usb hardware
HCANHW hwHandle = 1; // we want the first device
checkResult(CAN_RegisterNet(pcan_usb, 0, (LPCSTR)&netName[0], hwHandle, (can_any_bitrate_t *)&bitrate));
Different values of hwHandle give the same results.
Any suggestions on what I am doing wrong here?