首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

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

2013-07-08 
求C# 操控CH375的代码,求大神指点 网上的[DllImport(CH375DLL.DLL, EntryPoint CH375ReadData, Exac

求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就是吧,

热点排行