You are here: Forum Home → ANT Developers Forums → ANT General Questions → Thread
//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;
}
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;
}
//!!Just here temporarily until we get ANTDeviceList to do it.
const ANTDeviceList USBDeviceHandle::GetAvailableDevices(ULONG ulDeviceTypeField_)
{
ANTDeviceList clDeviceList;
if( (ulDeviceTypeField_ & DeviceType::SI_LABS) != 0)
{
const USBDeviceListSI clDeviceSIList = USBDeviceHandleSI::GetAvailableDevices(); //!!There is a list copy here!
clDeviceList.Add(clDeviceSIList.GetSubList(SiDeviceMatch) );
}
if( (ulDeviceTypeField_ & DeviceType::LIBUSB) != 0)
{
const USBDeviceListLibusb clDeviceLibusbList = USBDeviceHandleLibusb::GetAvailableDevices(); //!!There is a list copy here!
clDeviceList.Add(clDeviceLibusbList.GetSubList(LibusbDeviceMatch) );
}
return clDeviceList;
}
——————————————————
Free Indoor Cycling Software - https://maximumtrainer.com