none
How to get the port number in driver function XXX_Open? RRS feed

  • Question

  • Hello,

    (Win CE 6.0 R3, VS 2005, Digi CC9M2443)

    I wrote a driver to create a PWM at a portpin, works fine. Now there are more portpins that can output a PWM and I want to control them with the same driver and have a fixed assignment hardware PWM channel 0 <-> PWM1:, PWM channel 1 <-> PWM2: and so on.

    To do this I think I need to know in drivers function PWM_Open the portname that was passed to CreateFile.  But there is no parameter for this (??)

    How to do it?

    Thank you for any help

     

    Martin

    Thursday, January 6, 2011 12:37 PM

All replies

  • Martin,

     

    Need more clear explanation. What i understood is that you need to pass port pin name to the driver to generate PWM ?

    You can pass such argument in various driver entry points such as WriteFile(),IoControl()

    The best is to use IoControl driver entry point and pass the argument as port pin no to the driver .

     

    Driver shall read the port pin no and generate PWM for the corresponding port whenever the IoControl code is called.

     

    Dont forget to synchronize  against multiple access of the device and register access.

     

    Hope this will help.

     

    In case of implementation issue write us.

     

    Misbah

    • Proposed as answer by Misbah Khan Friday, January 7, 2011 5:56 AM
    Thursday, January 6, 2011 1:03 PM
  • Put the information that is unique to each instance of the driver in the registry in the same key that you use to load the driver.  Then use OpenDeviceKey() to get a handle to the registry key.

    See: http://geekswithblogs.net/BruceEitman/archive/2008/08/07/windows-ce-stream-interface-driver-xxx_init.aspx


    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.
    www.Eurotech.com
    Thursday, January 6, 2011 1:28 PM
    Moderator
  • Reading your question again, the answer is that you can't do it in XXX_Open().  You could require the application to call DeviceIoControl() prior to reading and writing to change the pin from a default.  You will then need a set of context data for each open.
    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.
    www.Eurotech.com
    Thursday, January 6, 2011 1:32 PM
    Moderator
  • Also see the serial port MDD driver as an example to handle multiple COM ports. Here is the driver path

    \WINCE600\PUBLIC\COMMON\OAK\DRIVERS\SERIAL\COM_MDD2\MDD.c . Search for COM_Init(), COM_Open() etc..

    This driver is a typical example for Bruce explanations.


    Vinoth.R http://vinoth-vinothblog.blogspot.com http://www.e-consystems.com
    Thursday, January 6, 2011 2:34 PM