USBDriverStatus() problem

Support for the Milan Intelligent interface, sold by Money Controls as the Paylink USB unit and for the earlier PCI card version.

Moderators: aardvark, davebush, Admin

Post Reply
jq
Posts: 19
Joined: Fri Jul 11, 2008 11:27 am

USBDriverStatus() problem

Post by jq »

Hi all,
I recently added a bit of code before a call to USBDriverStatus() to check if the driver window was open (and therefore the driver running). If the driver isn't running the code attempts to run the driver (see code below).

I then check again see if it is running and then i make a call to USBDriverStatus() and check everything is OK with the driver, but if i've just launched the driver from within code, USBDriverStatus() allways returns NOT_USB. I've changed the code to ignore this and everything works OK (i am able to intialise the rest of the hardware, but the NOT_USB return is obviously wrong (there are no PCI cards in the machine for a start). I can't see anything that is incorrect within my code:

Code: Select all

if(FindWindowEx (NULL,NULL,NULL,"AES Windowed USB Driver") == NULL)
{	
	CString driverPath;
	char tmpPath[513];
	tmpPath[0] = 0;
	::_getcwd(tmpPath,512);
	
	if(tmpPath[strlen(tmpPath)] != '\\')
	{
		strcat(tmpPath,"\\");
	}

	driverPath = CString(tmpPath);
	strcat(tmpPath,"AESWDriver.exe");
	ShellExecute(NULL,"open",tmpPath,NULL,driverPath,SW_SHOWMINNOACTIVE);
	Sleep (700); //give the driver a chance to start (normally takes 200 - 300 ms)
}

if(FindWindowEx (NULL,NULL,NULL,"AES Windowed USB Driver") == NULL)
{
	retVal = MHE_USB_DRIVER_NOT_RUNNING;
	return retVal;
}

switch (USBDriverStatus())
{
	case STANDARD_DRIVER:
		retVal = MHE_OK;
		break;
	case NOT_USB:
		this->lastError = CString("FATAL ERROR, no USB paylink card detected!");
		retVal = MHE_USB_DRIVER_FATAL;
		break;
	case USB_IDLE:
		this->lastError = CString("ERROR, USB driver not running, please locate the driver (\"AES Windowed USB Driver\"), place it in the start->programs->startup menu and restart the machine.");
		retVal = MHE_USB_DRIVER_NOT_RUNNING;
		break;
	case FLASH_LOADER:
	case MANUFACTURING_TEST:
		this->lastError = CString("ERROR, paylink card link is busy, please retry later. If you continue to get this message, please restart the machine and try again.");
		retVal = MHE_USB_DRIVER_BUSY;
		break;		
	case DRIVER_RESTART:
		this->lastError = CString("ERROR, the paylink driver is restarting or about to exit. Please ensure it is running and retry.");
		retVal = MHE_USB_DRIVER_RESTARTING;
		break;
	case USB_ERROR:
		this->lastError = CString("FATAL ERROR, there is a problem with the low-level USB driver.");
		retVal = MHE_USB_DRIVER_LOW_LEVEL;
		break;
	default:
		this->lastError = CString("UNKOWN ERROR, an unknown error was encountered checking the status of the USB driver");
		retVal = MHE_USB_DRIVER_UNKNOWN;
		break;
}

This isn't a critical issue as i can just treat the NOT_USB as everything is ok, i know for a fact there will never be a PCI card in this machine, but i would still like to make the software differentiate between everything is OK and NOT_USB.
davebush
Posts: 490
Joined: Fri Oct 22, 2004 12:20 pm

Post by davebush »

The USBDriverStatus() is intended to check the status on a "running" system.

The system only starts "running" following a successful OpenMHE (which is where the link to the server is made.)

if this link hasn't been made, then the USBDriverStatus() function can't see the server and returns NOT_USB.
Aardvark software developer. Please put all communication on the problem through the board for the benefit of others.
Post Reply