インターフェイスを持つDLLがあります
struct modeegPackage
{
uint8_t version; // = 2
uint8_t count; // packet counter. Increases by 1 each packet
uint16_t data[6]; // 10-bit sample (= 0 - 1023) in big endian (Motorola) format
uint8_t switches; // State of PD5 to PD2, in bits 3 to 0
};
__declspec(dllexport) void __cdecl initSerial();
__declspec(dllexport) void __cdecl closeSerialPort();
__declspec(dllexport) struct modeegPackage __cdecl getPackage();
そしてC#アダプター
class EEGCommunication
{
[StructLayout(LayoutKind.Sequential)]
public struct modeegPackage
{
/// unsigned char
public byte version;
/// unsigned char
public byte count;
/// unsigned int[6]
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6, ArraySubType = UnmanagedType.U2)]
public UInt16[] data;
/// unsigned char
public byte switches;
}
private const string DLL = "libneureader-lib.dll";
[DllImport(DLL, EntryPoint = "_Z10initSerialv")]
public static extern void InitSerial();
[DllImport(DLL, EntryPoint = "_Z15closeSerialPortv")]
internal static extern void CloseSerialPort();
[DllImport(DLL, EntryPoint = "_Z10getPackagev", CallingConvention = CallingConvention.Cdecl)]
public static extern modeegPackage GetPackage();
}
GetPackage
しかし、メソッドを呼び出そうとすると、エラーが発生しますMethod's type signature is not PInvoke compatible.
コードの何が問題になっていますか?
更新: コードが更新されました