发表于:2004-04-29 14:43:00
楼主
static int icount=0;
// reads analog input channel
ptMAIVoltageIn.NumChan = 5;
ptMAIVoltageIn.StartChan = usStartChan;
for (i=0 ; i< ptMAIVoltageIn.NumChan ; i++)
usGainCode[i+usStartChan] =
DevFeatures.glGainList[usGainIndex[i+usStartChan]].usGainCde;
ptMAIVoltageIn.GainArray = (USHORT far *) &usGainCode[usStartChan];
ptMAIVoltageIn.TrigMode = 0; // internal trigger
ptMAIVoltageIn.VoltageArray = (FLOAT far *)&fVoltage[usStartChan];
if ((ErrCde = DRV_MAIVoltageIn(DriverHandle,
(LPT_MAIVoltageIn)&ptMAIVoltageIn)) != 0)
{
DRV_GetErrorMessage(ErrCde,(LPSTR)szErrMsg);
MessageBox("voltage input failure!", MB_OK);
KillTimer(1);
DRV_DeviceClose((LONG far *)&DriverHandle);
}
// Display Data
m_sensor1=fVoltage[usStartChan];
m_sensor2=fVoltage[usStartChan+1];
m_sensor3=fVoltage[usStartChan+2];
m_sensor4=fVoltage[usStartChan+3];
m_sensor5=fVoltage[usStartChan+4];
UpdateData(false);
//control times
icount++;
if(icount==10)
KillTimer(1);
//save data
FILE *fp;
fp=fopen("d:\\sensor.txt","a+t");
for(int m=0;m<5;m++)
fwrite(fVoltage,sizeof(float),5,fp);
fclose(fp);
请问保存到文本文件里的数据为什么是乱码啊??多谢指教!
再就是用DMA方式编的程序为什么一点开始采集数据按钮程序就死锁啊?就是程序处于忙状态,没有反应。