M
Markus Stiller
Could someone give me an hint?
I have trouble with mashaling of a struct. I can set values in struct
(byVAL) but cant read from the struct. Its an long pointer struct in a
c dll.
thats my struct where is correct i guess
'-----------------------------------
' structure declarations
' xl event
<StructLayout(LayoutKind.Sequential, Pack:=1)> Structure s_xlEvent
Public tag As Byte
Public chanIndex As Byte
Public transID As Short
Public porthandle As Short
Public reserved As Short
Public timestamp As UInt64
<FieldOffset(0)> Public tagdata_can_msg As s_xl_can_msg
<FieldOffset(0)> Public tagdata_chipstate As s_xl_chipstate
<FieldOffset(0)> Public tagdata_lin_msg As s_xl_lin_msg_api
<FieldOffset(0)> Public tagdata_sync_pulse As s_xl_sync_pulse
<FieldOffset(0)> Public tagdata_daio_data As s_xl_daio_data
<FieldOffset(0)> Public tagdata_transceiver As
s_xl_transceiver
End Structure
Structure s_xl_can_msg
Public id As UInt32
Public flags As Short
Public dlc As Short
Public res1 As UInt64
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=8)> Public
data As Byte()
Public res2 As UInt64
End Structure
' function to fill/set struct with array - this is successful
Public Declare Function xlCanTransmit Lib "vxlapi.dll" (ByVal
PortHandle As UInt32, ByVal accessmask As UInt64, ByRef messageCount
As UInt16, <MarshalAs(UnmanagedType.LPArray)> ByVal pMessages As
s_xlEvent()) As Byte
' function to read frome struct with array - this is the problem
Public Declare Function xlReceive Lib "vxlapi.dll" (ByVal PortHandle
As UInt32, ByRef pEventCount As UInt16,
<MarshalAs(UnmanagedType.LPArray)> ByRef pMessages As s_xlEvent()) As
Byte
Problem SizeParamIndex is not allowed to with byref parameter
Any suggestions?
I have trouble with mashaling of a struct. I can set values in struct
(byVAL) but cant read from the struct. Its an long pointer struct in a
c dll.
thats my struct where is correct i guess
'-----------------------------------
' structure declarations
' xl event
<StructLayout(LayoutKind.Sequential, Pack:=1)> Structure s_xlEvent
Public tag As Byte
Public chanIndex As Byte
Public transID As Short
Public porthandle As Short
Public reserved As Short
Public timestamp As UInt64
<FieldOffset(0)> Public tagdata_can_msg As s_xl_can_msg
<FieldOffset(0)> Public tagdata_chipstate As s_xl_chipstate
<FieldOffset(0)> Public tagdata_lin_msg As s_xl_lin_msg_api
<FieldOffset(0)> Public tagdata_sync_pulse As s_xl_sync_pulse
<FieldOffset(0)> Public tagdata_daio_data As s_xl_daio_data
<FieldOffset(0)> Public tagdata_transceiver As
s_xl_transceiver
End Structure
Structure s_xl_can_msg
Public id As UInt32
Public flags As Short
Public dlc As Short
Public res1 As UInt64
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=8)> Public
data As Byte()
Public res2 As UInt64
End Structure
' function to fill/set struct with array - this is successful
Public Declare Function xlCanTransmit Lib "vxlapi.dll" (ByVal
PortHandle As UInt32, ByVal accessmask As UInt64, ByRef messageCount
As UInt16, <MarshalAs(UnmanagedType.LPArray)> ByVal pMessages As
s_xlEvent()) As Byte
' function to read frome struct with array - this is the problem
Public Declare Function xlReceive Lib "vxlapi.dll" (ByVal PortHandle
As UInt32, ByRef pEventCount As UInt16,
<MarshalAs(UnmanagedType.LPArray)> ByRef pMessages As s_xlEvent()) As
Byte
Problem SizeParamIndex is not allowed to with byref parameter
Any suggestions?