Windows Phone Thoughts - Daily News, Views, Rants and Raves

Check out the hottest Windows Mobile devices at our Expansys store!


Digital Home Thoughts

Loading feed...

Laptop Thoughts

Loading feed...

Android Thoughts

Loading feed...




Go Back   Thoughts Media Forums > WINDOWS PHONE THOUGHTS > Windows Phone Developer

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 06-24-2007, 02:12 PM
Nazgul
Neophyte
Join Date: Jun 2007
Posts: 2
Default USB and ReadFile

Hello,
I have recently acquired a Loox N560 with Windows Mobile 5, integral USB host and installed Ratoc USB host driver and Mass storage driver,
in order to develop a program that connects' to an embedded device through USB. The device registers itself as mass storage and handles command communication through a pipe file (text file).
This settings worked well for a similar program written for PC - thepipe file was opened using CreateFile with FILE_FLAG_NO_BUFFERING and FILE_FLAG_WRITE_THROUGH attributes, and sector aligned blocks werewritten and read using WriteFile and ReadFile, respectively.
I'm developing the program using C++/MFC.
Trying to implement to same thing in Windows Mobile 5, lead to some unfortunate results.
The CreateFile and WriteFile seems to work well; ReadFile does not fail, but returns invalid data (all zeros).
The USB driver implemented in the device maintains that while WriteFile and CreateFile does cause the OS
to send a WRITE request through the USB host and after that the data is pushed to the OUT FIFO in the device,
the ReadFile operation does not seem to cause the OS to send a READ request and thus does not receive any
viable data through the pipe from the device.
As the pipe is used to handle commands between the PDA and the device, operation as reading a parameter goes
like this - Allocation of a aligned data packet specifying the desired parameter, 'WriteFile'ing the packet through
the pipe, and 'ReadFile'ing the result. As I metioned, the WriteFile part seems always to work while the ReadFile does not.
It seems as if the OS buffers/caches the file contents the first time it is used and so does not seem to inquire the
device through the USB afterwards, despite the fact that the handle was created with the seemingly appropriate flags.
Been trying to use IOControl instead of ReadFile/WriteFile, but could not find anywhere 'diskio.h' needed for the
IOCTL_DISK_WRITE and IOCTL_DISK_READ definitions.
Does anybody has any idea what can be the problem or has encountered a similar one?
Thanks.
 
Reply With Quote
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:21 AM.