DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Fri, 17 Aug 2007 04:07:40 +0300,    posted on: microsoft.public.dotnet.framework.compactframework        back       

Thread Index
  1    Empi
          2    ctacke/ ctacke[at]opennetcf[dot]com
          3    Dick Grier dick_grierNOSPAM@.msn.com


ReadFile, DCB and OVERLAPPED   
Hi,

Several questions regarding serial I/O.

1) I got confused regarding the DCB flags.
    On msdn, these flags (fBinary; fParity; fOutxCtsFlowfErrorChar etc) are 
defined as 32 bitsvariable,
    while on MSpress book MS Compact Framework, I find a DCB on which each 
flag gets an int (DWORD).
    What does coredll.dll really expect?
    Did the compramise in order to accept both structures (using the dcb 
length) in order to help c# ? (no trivial support for defining bit flags).

2) How can I pass null to ReadFile when OVERLAPPED is not really used?
    I've found several ReadFile samples that simply define an OVERLAPPED, 
passing a ref to it without setting anything in it.
    Can't I kust pass a null? (trying to do so gave a compiler error 
regarding this parameter (fifth)).

Thanks.
Date:Fri, 17 Aug 2007 04:07:40 +0300   Author:  

Re: ReadFile, DCB and OVERLAPPED   

> 1) I got confused regarding the DCB flags.
>    On msdn, these flags (fBinary; fParity; fOutxCtsFlowfErrorChar etc) are 
> defined as 32 bitsvariable,
>    while on MSpress book MS Compact Framework, I find a DCB on which each 
> flag gets an int (DWORD).
>    What does coredll.dll really expect?


The docs are clear that each is a bit in a 32-bit DWORD, so that is what 
must go into the API.


>    Did the compramise in order to accept both structures (using the dcb 
> length) in order to help c# ? (no trivial support for defining bit flags).


I don't see a compromise (thout I'm also not looking at whatever book you 
have).  Managed code can use bit fields in the BitVector32 class, so that's 
what I'd likely choose for this, but I can't say what they did use.  The 
other option would be boolean accessors that all hit the same 32-bit (uint 
or int) value at different offsets.


> 2) How can I pass null to ReadFile when OVERLAPPED is not really used?
>    I've found several ReadFile samples that simply define an OVERLAPPED, 
> passing a ref to it without setting anything in it.


Define the P/Invoke to take an IntPtr and pass it IntPtr.Zero or as a 
int/uint and pass it 0.  NULL in native code is #defined as 0.


>    Can't I kust pass a null? (trying to do so gave a compiler error 
> regarding this parameter (fifth)).


No.  Managed code has a different definition of null than native.  They are 
not equivalent.


-- 

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com
Date:Thu, 16 Aug 2007 20:24:18 -0500   Author:  

Re: ReadFile, DCB and OVERLAPPED   
To add to what Chris said, you can find example code on www.opennetcf.org, 
or (also) in my book.  The Compact Framework 2 (VS 2005) has a built-in 
SerialPort object (System.IO.Ports), so unless you are using CF1, you 
probably should stick with it.

Dick

-- 
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth 
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March 
2006.
See www.hardandsoftware.net for details and contact information.
Date:Fri, 17 Aug 2007 10:18:04 -0600   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us