15,914,225 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by pravin29 (Top 9 by date)
pravin29
4-Apr-12 2:31am
View
Right now i can receive single byte by calling ReadFile.
pravin29
4-Apr-12 1:59am
View
We are using Endpoint OUT - 81 and IN - 2 (Bulk USB transfer)
pravin29
4-Apr-12 1:27am
View
1. The event being signaled alerts that data has arrived. You can create your own DataReceived event.
>> Let's assume device sent 1 byte of data on USB port. Now how could application software signaled this event. In VC++, For serial, communication there is EV_RXCHAR event. When this event signaled then we call ReadFile. In C# direct event provided from Serial class.
Serial _serialVP = new SerialPort("COM7");
_serialVP.BaudRate = 115200;
_serialVP.Parity = Parity.None;
_serialVP.StopBits = StopBits.One;
_serialVP.DataBits = 8;
_serialVP.Handshake = Handshake.None;
_serialVP.DataReceived += new SerialDataReceivedEventHandler(DataReceviedHandler);
private void DataReceviedHandler(
object sender,
SerialDataReceivedEventArgs e)
{
SerialPort sp = (SerialPort)sender;
int inData = sp.ReadByte();
}
This example is for serial. i wish same implementation for USB.
pravin29
3-Apr-12 10:05am
View
Thank you for your reply.
I did this. Here is code -
Collapse | Copy Code
g_hw_USBWrite = CreateFile (UsbWritePipe,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, // no SECURITY_ATTRIBUTES structure
OPEN_EXISTING, // No special create flags
0, // No special attributes
NULL); // No template file
hEventObject = CreateEvent((LPSECURITY_ATTRIBUTES)NULL,FALSE,TRUE,"");
HIDOverlapped.hEvent = hEventObject;
HIDOverlapped.Offset = 0;
HIDOverlapped.OffsetHigh = 0;
InputReportBuffer[0] = 0;
int s_i_NoOfBytes = 1;
Result = ReadFile(g_hw_USBRead,InputReportBuffer,s_i_NoOfBytes,&BytesRead,(LPOVERLAPPED) &HIDOverlapped);
Result = WaitForSingleObject(hEventObject,1000);
switch (Result)
{
case WAIT_OBJECT_0:
{
// Success;
// Use the report data;
break;
}
case WAIT_TIMEOUT:
{
// Timeout error;
//Cancel the read operation.
CancelIo(g_hw_USBRead);
break;
}
default:
{
// Undefined error;
//Cancel the read operation.
CancelIo(g_hw_USBRead);
break;
}
}
Actually problem is, application software doesn't know how much data (or bytes) to receive from device. In overlapped IO there is necessity to call ReadFile first and then wait for signaling. I just want DataReceived event similar to serial (which invoke by OS)
pravin29
12-Jan-11 0:03am
View
Everything works in ideal condition.
pravin29
11-Jan-11 23:58pm
View
Right now just consider s/w has no role during noise test. After finishing noise test i tried to communicate with device and device gets connected. Send the data but could not receive. So will software or driver need some care?
pravin29
20-Dec-10 6:14am
View
Thanks for your prompt reply
From my observation Even though we kill the thread, the "ReadFile" API does not terminate for synchronous communication and Killthread is not recommended to use.
pravin29
20-Dec-10 4:00am
View
for XP i did not find any suitable method for cancel pending IO operation for synchronous communication
pravin29
20-Dec-10 3:57am
View
This is exactly my query "How to implement timeout for synchronous communication (Specially in case of USB communication)"?.
In case of serial communication there is DCB structure and we can set ReadTimeout. But i could not find any method for USB communication.
Show More