The Elektor Forum will close. See also this link. From Friday March 1st it is no longer possible to log in to the forum. However, the content of the forum will remain visible until the end of March. As of April 1st the forum will definitely go off the air.

USB UART DEC 2001

The topic on number crunching

Postby Guest » Wed May 30, 2007 12:00 am

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
Guest
 

Return to Microcontrollers & Embedded

Who is online

Users browsing this forum: No registered users and 2 guests

cron