Привет всем, помогите разобраться, с демонстрационным файлом ex1.exe входящим в комплект программного обеспечения. 92 строчка функция AiUpdate(1, &ch) возрашает 0 если модуль готов, и тогда цикл while(AiUpdate(1, &ch)!=0); уходит в бесконечность.
/****************************************************/
/* Filename : EX1.C */
/* I/O Hardware : slot1 is 5017, slot2 is 5018, */
/* slot3 is 5013, */
/* Description : Read the data of simple low */
/* speed AI modules, then show the */
/* data on the screen of ADAM-5510 */
/* utility. */
/* */
/* */
/* */
/* */
/****************************************************/
#include "5510drv.h"
char *s_type[0x1f]={
"",
"",
"",
"",
"ADAM5017_ID ", /*0x4*/
"ADAM5018_ID ",
"",
"",
"",
"ADAM5013_ID ", /*0x9*/
"",
"",
"ADAM5017H_ID", /*0xc*/
"ADAM5018H_ID",
"",
"ADAM5052_ID ",
"ADAM5050_ID ", /*0x10*/
"ADAM5051_ID ",
"ADAM5056_ID ",
"",
"ADAM5060_ID ", /*0x14*/
"",
"",
"",
"ADAM5024_ID " /*0x18*/
"",
"",
"",
"",
"",
"ADAM5080_ID ", /*0x1e*/
};
void main()
{
unsigned char type[4];
int i;
int aiv[32]; /* AI value */
char c;
unsigned char chmask[4]; /* Channel Mask */
int ch;
/* ---- first scan IO module -------*/
for(i=0;i<4;i++)
{
type=Get_BoardID(i);
if( type > 0x18)
type=0;
}
/*----show on the screen ---*/
for(i=0;i<4;i++)
{
printf("IO slot %d is %s \n",i+1,s_type[type]);
}
printf("press any key to continue...\n");getch();
/*--- Initialize AI modules----- */
printf("Initialize ADAM-5017, 5018 ,5013\n");
Init501718(0);
Init501718(1);
Init5013(2);
/*--- Update 8-channel data ---*/
printf("get first 8-channel data \n");
for(i=0;i<8;i++)
{
/* Get 5017 data */
while(AiUpdate(0, &ch)!=0);
Get501718(0, ch, &(aiv[ch]));
/* The valid channels of 5018 are from 0 to 6, the data of the channel 7 is invalid */
while(AiUpdate(1, &ch)!=0);
Get501718(1, ch, &(aiv[ch+8]));
/* The valid channels of 5013 are from 0 to 2, the data of the channels 3-7 is invalid */
while(AiUpdate(2, &ch)!=0);
Get5013(2, ch, &(aiv[ch+16]));
}
/*---- Forever loop until user press any key */
printf("press 'Q' to quit, the other key to continue..\n");
while(1)
{
/*--- Check whether the AI data of the slot 0 is ready --*/
if(AiUpdate(0, &ch)==0)
{
/*-- AI is ready, then return current channel index--*/
/*-- Get one channel data */
/*-- The data format of AI value is a signed engineering unit. */
Get501718(0, ch, &(aiv[ch]));
printf("ch%d val=%d \n",ch,aiv[ch]);
}
/*--- Check whether the AI data of the slot 1 is ready --*/
if(AiUpdate(1, &ch)==0)
{
Get501718(1, ch, &(aiv[ch+8]));
}
if(AiUpdate(2, &ch)==0)
{
Get5013(2, ch, &(aiv[ch+16]));
}
if( kbhit())
{
c=getch();
if( c == 'q' || c == 'Q') /* Quit from this program */
break;
}
}
/*--- Release all allocated timers to reload the control programs */
Release_All();
}
_