读书人

求C# 操控CH375的代码求大神指导

发布时间: 2013-07-08 14:13:00 作者: rapoo

求C# 操控CH375的代码,求大神指点
网上的
[DllImport("CH375DLL.DLL", EntryPoint = "CH375ReadData", ExactSpelling = false, SetLastError = true)]
static extern bool CH375ReadData(
Int16 iIndex, [MarshalAs(UnmanagedType.LPArray)] byte[] oBuffer, [MarshalAs(UnmanagedType.LPArray)] Int32[] ioLength);//读单片机缓存

//写入数据
[DllImport("CH375DLL.DLL", EntryPoint = "CH375WriteData", ExactSpelling = false, SetLastError = true)]
static extern bool CH375WriteData(
Int16 iIndex, [MarshalAs(UnmanagedType.LPArray)] byte[] iBuffer, [MarshalAs(UnmanagedType.LPArray)] Int32[] ioLength); //写单片机缓存


public static bool ReadData(int index, byte[] buffer, ref int length)
{
ReadLength[0] = length;
bool r = CH375ReadData(0, buffer, ReadLength);
length = ReadLength[0];
return r;
}

//写入数据
public static bool WriteData(int index, byte[] buffer, ref int length)
{
ReadLength[0] = length;
bool r = CH375WriteData(0, buffer, ReadLength);
length = ReadLength[0];
return r;
}
那里面的读写 都SlaveDecAddr 和 Startadd 那怎么知道从哪个寄存器的位置开始的呢?
如果我要读写制定的寄存器位置,该如何写呢?


[解决办法]
static extern bool CH375ReadData(
Int16 iIndex, [MarshalAs(UnmanagedType.LPArray)] byte[] oBuffer, [MarshalAs(UnmanagedType.LPArray)] Int32[] ioLength);//读单片机缓存

这个iIndex就是吧,

读书人网 >C#

热点推荐