Hi,
I'm trying to access the USB UART, which was published in the December 2001 edition of the magazine, from visuall C++.
I am only trying to turn a LED on and off to start with. I have wired the cathode to the 5V supply and the Anode to P1.3 on the microcontroller.
My code for writing to the USB device is:
LPOVERLAPPED gOverlapped = NULL;
HANDLE hgDrvrHnd;
LPCSTR sFileName = "\\.\\usbuart_0";
long lIn = 0;
long lOut;
long htemp, lTemp;
LPDWORD lSize = 0;
DWORD lOutSize = 0;
BOOL lInSize = 0;
LPSECURITY_ATTRIBUTES security;
lOut = 0;//(65536 * y + 1 *256 +21);
lOut=65536*256+21;
lIn = 65536 * 255 + 1 * 256 +21;
lInSize = 3;
lOutSize = 1;
hgDrvrHnd = CreateFile(sFileName, GENERIC_READ |
GENERIC_WRITE,
FILE_SHARE_READ |
FILE_SHARE_WRITE,
security,
OPEN_EXISTING, 0, 0);
lTemp = DeviceIoControl(hgDrvrHnd,
0x04,&lIn,4,
&lOut,sizeof(lOut),
lSize,gOverlapped);
htemp = CloseHandle(hgDrvrHnd);
Can someone please explain what I'm doing wrong.
Thanks
Andrew Ellis
