⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bmset.c

📁 实现vxworks下的1553b通讯功能
💻 C
字号:
#include "proto.h"
extern int gMultiBuf;

extern struct bm_command_block * bm_command_blocks; /* monitor command blocks */

int borland_dll Run_BM (void)
{
	#define BUFFERMODE2 0x180
	if ((curmode != BM_MODE) && (curmode != BM_RT_MODE))
	   return (emode);
	
	exc_summit->cmd_blk_ptr = INIT_MON_BLK;
	exc_summit->data_ptr = INIT_DATA_BLK;
	exc_summit->blk_counter = MAXMESSAGES;
	nextmsg = 0;

      if (curmode == BM_MODE)
      	wForceWordWrite = exc_summit->control | START_EXECUTION;
      else
        wForceWordWrite =  START_EXECUTION | BUAEN | BUBEN;

	if (gMultiBuf == 1)
	wForceWordWrite |= (unsigned short)BUFFERMODE2; /* hopefully pingpong and broadcast not set */

      exc_summit->control = wForceWordWrite;
	return (0);
} /* end Run_BM */


int borland_dll Get_Last_Cmd (void)
{
	if ((curmode != BM_MODE) && (curmode != BM_RT_MODE))
	   return(emode);
	return(exc_summit->current_cmd_block);
} /* end Get_Last_Cmd */


int borland_dll Monitor_All_RT (void)
{

	if ((curmode != BM_MODE) && (curmode != BM_RT_MODE))
	   return (emode);
      wForceWordWrite =  exc_summit->control & ~BMTC; /*bm select and monitor all terminals*/
	  exc_summit->control = wForceWordWrite;

	/* set filter value for all rtids */
	exc_summit->filter2 = (unsigned short)0xffff;
        exc_summit->filter1 = (unsigned short)0xffff;

	return (0);
} /* end Monitor_All_RT */


int borland_dll Monitor_RT (short rtid)
{
	if ((curmode != BM_MODE) && (curmode != BM_RT_MODE))
	   return (emode);
	if ((rtid<0) || (rtid>31))
	   return (ebadid);
	
      wForceWordWrite =  exc_summit->control | BMTC; /*stop monitor all terminals*/
	  exc_summit->control = wForceWordWrite;

	if (rtid>15)
        {
		  wForceWordWrite = exc_summit->filter1 |(unsigned short) (1 << (rtid-16));
		  exc_summit->filter1 = wForceWordWrite;	 
        }
	else
        {
		wForceWordWrite = exc_summit->filter2 | (unsigned short) (1 << rtid);
		exc_summit->filter2 = wForceWordWrite;
        }
	return (0);
} /* end Monitor_RT */


int borland_dll Clear_Monitor_RT (short rtid)
{
	if ((curmode != BM_MODE) && (curmode != BM_RT_MODE))
	   return (emode);
	if ((rtid<0) || (rtid>31))
	   return (ebadid);

	  wForceWordWrite = exc_summit->control | BMTC; /*stop monitor all terminals*/
	  exc_summit->control = wForceWordWrite;

	if (rtid>15)
        {
		wForceWordWrite = exc_summit->filter1 & (unsigned short)~(1 << (rtid-16));
		exc_summit->filter1 = wForceWordWrite;
        }
	else
        {
		wForceWordWrite = exc_summit->filter2 & (unsigned short)~(1 << rtid);
		exc_summit->filter2 = wForceWordWrite;
        }
	return (0);
} /* end Clear_Monitor_RT */


int borland_dll Read_Next_Message (struct BM_MSG  *msg)
{
	unsigned short msgindex;
	unsigned short i, wordcnt, subaddr;

	if ((curmode != BM_MODE) && (curmode != BM_RT_MODE))
	   return (emode);

	if (bm_command_blocks[nextmsg].msginfo == Clear_Pattern)
	   return(enomsg);
	
	msg->command1 = bm_command_blocks[nextmsg].command1;
	msg->command2 = bm_command_blocks[nextmsg].command2;
	msg->status1  = bm_command_blocks[nextmsg].status1;
	msg->status2  = bm_command_blocks[nextmsg].status2;
	msg->timetag  = bm_command_blocks[nextmsg].timetag;
	msg->msginfo  = bm_command_blocks[nextmsg].msginfo;

	bm_command_blocks[nextmsg].msginfo = Clear_Pattern;
	
	msgindex = bm_command_blocks[nextmsg].data_ptr;
	subaddr =(unsigned short)( (msg->command1 >> 5) & 0x1f);
   if ((subaddr == 0) || (milstd1553B && (subaddr == 31)))
	   wordcnt = 1;
	else
	   {
	   wordcnt = (unsigned short) (msg->command1 & 0x1f);
	   if (wordcnt == 0)
	      wordcnt = 32;
	   }
	for (i = 0; i < wordcnt; i++)
	   msg->data[i] = exc_summit_int[(msgindex) + i];
	if (nextmsg++ == MAXMESSAGES)
	   nextmsg = 0;
	return(0); 
} /* end Read_Next_Message */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -