pinvoke ceddk.dll

  • Thread starter Thread starter Leela
  • Start date Start date
L

Leela

I am new to wince and am having various issues trying to do some basic
io routines. From reading the other posts, I have gained a wealth of
information regarding utilizing ceddk for doing this. I am trying to
utilize pinvoke to call READ_PORT_UCHAR() and WRITE_PORT_UCHAR() w/in
CF written in VB. I am using an x86 based platform and I have verified
ceddk.dll in the \windows on the CE device.

So far I have:

<DllImport("ceddk.dll")> _
Public Shared Function READ_PORT_UCHAR( _
ByRef Port As int16 _
) As Byte
End Function

<DllImport("ceddk.dll")> _
Public Shared Function READ_PORT_UCHAR( _
ByRef Port As int16 _
) As Byte
End Function

the io base port address is 0X300 and I am trying to read the lower
nibble at 0X303

and when I pass in an int of 771 ( 0X303) I get a return of 255 from
READ_PORT_UCHAR() when the actual read should be 0X000 or 0
I've verified that the return read should be 0 by booting into dos and
using the inportb function.

As a matter of fact, no matter what I pass in (any int value), I get a
return read value of 255.

Please help.... any help is greatly appreciated. Thanks in advance.
 
A UCHAR is 16 bits, a byte is only 8, so that's going to cause you major
grief with your definitions right there.
 
Well, among other things I've tried port as byte datatype..... but how
do you pass in an address of 0X303 (int of 771) as a byte value? or
am I completely off base here.
 
You can't. You'd need READ_PORT_USHORT, which is a UInt16 (short). I'm no
x86 expert, but addresses are using 32 bits, so you'd probably want to be
passing a full DWORD anyway, not a byte or a short, so maybe READ_PORT_ULONG
is most appropriate for your goal.
 
I've also tried the following function call with integer datatype...

<DllImport("ceddk.dll")> _
Public Shared Function READ_PORT_ULONG( _
ByRef Port As Integer _
) As Integer
End Function

and I returned a value of -1 when passing in an address of 771
(0X303) .... when I was expecting a value of 0X000. Once again no
matter what address I pass in, I am returning a value of -1
 
that did the trick...... thank you very much for all the help, I was on
the brink of going mad and you saved me. Kudos to google groups and
Chris.
 
Back
Top