Stream Interface drivers access with Compact Framework

  • Thread starter Thread starter Fabrice MOUSSET
  • Start date Start date
F

Fabrice MOUSSET

Hi all,
I have developed some Windows CE 6.00 Stream Interface drivers for my
own BSP.
Some of those drivers are very basic, like LEDs or Switch drivers.

I also have developed a lite C# application (C# 2.0) to test my drivers
and I found strange access problem to my Switch driver.

I use FileStream class to read or write to my drivers. For write access
all work fine but for reading I always got an error.
After analyze, I see that the problem is that before reading data from
the driver, the Read() routine try to made a Seek() sequence which is
not supported by the driver!

Here is the code that I am using to read my driver:
public bool GetFrontSwitchState()
{
bool state;
using (FileStream switchFile = new FileStream("SWI1:", FileMode.Open,
FileAccess.Read, FileShare.Read))
{
state = switchFile.ReadByte() == (byte)1;
}
return state;
}

When I look at the "canSeek" property of FileStream object switchFile,
it says "True" but there is no Seek() routine in the Stream Driver !
Is there something wrong in my driver or is it a bug in the FileStream
Class ?

Thanks in advance for any help or suggestion.

Best regards

Fabrice
 
Neither. You driver doesn't need to support Seek if it doesn't use it. The
FileStream class is used for generic File Stream access. The problem is
that the two aren't completely compatible. You could add an implementation
for Seek (which would presumably do nothing) and that would probably get
past the immediate issue (though if you have any IOCTL's you still won't
have access to them) or you need to implement your managed code to call the
direct APIs instead of using the FileStream (which is what I always do).

The SmartDeviceFramework contains an abstract base StreamInterfaceDriver
class that encapsulates all of the API plumbing.

See these:
http://www.opennetcf.com/library/sdf/html/1e664b5d-cdc4-0c23-602b-d21a98eecaeb.htm
http://msdn.microsoft.com/en-us/library/aa446570.aspx

--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com
 
Many Chris for your answer,
I have added a Seek() routine to my driver.
This routine always return 0 and now the FileStream class works fine.

Best regards

Fabrice

Chris Tacke, eMVP a écrit :
 
You should still consider using Chris's implementation in the SDF. What
you're doing now doesn't allow you to use IOCTLs in your driver. Most
drivers of any complexity leverage the IOCTL interface because simply
reading/writing isn't enough.

--
Dean Ramsier - eMVP
BSQUARE Corporation


Many Chris for your answer,
I have added a Seek() routine to my driver.
This routine always return 0 and now the FileStream class works fine.

Best regards

Fabrice

Chris Tacke, eMVP a écrit :
 
Back
Top