Xmega32a4U interfacing to PC using ATUSBHID.DLL

1 post / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi, we are just trying to finish off a project which uses the XMega32A4U. On the PC side, we are using a custom Delphi program which accesses the USB with the ATUSBHID.DLL using the functions below:

function findHidDevice(VendorID,ProductID: LongWord ): Boolean; STDCALL; external LIBUSB_DLL_NAME  name 'findHidDevice';
procedure  openDevice STDCALL; external LIBUSB_DLL_NAME  name 'openDevice';
procedure  closeDevice STDCALL; external LIBUSB_DLL_NAME  name 'closeDevice';
function  writeData(Buf : PChar ): Boolean; STDCALL; external LIBUSB_DLL_NAME  name 'writeData';
function  readData(Buf : PChar ): Boolean; STDCALL; external LIBUSB_DLL_NAME  name 'readData';
function  hidRegisterDeviceNotification(hWnd : THandle ): Integer; STDCALL; external LIBUSB_DLL_NAME  name 'hidRegisterDeviceNotification';
procedure  hidUnregisterDeviceNotification(hWnd : THandle ); STDCALL; external LIBUSB_DLL_NAME  name 'hidUnregisterDeviceNotification';
function  isMyDeviceNotification(dwData:longword): Integer; STDCALL; external LIBUSB_DLL_NAME  name 'isMyDeviceNotification';
function  setFeature(Buf : PChar ): Boolean; STDCALL; external LIBUSB_DLL_NAME  name 'setFeature';
function  getFeatureReportLength: Integer; STDCALL; external LIBUSB_DLL_NAME  name 'getFeatureReportLength';
function  getOutputReportLength: Integer; STDCALL; external LIBUSB_DLL_NAME  name 'getOutputReportLength';
function  getInputReportLength: Integer; STDCALL; external LIBUSB_DLL_NAME  name 'getInputReportLength';

Everything is fine at the start  - the program starts, connects to USB, the USB cable is pulled out, reconnected OK but then on the second time the USB cable is pulled out we keep getting these Error code is 6 errors (show below). When the Error code is 6 happens, everything runs slow like around 1% of normal speed or slower and buttons on the program cannot be clicked (like the Exit button).

 

Debug Output:
Error code is 6

Process Epilator.exe (10808)

 

I found this thread which outlines that caling the closeDevice will fix this issue.

https://forums.ni.com/t5/Instrum...

 

We have tried calling closeDevice, and have added a 5 second delay but closeDevice does not seem to do anything. Any help would be much appreciated,

 

Below are the functions found by using DLL Export Viewer.

closeDevice	0x1000198d	0x0000198d	2 (0x2)	AtUsbHid.dll	C:\_projects\Elf\Software\Epilator_old\Output\AtUsbHid.dll	Exported Function
findHidDevice	0x100011cf	0x000011cf	3 (0x3)	AtUsbHid.dll	C:\_projects\Elf\Software\Epilator_old\Output\AtUsbHid.dll	Exported Function
getch	0x10001eb0	0x00001eb0	7 (0x7)	AtUsbHid.dll	C:\_projects\Elf\Software\Epilator_old\Output\AtUsbHid.dll	Exported Function
getFeatureReportLength	0x10002103	0x00002103	4 (0x4)	AtUsbHid.dll	C:\_projects\Elf\Software\Epilator_old\Output\AtUsbHid.dll	Exported Function
getInputReportLength	0x100020f3	0x000020f3	5 (0x5)	AtUsbHid.dll	C:\_projects\Elf\Software\Epilator_old\Output\AtUsbHid.dll	Exported Function
getOutputReportLength	0x100020e3	0x000020e3	6 (0x6)	AtUsbHid.dll	C:\_projects\Elf\Software\Epilator_old\Output\AtUsbHid.dll	Exported Function
hidRegisterDeviceNotification	0x10001fa0	0x00001fa0	8 (0x8)	AtUsbHid.dll	C:\_projects\Elf\Software\Epilator_old\Output\AtUsbHid.dll	Exported Function
hidUnregisterDeviceNotification	0x10001f8f	0x00001f8f	9 (0x9)	AtUsbHid.dll	C:\_projects\Elf\Software\Epilator_old\Output\AtUsbHid.dll	Exported Function
isMyDeviceNotification	0x10001ffd	0x00001ffd	10 (0xa)	AtUsbHid.dll	C:\_projects\Elf\Software\Epilator_old\Output\AtUsbHid.dll	Exported Function
openDevice	0x10001000	0x00001000	11 (0xb)	AtUsbHid.dll	C:\_projects\Elf\Software\Epilator_old\Output\AtUsbHid.dll	Exported Function
putch	0x10001e62	0x00001e62	12 (0xc)	AtUsbHid.dll	C:\_projects\Elf\Software\Epilator_old\Output\AtUsbHid.dll	Exported Function
readContinuous	0x10001ce5	0x00001ce5	13 (0xd)	AtUsbHid.dll	C:\_projects\Elf\Software\Epilator_old\Output\AtUsbHid.dll	Exported Function
readData	0x10001d1f	0x00001d1f	14 (0xe)	AtUsbHid.dll	C:\_projects\Elf\Software\Epilator_old\Output\AtUsbHid.dll	Exported Function
readStandard	0x10001c13	0x00001c13	15 (0xf)	AtUsbHid.dll	C:\_projects\Elf\Software\Epilator_old\Output\AtUsbHid.dll	Exported Function
setFeature	0x1000204d	0x0000204d	16 (0x10)	AtUsbHid.dll	C:\_projects\Elf\Software\Epilator_old\Output\AtUsbHid.dll	Exported Function
setReportContinuous	0x10001ae7	0x00001ae7	17 (0x11)	AtUsbHid.dll	C:\_projects\Elf\Software\Epilator_old\Output\AtUsbHid.dll	Exported Function
setTxPeriod	0x10001f63	0x00001f63	18 (0x12)	AtUsbHid.dll	C:\_projects\Elf\Software\Epilator_old\Output\AtUsbHid.dll	Exported Function
updateFeatureBytes	0x10001ded	0x00001ded	1 (0x1)	AtUsbHid.dll	C:\_projects\Elf\Software\Epilator_old\Output\AtUsbHid.dll	Exported Function
writeContinuous	0x10001d2f	0x00001d2f	19 (0x13)	AtUsbHid.dll	C:\_projects\Elf\Software\Epilator_old\Output\AtUsbHid.dll	Exported Function
writeData	0x10001ddd	0x00001ddd	20 (0x14)	AtUsbHid.dll	C:\_projects\Elf\Software\Epilator_old\Output\AtUsbHid.dll	Exported Function
writeStandard	0x10001b1d	0x00001b1d	21 (0x15)	AtUsbHid.dll	C:\_projects\Elf\Software\Epilator_old\Output\AtUsbHid.dll	Exported Function

 

Electronic System Design
http://www.esdn.com.au

Last Edited: Mon. Apr 9, 2018 - 11:42 PM