叶帆的博文中流驱动提出了c#调用底层C/C++的方案,但是有个问题有点困惑.就是应用层的C#接口代码
public sealed class GeneralStream
{
publicGeneralStream();
public event GeneralStreamEventHandlerNotice;
public int Close();
public int IOControl(intcode);
public int IOControl(intcode, int parameter);
public int IOControl(intcode, byte[] inBuffer, intinCount, byte[] outBuffer, int outCount);
public int Open(stringname);
public int Open(string name,int config);
public int Open(string name,string config);
public int Read(byte[]buffer, int offset, intcount);
public int Write(byte[]buffer, int offset, intcount);
}
如何指向g_GeneralStream_UserDriver这个地址呢?
特别看了
http://blog.csdn.net/yfiot/article/details/8087654
这里面的
public LCD1602()
{
gs = new GeneralStream();
int ret =0;
if ((ret = gs.Open("UserDriver", "RS=PC08,RW=PC09,E=PB06,D4=PB07,D5=PC00,D6=PC02,D7=PC03"))<= 0)
{
Debug.Print("ERR="+ ret.ToString());
gs = null;
}
}
gs.Open,这个函数地址应该是Ram里面的地址吧,如果是Ram里面的地址的话,那他跟
const IGeneralStream g_GeneralStream_UserDriver =
{
&GeneralStream_Open1_UserDriver,
&GeneralStream_Open2_UserDriver,
&GeneralStream_Close_UserDriver,
&GeneralStream_IOControl1_UserDriver,
&GeneralStream_IOControl2_UserDriver,
&GeneralStream_Read_UserDriver,
&GeneralStream_Write_UserDriver,
};
这个结构体里面的open地址就没有关系,那么它就无法调用底下实现的流驱动函数了。
所以好疑惑,应用如何指向底层 g_GeneralStream_UserDriver这个常量. |