You are here: Forum Home → ANT Developers Forums → ANT General Questions → Thread
for (int deviceNumber=0; deviceNumber<12; deviceNumber++) {
printf("Looking usb device on port : %d...", deviceNumber);
// UCHAR nbDevice = pclSerialObject->GetNumberOfDevices();
bStatus = pclSerialObject->Init(USER_BAUDRATE_USB2, deviceNumber);
if (bStatus) //always return true even with wrong deviceNumber..
break;
}
——————————————————
Free Indoor Cycling Software - https://maximumtrainer.com
——————————————————
Free Indoor Cycling Software - https://maximumtrainer.com
///////////////////////////////////////////////////////////////////////
// Initializes and opens the object.
///////////////////////////////////////////////////////////////////////
//defines used by AutoInit
#define ANT_USB_STICK_PID 0x1004
#define ANT_USB_DEV_BOARD_PID 0x1006
#define ANT_USB_STICK_BAUD ((USHORT)50000)
#define ANT_DEFAULT_BAUD ((USHORT)57600)
BOOL DSISerialGeneric::AutoInit()
{
Close();
if (pclDevice)
delete pclDevice;
pclDevice = NULL;
ucDeviceNumber = 0xFF;
const ANTDeviceList clDeviceList = USBDeviceHandle::GetAvailableDevices(); //saves a copy of the list and all of the elements
if(clDeviceList.GetSize() == 0)
{
//When this is being polled repeatedly, as in the ANTFS host class, the USBReset calls to WinDevice Enable/Disable take a large amount if CPU, so we limit the
//reset here to only be called a maximum of once every 30s
time_t curTime = time(NULL);
if(curTime - lastUsbResetTime > 30)
{
lastUsbResetTime = curTime;
this->USBReset();
}
return FALSE;
}
//--- Custom code Added by blaisminator
if(clDeviceList.GetSize() > 0) {
/// Detect if we have busy ANT ke
}
USBDeviceHandle::CopyANTDevice(pclDevice, clDeviceList[0]);
ucDeviceNumber = 0; //initialize it to 0 for now (all devices that use autoinit will have a 0 device number) //TODO this devicenumber is useless because it can't be used to access the list again
switch (pclDevice->GetPid())
{
case ANT_USB_STICK_PID:
ulBaud = ANT_USB_STICK_BAUD;
break;
case ANT_USB_DEV_BOARD_PID:
default:
ulBaud = ANT_DEFAULT_BAUD;
break;
}
return TRUE;
}
——————————————————
Free Indoor Cycling Software - https://maximumtrainer.com