C# 与C++传值问题
C++结构体:typedefstructGY7502_DATA_INFO{BYTEDatabuffer[256];//buffertowriteorreadUINTWri...
C++结构体:
typedef struct GY7502_DATA_INFO{
BYTE Databuffer[256];//buffer to write or read
UINT WriteNum;//Valid num in Databuffer[]
UINT ReadNum;// data num to Read
BYTE IoSel;//bit value=1 means selected. bit0 for IO-PORT0, bit1 for IO-PORT1
BYTE IoData;//only the bit will be valid which bit is 1 in IoSel.
BYTE ChipSelect;//Chip Selected,output, 0~CS0, 1~CS1
BYTE Reserved[4];//Reserved
}GY7502_DATA_INFO,*pGY7502_DATA_INFO;
C#的结构体:
[StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public struct GY7502_DATA_INFO
{
/// <summary>
/// 地址和数据
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
public byte[] Databuffer;
/// <summary>
/// 地址和数据的总个数
/// </summary>
public int WriteNum;
/// <summary>
/// 需要读的数据个数
/// </summary>
public byte ReadNum;
/// <summary>
/// IO口选择
/// </summary>
public byte IoSel;
public byte IoData;
/// <summary>
/// 片选输出选择 值:0、1
/// </summary>
public byte ChipSelect;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public byte[] Reserved;
}
请问对不对啊? 展开
typedef struct GY7502_DATA_INFO{
BYTE Databuffer[256];//buffer to write or read
UINT WriteNum;//Valid num in Databuffer[]
UINT ReadNum;// data num to Read
BYTE IoSel;//bit value=1 means selected. bit0 for IO-PORT0, bit1 for IO-PORT1
BYTE IoData;//only the bit will be valid which bit is 1 in IoSel.
BYTE ChipSelect;//Chip Selected,output, 0~CS0, 1~CS1
BYTE Reserved[4];//Reserved
}GY7502_DATA_INFO,*pGY7502_DATA_INFO;
C#的结构体:
[StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public struct GY7502_DATA_INFO
{
/// <summary>
/// 地址和数据
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
public byte[] Databuffer;
/// <summary>
/// 地址和数据的总个数
/// </summary>
public int WriteNum;
/// <summary>
/// 需要读的数据个数
/// </summary>
public byte ReadNum;
/// <summary>
/// IO口选择
/// </summary>
public byte IoSel;
public byte IoData;
/// <summary>
/// 片选输出选择 值:0、1
/// </summary>
public byte ChipSelect;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public byte[] Reserved;
}
请问对不对啊? 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询