When you call KernelLibIoControl with the correct parameters what does it
return??
The document indicates that it returns a boolean - but the code I have seen
used returns a handle - I have than found code that allows us to
waitForSingle on this handle for when the WatchDog is actuall triggered. Is
someone able to explain if this is correct or if I have it completly wrong.
In addition to this I have noticed that the action that you are taking with
calling KernelLibIoControl is controlled by the second last parameter call
nOutBufSize. It is in this parameter that you pass in if we are starting the
watchDog, refreshing it etc.
Some of the Code
DECLARATION:
Private Declare Function KernelLibIoControl Lib "coredll.dll" (ByVal hLib As
IntPtr, _
ByVal dwIoControlCode As UInteger, _
ByRef lpInBuf As WDAPIStruct, _
ByVal nInBufSize As UInteger, _
ByVal lpOutBuf As IntPtr, _
ByVal nOutBufSize As UInteger, _
ByVal lpBytesReturned As IntPtr) As IntPtr
CREATING THE WATCH DOG - Notice the WDAPI_START
hWatchDog = KernelLibIoControl(New IntPtr(KMOD_CORE),
IOCTL_KLIB_WDOGAPI, wdas, _
CType(Marshal.SizeOf(wdas), UInteger), IntPtr.Zero,
WDAPI_START, IntPtr.Zero)
Is the hWatchDog actually a handle or a boolean True false indicating sucess.
If it is a handle can I than wait on this handle as in following
waitThread = New Threading.Thread(AddressOf WaitThreadStart)
waitThread.Start()
Private Shared Sub WaitThreadStart()
Dim Res As Integer = WaitForSingleObject(hWatchDog, INFINITE)
End Function
Thanks for your help
--
matthew
--
matthew
--
Luca Calligaris (MVP-Windows Embedded)
http://geekswithblogs.net/WindowsEmbeddedAnnotations
l.calliga...@eurotech.it.nospam
www.eurotech.it
"matvdl" <mat...@discussions.microsoft.com> ha scritto nel messaggio
news:B35377AC-C199-4A67...@microsoft.com...
I have reviewed my code and this function does returns a Handle - and to
control the Watchdog you do pass your instructions into the second last
parameter that is meant to be nOutBufSize.
Unless I have got something very wrong - this makes understanding code very
very difficult - it appears that the function has been used in an entirely
different way to how it was intended to be used.
Interested to here from people if this is correct.
--
matthew
In your case, your OEM has decided to use KernelLibIoControl, and it
seems from what you say that it is rather unconventional in returning a
handle to something. Nobody but the OEM can say what use you can make of
the handle, unfortunately.
Some OEM's implement their own watchdog control via a DLL of their own,
especially if they are using an "external" (to the microcontroller)
hardware watchdog.
Some OEM's *may* even implement the official SetWatchDogTimer etc API to
which Luca referred you. But I've got two boards from different OEM's
on my bench right now which don't (though they return valid handles etc)!
Unfortunately only your OEM is likely to be of much help, unless you
have the relevant BSP source code .
Tony
http://geekswithblogs.net/WindowsEmbeddedAnnotations/Default.aspx
Apologies if I misled anyone! And thanks to Luca for his blog article -
it certainly helped me fix mine!
Tony
--
Luca Calligaris (MVP-Windows Embedded)
http://geekswithblogs.net/WindowsEmbeddedAnnotations
l.calliga...@eurotech.it.nospam
www.eurotech.it
"Tony Hedge" <tonyatbenthicsciencesdotcodotuk> ha scritto nel messaggio
news:O3iin77p...@TK2MSFTNGP06.phx.gbl...
I am new to C++ and much of what I see can be confusing - I hope that this
situation is unusual because I found trying to understand it very difficult.
A few questions:
The KernelLibIoControl function is defined in Microsoft literature as
returning as a boolean - in vb.net if something is defined as boolean - it
returns a boolean - is C++ different - obviously what something is defined as
returning is not set in stone when using C++.
Also - this applies with what is passed in to a function - something that is
defined as an nOutBufSize has been used as something completely different??
I spent a few hours for looking for anything that pointed to how functions
defined as boolean can return a handle - couldn't find anything.
Also
what is a OAL
Another questions - the reason that the KernelLibIoControl is used is
because the calls that it makes (CreateWatchDogTimer in the background) are
protected within the kernel or similar - therefore I would not be able to
call CreateWatchDogTimer from my .net app - is this correct?
Hopefully I don't sound too stupid - but just trying to understand.
Thanks very much for your help and input so far - it has been great.
Matthew
--
matthew
I am new to C++ and much of what I see can be confusing - I hope that this
situation is unusual because I found trying to understand it very difficult.
A few questions:
The KernelLibIoControl function is defined in Microsoft literature as
returning as a boolean - in vb.net if something is defined as boolean - it
returns a boolean - is C++ different - obviously what something is defined as
returning is not set in stone when using C++.
Also - this applies with what is passed in to a function - something that is
defined as an nOutBufSize has been used as something completely different??
I spent a few hours for looking for anything that pointed to how functions
defined as boolean can return a handle - couldn't find anything.
Also
what is a OAL
Another questions - the reason that the KernelLibIoControl is used is
because the calls that it makes (CreateWatchDogTimer in the background) are
protected within the kernel or similar - therefore I would not be able to
call CreateWatchDogTimer from my .net app - is this correct?
Hopefully I don't sound too stupid - but just trying to understand.
Thanks very much for your help and input so far - it has been great.
--
matthew
No, it returns a BOOL, which is defined as 4-bytes. In managed code it's an
int. It should only be declared as a bool if you decorate it with a
MarshalAs attribute (which is actully how you should define it). What it
returns *is* set in stone. It's a 4-byte value. Since it's a BOOL, it
should be either 0 or non-zero equating to false or true.
> Also - this applies with what is passed in to a function - something that
> is
> defined as an nOutBufSize has been used as something completely
> different??
No. nOutBufSize is a DWORD, which is a 4-byte unsigned number. Since the
high bit is really unlikely to be used, it is also an int.
> I spent a few hours for looking for anything that pointed to how functions
> defined as boolean can return a handle - couldn't find anything.
A HANDLE is a 4-byte number, just like a BOOL, so there's nothing that says
you *can't* return a HANDLE (or any other 4-byte thing) but it's absolutely,
positively wrong for whoever implemented that specific IOCTL to be using it
that way. If they wanted to return a handle, that's what the out buffer
parameter is for.
> what is a OAL
OEM Adaptation Layer. Analogous to the HAL on a PC.
> Another questions - the reason that the KernelLibIoControl is used is
> because the calls that it makes (CreateWatchDogTimer in the background)
> are
> protected within the kernel or similar - therefore I would not be able to
> call CreateWatchDogTimer from my .net app - is this correct?
You shouldn't be calling KernelLibIoControl from an app *period*. If you
need to make a call into the kernel, it should be with KernelIoControl (note
the lack of 'Lib' in there). The reason you would call this is because the
OEM is lazy and didn't provide you with a nicer, more protected API. In CE
6.0 this call may get closed on you anyway becasue unless the OEM added an
exclusion for the IOCTL, the app probably can't call it anyway.
--
Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com
So this means simply that this is a nasty hack - and as I get more involved
in C++ this should not occour that often??
I hope not as it is all very confusing
Thanks
--
matthew
Yes, it's a hack and I wouldn't use it. It's very brittle and prone to
breaking the next time you update the device OS.
--
Luca Calligaris (MVP-Windows Embedded)
http://geekswithblogs.net/WindowsEmbeddedAnnotations
l.calliga...@eurotech.it.nospam
www.eurotech.it
"matvdl" <mat...@discussions.microsoft.com> ha scritto nel messaggio
news:01BF0275-A39E-4072...@microsoft.com...