📄 bcdemo4.c
字号:
/* ILC Data Device Corp.
*
* Advanced Communication Engine Integerated 1553 Terminal
* (ACE) 'C' Software Library
*
* BUS-69080 rel 2.3 01-JAN-1996
*
* Copyright (c) 1995, 1996 by ILC Data Device Corp.
* All Rights Reserved.
*
* bcdemo4.c
* This program demonstrates the use of BuBCRecallMinor. This
* function loads a minor frame from disk and does all the
* necessary message and minor frame creation. The program
* continues with the execution of the minor frame and the
* reading of the message results with BuBCReadMsgNum.
*/
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
/* uncomment the following if using the 'ACEWIN31.DLL' Dynamic Link Library */
//#define __IMPORTDLL__
#include <stdace.h>
void DisplayMsg(MsgType*Msg);
void main ()
{
BuConf_t Conf; /* ACE library configuration type */
BuError_t Err; /* ACE library error status type */
int NumOfMsgs,j;
BCMinorFrmHandle myframe; /* each minor frame has a handle */
MsgType readmsg;
clrscr();
/* display revision info */
printf("%s\n\n",BuRev());
/* load configuration from "ace.cfg" file and open ACE library */
Err=BuInit("ace.cfg",&Conf);
if(Err) {
printf("BuError %d %s\n",Err,BuErrorStr(Err));
return;
}
if(BuValid()) {
/* enter bus controller mode of operation */
BuBCOpen();
/* recall minor frame to file */
if((NumOfMsgs=BuBCRecallMinor("test.frm",&myframe))==0) {
printf("error loading .frm file\n");
BuBCClose();
BuClose();
return;
}
/* set response timeout to 50.5 us */
BuTimeout(RESPONSE_505);
/* load minor frame into ACE stack */
BuBCLoadMinor(BU_BCFRMBUFA,myframe);
/* run frame */
BuBCRunMinor(BU_BCFRMBUFA,BU_BCSINGLE);
while(BuBCIsFrmActive());
for(j=0;j<NumOfMsgs;j++) {
if(BuBCReadMsgNum(myframe,j,&readmsg))
printf("error reading message result\n");
else DisplayMsg(&readmsg);
}
/* free minor frame and associated messages */
BuBCFreeMinor(myframe,TRUE);
/* should be called to close bus controller mode */
BuBCClose();
} else printf("error communicating with pc card\n");
BuClose();
}
void DisplayMsg(MsgType*Msg)
{
U16BIT i;
printf("Message Type = %s",BuMsgTypeStr(Msg->Type));
if(Msg->BlockStatus&MT_ERR)printf(" (EXCEPTION)\n");else printf("\n");
printf(" Cmd1 %04X %s\n",Msg->CmdWord1,BuCmdStr(Msg->CmdWord1));
if(Msg->CmdWord2flag) {
printf(" Cmd2 %04X %s\n",Msg->CmdWord2,BuCmdStr(Msg->CmdWord2));
}
printf(" Time %u uS\n",Msg->TimeTag*2); /*2us resolution*/
printf(" GapT %u uS\n",Msg->GapTime); /*1us resolution*/
printf(" BSW %04X %s\n",Msg->BlockStatus,BuBCBSWErrorStr(Msg->BlockStatus));
printf(" Ctrl %04X \n",Msg->ControlWord);
for(i=0;i<Msg->DataLength;++i) {
if(i==0)printf(" Data ");
printf("%04X ",Msg->Data[i]);
if((i%6)==5)printf("\n ");
}
if(Msg->Status1flag)printf("\n Sta1 %04X",Msg->Status1);
if(Msg->Status2flag)printf("\n Sta2 %04X",Msg->Status2);
if(Msg->LoopBack1flag)printf("\n Lpb1 %04X",Msg->LoopBack1);
if(Msg->LoopBack2flag)printf("\n Lpb2 %04X",Msg->LoopBack2);
printf("\n\n");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -