Reputation: 11
I have a project to communicate with a usb device using usb bus. The device has its own driver and a communication protokol Guid . In its guid there is this senetence :"After USB driver is installed any program can communicate with the device by using ‘CreateFile’, ‘ReadFile’ and ‘WriteFile’, common Windows system functions." So I followed the instructions and the Creatfile() function works very well. My problem is with Writefile()and ReadFile functions. It shows always this Error 3758100489 : In the guid book there is this note:All messages use Intel style byte ordering where fields larger than one byte are stored in memory so that the least significant part is in lowest address. So i tried to use functions to convert to littel Endien too I tried to use overlapped parameter in Creatfile() and Writefile() but still have the same problem. i tried to use many forms of message packet with help from the guid too
Can anyone help me ? thank you very much
P.s USB path is right 100%
Upvotes: 1
Views: 244
Reputation: 1881
Your error code in hex is 0xE0001009
. The USB device should be locked before you can perform the operation. I am not completely sure and can't test it, but I think you would need this function DeviceIoControl to lock the volume first.
In WriteFile documentation, it's mentioned
A write on a disk handle will succeed if one of the following conditions is true:
This article could help in making the call for locking.
Upvotes: 1
Reputation: 18593
Try to get more info about 3758100489
.
See Retrieving the Last-Error Code or try to build and run the following program which should show you a human readable description of error 3758100489
:
#include <windows.h>
#include <strsafe.h>
void main()
{
LPVOID lpMsgBuf;
LPVOID lpDisplayBuf;
//DWORD dw = GetLastError();
DWORD dw = 3758100489;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL );
// Display the error message and exit the process
lpDisplayBuf = (LPVOID)LocalAlloc(LMEM_ZEROINIT,
lstrlen((LPCTSTR)lpMsgBuf) );
StringCchPrintf((LPTSTR)lpDisplayBuf,
LocalSize(lpDisplayBuf) / sizeof(TCHAR),
TEXT("failed with error %d: %s"),
dw, lpMsgBuf);
MessageBox(NULL, (LPCTSTR)lpDisplayBuf, TEXT("Error"), MB_OK);
LocalFree(lpMsgBuf);
LocalFree(lpDisplayBuf);
}
Upvotes: 0