- 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?