📄 mtdemo1.c
字号:
/* ILC Data Device Corp.
*
* Advanced Communication Engine Integrated 1553 Terminal
* (ACE) 'C' Software Library
*
* BUS-69080 rel 4.0 05-MAR-1998
*
* Copyright (c) 1995,96,97,98 by ILC Data Device Corp.
* All Rights Reserved.
*
* mtdemo1.c
* Demonstrates use of monitor mode using polling of the
* ACE stack pointer to determine if messages have been rcvd
* off-loading monitor stack on a message by message basis.
*/
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
/* uncomment the following if the ACELIB dll is being used */
/*#define __IMPORTDLL__*/
#include <stdace.h>
void DisplayMsg(MsgType*Msg);
void main ()
{
MsgType msg;
BuConf_t Conf;
BuError_t Err;
clrscr();
printf("%s\n\n",BuRev());
Err=BuInit("ace.cfg",&Conf);
if(Err) {
printf("BuError %d %s\n",Err,BuErrorStr(Err));
return;
}
if(BuValid()) {
BuMTOpen();
BuMTStkType(MT_DOUBLE,CMD256,DATA1024);
/* def stack A to have a command stack at address 0, initially */
/* pointing to address 0x40 and a length of 256 words. and define */
/* the data stack to be at address 0x400, with the pointer initially */
/* starting at 0x500 and a length of 0x400 */
BuMTDefStk(MT_STACKA,0X0000,0X0040,0X0400,0x100);
/* def stack B to have a command stack at address 0x100, initially */
/* pointing to address 0x140 and a length of 256 words. and define */
/* the data stack to be at address 0x800, with the pointer initially */
/* starting at 0x900 and a length of 0x400 */
BuMTDefStk(MT_STACKB,0x0100,0x40,0x0800,0x100);
/* enable all subaddress's */
BuMTEnableRT(MT_ALL,MT_ALL,MT_ALL);
BuMTRun(); /* start the monitor up */
printf("Monitor Running -- waiting for messages\n");
do {
if(BuMTReadMsg(&msg)) {
DisplayMsg(&msg);
}
} while(!kbhit());
BuMTClose();
} else printf("Error with 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(" wc %d\n",Msg->WordCount);
printf(" dl %d\n",Msg->DataLength);
printf(" Time %u uS\n",Msg->TimeTag*2); /*2us resolution*/
printf(" BSW %04X %s\n", Msg->BlockStatus,
BuMTBSWErrorStr(Msg->BlockStatus));
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);
printf("\n\n");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -