
Signature
Bruce Eitman (eMVP)
Senior Engineer
Bruce.Eitman AT EuroTech DOT com
My BLOG http://geekswithblogs.net/bruceeitman
EuroTech Inc.
www.EuroTech.com
Bruce Eitman [eMVP] a écrit :
> What does crash mean to you?
I suppose, because i can't power up the device after a power down, but
it is more complicated i think than my knowledges ...
> Is the declare of "value" and initialize it to 1 actually the one
> instruction? I suspect that that code gets optimized out, so I doubt it.
sorry, it seems to work with this simple instruction (i forgot to reset
the device with this new driver)
> What you cannot do is call system APIs, like CreateFile() and CloseHandle().
> You can output a DEBUGMSG.
so i can't close the COM port in COM_PowerDown function (inside
COM_Close function there's of course a CloseHandle API) ?
Michel Verhagen (eMVP) - 17 Jul 2008 14:23 GMT
And you can power cycle the device without problems without this COM
driver right?
> so i can't close the COM port in COM_PowerDown function (inside
> COM_Close function there's of course a CloseHandle API) ?
Why is there "of course" a CloseHandle API? CloseHandle is called from
an application to close the handle to the driver, *not* from the driver
itself (at least not on the driver "handle").
Usually the "handle" inside the driver is a block of memory containing
instance data for the driver. Closing the "handle" in COM_PowerDown does
not make sense from a driver point of view. What you should do in
COM_PowerDown is put your serial HW in the lowest possible powerstate,
and get it out of this powerstate at COM_PowerUp.
But... I will repeat myself again: You should not be using the
PowerUp/Down functions anymore. Instead implement the IOCTL_POWER
ioctls. They are much more flexible and allow multiple powerlevels. You
can also call system API's from the IOCTL handling code.
Good luck,
Michel Verhagen, eMVP
Check out my blog: http://GuruCE.com/blog
GuruCE Ltd.
Microsoft Embedded Partner
http://GuruCE.com
Consultancy, training and development services.
> Bruce Eitman [eMVP] a écrit :
>> What does crash mean to you?
[quoted text clipped - 12 lines]
> so i can't close the COM port in COM_PowerDown function (inside
> COM_Close function there's of course a CloseHandle API) ?
Bruce Eitman [eMVP] - 17 Jul 2008 15:11 GMT
Michel, notice this is a virtual com driver, so it is doing CreateFile and
CloseHandle, that makes sense, but **of course** not in the power
functions.
Kirk: Since Michel has said it twice, and becuase it is new to you, I will
repeat if you need to call those APIs you should use the power manager
IOCTLs instead. But really if your physical com driver works well you
shouldn't need to do anything in response to the power functions.

Signature
Bruce Eitman (eMVP)
Senior Engineer
Bruce.Eitman AT EuroTech DOT com
My BLOG http://geekswithblogs.net/bruceeitman
EuroTech Inc.
www.EuroTech.com
> And you can power cycle the device without problems without this COM
> driver right?
[quoted text clipped - 44 lines]
>> so i can't close the COM port in COM_PowerDown function (inside COM_Close
>> function there's of course a CloseHandle API) ?