M1553 BC Run Sched
Edit this on GitLab
M1553 BC Run Sched Sample Application (SSK 2.x)
Overview
The M1553 BC Run Sched sample application demonstrates how to configure a MIL-STD-1553 Bus Controller (BC) to run a multi-rate message schedule using the NAI Software Support Kit (SSK 2.x). Unlike the basic BC SendMsg sample which sends a single message per major frame, this sample creates three messages that execute at different periodic rates by organizing them across multiple minor frames within a single major frame.
The schedule uses three 2.5 ms minor frames to achieve the following message rates:
-
Message 1 — sent at 400 Hz (every 2.5 ms), present in all three minor frames
-
Message 2 — sent at 200 Hz (every 5 ms), present in minor frames 1 and 2
-
Message 3 — sent at 100 Hz (every 10 ms), present in minor frame 1 only
The minor frames are chained in the major frame as: Minor Frame 1, Minor Frame 3, Minor Frame 2, Minor Frame 3. This pattern ensures each message executes at its target rate.
For detailed 1553 protocol specifications, message formats, and hardware register descriptions, see the FTA-FTF Manual.
For the SSK 1.x version, see M1553 BC SendMessageSchedule (SSK 1.x).
Prerequisites
Before running this sample, make sure you have:
-
An NAI board with a 1553 module installed (FTA-FTF, FTJ-FTK).
-
SSK 2.x installed on your development host.
-
The sample applications built. Refer to the SSK 2.x Software Development Guide for platform-specific build instructions.
-
A second 1553 device (RT) at address 1 connected on the same bus to respond to BC messages.
How to Run
Launch the m1553_bc_run_sched executable from your build output directory. On startup the application looks for a configuration file (default_1553BC_SendMessageSchedule.txt). Once connected, the application prompts for channel, bus selection, and software override settings, then runs the schedule continuously for approximately 10 seconds before displaying the last decoded response for each message.
Board Connection and Module Selection
|
Note
|
This startup sequence is common to all NAI sample applications. |
The main() function follows a standard SSK 2.x startup flow:
-
Call
naiapp_RunBoardMenu()to load or create a configuration file (default_1553BC_SendMessageSchedule.txt). -
Query the user for a card index with
naiapp_query_CardIndex(). -
Query for a module slot with
naiapp_query_ModuleNumber(). -
Retrieve the module ID with
naibrd_GetModuleName().
#if defined (NAIBSP_CONFIG_SOFTWARE_OS_VXWORKS)
int32_t m1553_bc_run_sched(void)
#else
int32_t main(void)
#endif
{
int32_t cardIndex;
int32_t moduleCnt;
int32_t module;
bool_t stop = NAI_FALSE;
uint32_t moduleID = 0;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
if (naiapp_RunBoardMenu(DEF_CONFIG_FILE) == (bool_t)NAI_TRUE)
{
while (stop != NAI_TRUE)
{
stop = naiapp_query_CardIndex(naiapp_GetBoardCnt(), 0, &cardIndex);
if (stop != NAI_TRUE)
{
check_status(naibrd_GetModuleCount(cardIndex, &moduleCnt));
stop = naiapp_query_ModuleNumber(moduleCnt, 1, &module);
if (stop != NAI_TRUE)
{
check_status(naibrd_GetModuleName(cardIndex, module, &moduleID));
if ((moduleID != 0))
{
Run_m1553_bc_send_msgSchedule(cardIndex, module, moduleID);
}
}
}
naiif_printf("\r\nType Q to quit or Enter key to restart application:\r\n");
stop = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
}
}
naiapp_access_CloseAllOpenCards();
return 0;
}
|
Important
|
Common Connection Errors
|
Program Structure
Entry Point
The Run_m1553_bc_send_msgSchedule() function validates the module supports 1553, queries for a channel, and delegates to RunSendMessageSchedule().
Application Flow
RunSendMessageSchedule() creates three BC-to-RT messages with different subaddresses and word counts, builds a multi-level frame hierarchy, runs the schedule for 10 seconds, then decodes and displays the last response for each message.
The sample defines three messages targeting different subaddresses:
#define RT_SUBADDRESS1 1 /* Subaddress for Message 1 */
#define RT_SUBADDRESS2 2 /* Subaddress for Message 2 */
#define RT_SUBADDRESS3 8 /* Subaddress for Message 3 */
#define WORDCOUNT1 11 /* Data Word count for Message 1 */
#define WORDCOUNT2 21 /* Data Word count for Message 2 */
#define WORDCOUNT3 30 /* Data Word count for Message 3 */
Building the Multi-Rate Frame Hierarchy
The schedule hierarchy is more complex than the single-message samples. It uses three minor frames with different message combinations and six opcodes (three execute-message, three call-subroutine).
Minor Frame Construction
/* Minor Frame 1: Messages 1, 2, and 3 */
aOpCodes[0] = OP1; aOpCodes[1] = OP2; aOpCodes[2] = OP3;
status = naibrd_1553_BcFrmCreate(devnum, MNR1, NAIBRD_1553_BC_FRAME_MINOR,
aOpCodes, 3, 25, NAIBRD_1553_BC_FRAME_DEFAULT); /* 25 = 2.5 ms */
/* Minor Frame 2: Messages 1 and 2 */
aOpCodes[0] = OP1; aOpCodes[1] = OP2;
status = naibrd_1553_BcFrmCreate(devnum, MNR2, NAIBRD_1553_BC_FRAME_MINOR,
aOpCodes, 2, 25, NAIBRD_1553_BC_FRAME_DEFAULT);
/* Minor Frame 3: Message 1 only */
aOpCodes[0] = OP1;
status = naibrd_1553_BcFrmCreate(devnum, MNR3, NAIBRD_1553_BC_FRAME_MINOR,
aOpCodes, 1, 25, NAIBRD_1553_BC_FRAME_DEFAULT);
Each minor frame has a time of 25 (2.5 ms in 0.1 ms units).
Major Frame Construction
/* Major Frame: MNR1, MNR3, MNR2, MNR3 */
aOpCodes[0] = OP4; /* Call Minor Frame 1 */
aOpCodes[1] = OP6; /* Call Minor Frame 3 */
aOpCodes[2] = OP5; /* Call Minor Frame 2 */
aOpCodes[3] = OP6; /* Call Minor Frame 3 */
status = naibrd_1553_BcFrmCreate(devnum, MJR, NAIBRD_1553_BC_FRAME_MAJOR,
aOpCodes, 4, 0, NAIBRD_1553_BC_FRAME_DEFAULT);
The major frame time is set to 0, which means the minor frame times (2.5 ms each) determine the schedule timing. If the major frame time were set to a non-zero value, it would override all minor frame times.
Running the Schedule
The BC runs the schedule continuously for 10 seconds:
status = naibrd_1553_BcStart(devnum, MJR, NAIBRD_1553_BC_FRAME_RUN_FOREVER);
naiif_printf("BC Running for approximately 10 seconds...\r\n");
naibrd_msDelay(10000);
status = naibrd_1553_BcStop(devnum);
After stopping, the sample polls naibrd_1553_BcGetActiveState() to confirm the BC has fully stopped before reading results:
do
{
status = naibrd_1553_BcGetActiveState(devnum, &outBCstate);
naibrd_msDelay(100);
timeOutCount++;
} while((outBCstate == NAIBRD_1553_BC_STATE_BUSY) && (timeOutCount <= 50));
Decoding Responses
After the schedule completes, the sample decodes the last response for each of the three messages using naibrd_1553_BcMsgGetByIdDecoded().
Troubleshooting Reference
| Error / Symptom | Possible Causes | Suggested Resolution |
|---|---|---|
|
Channel already open, invalid indices |
Verify indices, ensure no other application holds the channel |
|
Incomplete frame hierarchy |
Verify all opcodes, minor frames, and major frame are created |
BC never leaves BUSY state |
Schedule running forever without stop |
Increase timeout in |
No response from RT |
RT not at address 1, bus wiring issue |
Verify RT address matches |
Minor frame overrun |
Messages take longer than 2.5 ms minor frame time |
Reduce word counts or increase minor frame time |
Software override needed |
BC_DISABLE or M1760 pins not externally driven high |
Enable software override when prompted for bench testing |
Full Source
The complete source for this sample is provided below for reference. The sections above explain each part in detail.
Full Source — m1553_bc_run_sched.c (SSK 2.x)
/* nailib include files */
#include "nai_libs/nailib/include/naitypes.h"
#include "nai_libs/nailib/include/nailib.h"
#include "nai_libs/nailib/include/nailib_utils.h"
/* naibrd include files */
#include "nai_libs/naibrd/include/naibrd.h"
#include "nai_libs/naibrd/include/functions/naibrd_1553.h"
/* naiif include files */
#include "nai_libs/naiif/include/naiif_stdio.h"
/* Common 1553 Sample Program include files */
#include "nai_sample_apps/naiapp_src/board_modules/1553/m1553_common_utils/m1553_common_utils.h"
#include "nai_sample_apps/naiapp_src/board_modules/1553/m1553_common_utils/BC/m1553_bc_common_utils.h"
/* Common Sample Program include files */
#include "nai_sample_apps/naiapp_common/include/naiapp_boardaccess_menu.h"
#include "nai_sample_apps/naiapp_common/include/naiapp_boardaccess_query.h"
#include "nai_sample_apps/naiapp_common/include/naiapp_boardaccess_access.h"
#include "nai_sample_apps/naiapp_common/include/naiapp_boardaccess_display.h"
#include "nai_sample_apps/naiapp_common/include/naiapp_boardaccess_utils.h"
static const int8_t *DEF_CONFIG_FILE = (int8_t *)"default_1553BC_SendMessageSchedule.txt";
/* Function prototypes */
static bool_t Run_m1553_bc_send_msgSchedule(int32_t cardIndex, int32_t module, uint32_t modid);
static bool_t RunSendMessageSchedule(int32_t cardIndex, int32_t module, int32_t channel, uint32_t modid);
/* define message constants */
#define MSG1 1
#define MSG2 2
#define MSG3 3
/* define opcodes */
#define OP1 1
#define OP2 2
#define OP3 3
#define OP4 4
#define OP5 5
#define OP6 6
/* define frame constants */
#define MNR1 1
#define MNR2 2
#define MNR3 3
#define MJR 4
/* define data block numbers */
#define DBLK1 1
#define DBLK2 2
#define DBLK3 3
#define DEF_M1553_CARD_INDEX 0
#define DEF_M1553_MODULE 1
#define DEF_M1553_CHANNEL 1
#define DEF_M1553_DEVNUM 1
#define RT_ADDRESS 1
#define RT_SUBADDRESS1 1 /* Subaddress for Message 1 */
#define RT_SUBADDRESS2 2 /* Subaddress for Message 2 */
#define RT_SUBADDRESS3 8 /* Subaddress for Message 3 */
#define WORDCOUNT1 11 /* Data Word count for Message 1 */
#define WORDCOUNT2 21 /* Data Word count for Message 2 */
#define WORDCOUNT3 30 /* Data Word count for Message 3 */
/**************************************************************************************************************/
/** \defgroup M1553_BC_RunSchedule
\brief This sample application demonstrates how to configure a channel as a Bus Controller and send a message schedule.
The purpose of the M1553_BC_RunSchedule is to illustrate the methods to call in the naibrd library to configure
the 1553 channel as a Bus Controller and to send various messages at different periodic rates. Specifically,
Message 1 is sent at a rate of 400 Hz (every 2.5 ms), Message 2 is sent at a rate of 200 Hz (every 5 ms) and
Message 3 is sent at a rate of 100 Hz (every 10 ms). Three 2.5 ms minor frames are used to manage the periodicity
of these messages. Minor Frame 1 contains Messages 1, 2 and 3. Minor Frame 2 contains Messages 1 and 2 only. Minor
Frame 3 only contains Message 1. By chaining these frames together in the following order:x
Minor Frame 1 | Minor Frame 3 | Minor Frame 2 | Minor Frame 3
Message 1 is sent every 2.5 ms, Message 2 is sent every 5 ms and Message 3 is sent every 10 ms.
The main steps include:
- Querying the user for the card index and module number.
- Configuring the channel for Bus Controller functionality.
- Configuring a major frame with several minor frames with different message configurations.
- Starting the BC to transmit the configured schedule.
- Displaying the RT response and BC Status.
*/
/**************************************************************************************************************/
#if defined (NAIBSP_CONFIG_SOFTWARE_OS_VXWORKS)
int32_t m1553_bc_run_sched(void)
#else
int32_t main(void)
#endif
{
int32_t cardIndex;
int32_t moduleCnt;
int32_t module;
bool_t stop = NAI_FALSE;
uint32_t moduleID = 0;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
if (naiapp_RunBoardMenu(DEF_CONFIG_FILE) == (bool_t)NAI_TRUE)
{
while (stop != NAI_TRUE)
{
/* Select Card Index */
stop = naiapp_query_CardIndex(naiapp_GetBoardCnt(), 0, &cardIndex);
if (stop != NAI_TRUE)
{
check_status(naibrd_GetModuleCount(cardIndex, &moduleCnt));
/* Select Module */
stop = naiapp_query_ModuleNumber(moduleCnt, 1, &module);
if (stop != NAI_TRUE)
{
check_status(naibrd_GetModuleName(cardIndex, module, &moduleID));
if ((moduleID != 0))
{
Run_m1553_bc_send_msgSchedule(cardIndex, module, moduleID);
}
}
}
naiif_printf("\r\nType Q to quit or Enter key to restart application:\r\n");
stop = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
}
}
naiif_printf("\r\nType the Enter key to exit the program: ");
naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
naiapp_access_CloseAllOpenCards();
return 0;
}
static bool_t Run_m1553_bc_send_msgSchedule(int32_t cardIndex, int32_t module, uint32_t modid)
{
bool_t bQuit = NAI_FALSE;
int32_t channel;
int32_t MaxChannel = 4;
if ((IsFTx1553(modid)) || (IsFTx1760(modid)))
{
MaxChannel = 4;
bQuit = naiapp_query_ChannelNumber(MaxChannel, DEF_M1553_CHANNEL, &channel);
if (!bQuit)
{
bQuit = RunSendMessageSchedule(cardIndex, module, channel, modid);
}
}
else
naiif_printf("\r\nThis module does not support 1553 functionality.\r\n");
return bQuit;
}
static bool_t RunSendMessageSchedule(int32_t cardIndex, int32_t module, int32_t channel, uint32_t modid)
{
int32_t i = 0u;
bool_t bQuit = NAI_FALSE;
uint32_t usBus = 0u;
naibrd_1553_t status = 0u;
uint16_t increment = 0u;
uint16_t aData[32] = {0};
int16_t aOpCodes[20] = { 0 };
bool_t bContinue = NAI_TRUE;
int16_t devnum = 0u;
naibrd_1553_msgstruct_t DecodedMsgStruct;
bool_t bSoftware = NAI_FALSE;
int8_t inputBuffer[80] = {0};
int32_t inputResponseCnt = 0u;
int32_t timeOutCount = 0u;
naibrd_1553_bc_active_state_t outBCstate;
/* Get the Logical Device Number */
bQuit = Get1553LogicalDevNum(DEF_M1553_DEVNUM, &devnum);
if (!bQuit)
{
/* Which bus are we firing on? */
bQuit = GetBus(&usBus);
if (!bQuit)
{
bQuit = Get1553BCSoftwareOverride(NAI_TRUE, &bSoftware);
if (!bQuit)
{
/* Open 1553 Device(s) */
status = naibrd_1553_Open(cardIndex, module, channel, devnum);
if (status != 0)
{
naiif_printf("Error: naibrd_1553_Open Ch %d, status = %d", channel, status);
return NAI_TRUE;
}
if (bSoftware)
{
/* Override external BC_DISABLE and M1760 (In order to configure as BC, this needs to */
/* be set if BC_DISABLE and M1760 pins are not driven high) */
naibrd_1553_WriteAuxRegister(devnum, NAIBRD_1553_AUX_ADDRESS_MISC_BITS,
NAIBRD_1553_AUX_REG_MISC_BITS_MASK_OVERRIDE_BC_DISABLE | NAIBRD_1553_AUX_REG_MISC_BITS_MASK_OVERRIDE_M1760);
}
else
{
/* Do not override external BC_DISABLE and M1760 Inputs */
naibrd_1553_WriteAuxRegister(devnum, NAIBRD_1553_AUX_ADDRESS_MISC_BITS, 0);
}
if (modid == NAIBRD_MODULE_ID_FT8)
{
/* Simplex Enable (for NAI internal testing only, do not enable) */
/*naibrd_1553_WriteAuxReg(devnum, 0x3, 0x4000);*/
/*naibrd_1553_WriteAuxReg(devnum, 0xF, 0x0001);*/
}
/* Reset Device */
naibrd_1553_WriteAuxRegister(devnum, NAIBRD_1553_AUX_ADDRESS_RESET, 1);
naibrd_msDelay(1);
naibrd_1553_WriteAuxRegister(devnum, NAIBRD_1553_AUX_ADDRESS_RESET, 0);
/* Initialize 1553 Device(s) */
status = naibrd_1553_Init(devnum, NAIBRD_1553_ACCESS_CARD, NAIBRD_1553_MODE_BC, 0, 0, 0);
if (status != 0)
{
naiif_printf("Error: naibrd_1553_Initialize Ch %d, status = %d", channel, status);
return NAI_TRUE;
}
/* Create BC Data Block 1 */
status = naibrd_1553_BcDataBlkCreate(devnum, DBLK1, NAIBRD_1553_BC_DATABLOCK_SIZE_32_SINGLE, NULL, 0);
if (status != 0)
{
naiif_printf("Error: naibrd_1553_BcDataBlockCreate Ch %d, status = %d", channel, status);
return NAI_TRUE;
}
/* Create BC Data Block 2 */
status = naibrd_1553_BcDataBlkCreate(devnum, DBLK2, NAIBRD_1553_BC_DATABLOCK_SIZE_32_SINGLE, NULL, 0);
if (status != 0)
{
naiif_printf("Error: naibrd_1553_BcDataBlockCreate Ch %d, status = %d", channel, status);
return NAI_TRUE;
}
/* Create BC Data Block 3 */
status = naibrd_1553_BcDataBlkCreate(devnum, DBLK3, NAIBRD_1553_BC_DATABLOCK_SIZE_32_SINGLE, NULL, 0);
if (status != 0)
{
naiif_printf("Error: naibrd_1553_BcDataBlockCreate Ch %d, status = %d", channel, status);
return NAI_TRUE;
}
/* Create BC to RT Message 1 */
status = naibrd_1553_BcMsgCreateBcToRt(devnum, MSG1, DBLK1, RT_ADDRESS, RT_SUBADDRESS1, WORDCOUNT1, 0, usBus);
if (status != 0)
{
naiif_printf("Error: naibrd_1553_BcMessageCreateBcToRt status = %d", status);
return NAI_TRUE;
}
/* Create BC to RT Message 2 */
status = naibrd_1553_BcMsgCreateBcToRt(devnum, MSG2, DBLK2, RT_ADDRESS, RT_SUBADDRESS2, WORDCOUNT2, 0, usBus);
if (status != 0)
{
naiif_printf("Error: naibrd_1553_BcMessageCreateBcToRt status = %d", status);
return NAI_TRUE;
}
/* Create BC to RT Message 3 */
status = naibrd_1553_BcMsgCreateBcToRt(devnum, MSG3, DBLK3, RT_ADDRESS, RT_SUBADDRESS3, WORDCOUNT3, 0, usBus);
if (status != 0)
{
naiif_printf("Error: naibrd_1553_BcMessageCreateBcToRt status = %d", status);
return NAI_TRUE;
}
/* Create Execute Message Command 1 */
status = naibrd_1553_BcCmdCreate(devnum, OP1, NAIBRD_1553_OPCODE_EXECUTE_MESSAGE, NAIBRD_1553_OPCODE_COND_ALWAYS, MSG1, 0, 0);
if (status != 0)
{
naiif_printf("Error: naibrd_1553_BcCommandCreate status = %d", status);
return NAI_TRUE;
}
/* Create Execute Message Command 2 */
status = naibrd_1553_BcCmdCreate(devnum, OP2, NAIBRD_1553_OPCODE_EXECUTE_MESSAGE, NAIBRD_1553_OPCODE_COND_ALWAYS, MSG2, 0, 0);
if (status != 0)
{
naiif_printf("Error: naibrd_1553_BcCommandCreate status = %d", status);
return NAI_TRUE;
}
/* Create Execute Message Command 3 */
status = naibrd_1553_BcCmdCreate(devnum, OP3, NAIBRD_1553_OPCODE_EXECUTE_MESSAGE, NAIBRD_1553_OPCODE_COND_ALWAYS, MSG3, 0, 0);
if (status != 0)
{
naiif_printf("Error: naibrd_1553_BcCommandCreate status = %d", status);
return NAI_TRUE;
}
/* Create Minor Frame 1 */
aOpCodes[0] = OP1; /* Execute Message 1 Command */
aOpCodes[1] = OP2; /* Execute Message 2 Command */
aOpCodes[2] = OP3; /* Execute Message 3 Command */
/* 25 for 2.5 ms minor frame (1 unit is 0.1 ms) */
status = naibrd_1553_BcFrmCreate(devnum, MNR1, NAIBRD_1553_BC_FRAME_MINOR, aOpCodes, 3, 25, NAIBRD_1553_BC_FRAME_DEFAULT);
if (status != 0)
{
naiif_printf("Error: naibrd_1553_BcFrameCreate status = %d", status);
return NAI_TRUE;
}
/* Create Minor Frame 2 */
aOpCodes[0] = OP1; /* Execute Message 1 Command */
aOpCodes[1] = OP2; /* Execute Message 2 Command */
status = naibrd_1553_BcFrmCreate(devnum, MNR2, NAIBRD_1553_BC_FRAME_MINOR, aOpCodes, 2, 25, NAIBRD_1553_BC_FRAME_DEFAULT); /* 25 for 2.5 ms frame */
if (status != 0)
{
naiif_printf("Error: naibrd_1553_BcFrameCreate status = %d", status);
return NAI_TRUE;
}
/* Create Minor Frame 3 */
aOpCodes[0] = OP1; /* Execute Message 1 Command */
status = naibrd_1553_BcFrmCreate(devnum, MNR3, NAIBRD_1553_BC_FRAME_MINOR, aOpCodes, 1, 25, NAIBRD_1553_BC_FRAME_DEFAULT); /* 25 for 2.5 ms frame */
if (status != 0)
{
naiif_printf("Error: naibrd_1553_BcFrameCreate status = %d", status);
return NAI_TRUE;
}
/* Create Call Subroutine Command 1 */
status = naibrd_1553_BcCmdCreate(devnum, OP4, NAIBRD_1553_OPCODE_CALL_SUBROUTINE, NAIBRD_1553_OPCODE_COND_ALWAYS, MNR1, 0, 0);
if (status != 0)
{
naiif_printf("Error: naibrd_1553_BcCommandCreate status = %d", status);
return NAI_TRUE;
}
/* Create Call Subroutine Command 2 */
status = naibrd_1553_BcCmdCreate(devnum, OP5, NAIBRD_1553_OPCODE_CALL_SUBROUTINE, NAIBRD_1553_OPCODE_COND_ALWAYS, MNR2, 0, 0);
if (status != 0)
{
naiif_printf("Error: naibrd_1553_BcCommandCreate status = %d", status);
return NAI_TRUE;
}
/* Create Call Subroutine Command 3 */
status = naibrd_1553_BcCmdCreate(devnum, OP6, NAIBRD_1553_OPCODE_CALL_SUBROUTINE, NAIBRD_1553_OPCODE_COND_ALWAYS, MNR3, 0, 0);
if (status != 0)
{
naiif_printf("Error: naibrd_1553_BcCommandCreate status = %d", status);
return NAI_TRUE;
}
/* Create Major Frame */
aOpCodes[0] = OP4; /* Minor Frame 1 */
aOpCodes[1] = OP6; /* Minor Frame 3 */
aOpCodes[2] = OP5; /* Minor Frame 2 */
aOpCodes[3] = OP6; /* Minor Frame 3 */
status = naibrd_1553_BcFrmCreate(devnum,MJR,NAIBRD_1553_BC_FRAME_MAJOR,aOpCodes,4,0, /* If frameTime is set here to a value */
NAIBRD_1553_BC_FRAME_DEFAULT); /* other than zero, this value will */
/* override the minor frame times that */
/* were set using the _BcFrameCreate() */
/* function and set all minor frame */
/* times to the same duration. */
if (status != 0)
{
naiif_printf("Error: naibrd_1553_BcFrameCreate status = %d", status);
return NAI_TRUE;
}
while (bContinue)
{
/* Load BC data block 1 with incremental data */
for (i = 0; i < WORDCOUNT1; i++)
{
aData[i] = increment++;
}
status = naibrd_1553_BcDataBlkWrite(devnum, DBLK1, aData, WORDCOUNT1, 0);
if (status != 0)
{
naiif_printf("Error: naibrd_1553_BcDataBlockWrite status = %d", status);
return NAI_TRUE;
}
/* Load BC data block 2 with 0x5566 */
for (i = 0; i < WORDCOUNT2; i++)
{
aData[i] = 0x5566;
}
status = naibrd_1553_BcDataBlkWrite(devnum, DBLK2, aData, WORDCOUNT2, 0);
if (status != 0)
{
naiif_printf("Error: naibrd_1553_BcDataBlockWrite status = %d", status);
return NAI_TRUE;
}
/* Load BC data block 3 with 0xBBCC */
for (i = 0; i < WORDCOUNT3; i++)
{
aData[i] = 0xBBCC;
}
status = naibrd_1553_BcDataBlkWrite(devnum, DBLK3, aData, WORDCOUNT3, 0);
if (status != 0)
{
naiif_printf("Error: naibrd_1553_BcDataBlockWrite status = %d", status);
return NAI_TRUE;
}
/* Start BC */
status = naibrd_1553_BcStart(devnum,MJR,NAIBRD_1553_BC_FRAME_RUN_FOREVER);
if (status != 0)
{
naiif_printf("Error: naibrd_1553_BcStart status = %d", status);
return NAI_TRUE;
}
naiif_printf("BC Running for approximately 10 seconds...\r\n");
/* Run the schedule for 10 seconds */
naibrd_msDelay(10000);
/* Stop BC (This call is not necessary here since transmission of the major frame should have completed by now) */
status = naibrd_1553_BcStop(devnum);
if (status != 0)
{
naiif_printf("Error: naibrd_1553_BcStop status = %d", status);
return NAI_TRUE;
}
do
{
status = naibrd_1553_BcGetActiveState(devnum, &outBCstate);
if (status != 0)
{
naiif_printf("Error: naibrd_1553_BcGetActiveState status = %d", status);
return NAI_TRUE;
}
naibrd_msDelay(100);
timeOutCount++; /* time out after 5 seconds */
} while((outBCstate == NAIBRD_1553_BC_STATE_BUSY) && (timeOutCount <= 50));
/* Get Decoded Msg Structure */
status = naibrd_1553_BcMsgGetByIdDecoded(devnum, MSG1, &DecodedMsgStruct, 1);
if (status < 0)
{
naiif_printf("Error: naibrd_1553_BcMsgGetByIdDecoded status = %d", status);
return NAI_TRUE;
}
else if (status > 0)
{
naiif_printf("Control Word: 0x%04X\r\n", DecodedMsgStruct.bcControlWord);
naiif_printf("Command Word: 0x%04X\r\n", DecodedMsgStruct.commandWord1);
naiif_printf("Block Status: 0x%04X\r\n", DecodedMsgStruct.blockStatus);
naiif_printf("Time Tag: 0x%04X\r\n", DecodedMsgStruct.timeTag);
naiif_printf("Word Count: 0x%04X\r\n", DecodedMsgStruct.dataWordCount);
naiif_printf("RT Status Word: 0x%04X\r\n", DecodedMsgStruct.status1);
naiif_printf("Data:");
for (i = 0; i < DecodedMsgStruct.dataWordCount; i++)
{
if (i % 8 == 0)
{
naiif_printf("\r\n");
}
naiif_printf("0x%04X ", DecodedMsgStruct.data[i]);
}
}
naiif_printf("\r\n\r\n");
/* Get Decoded Msg Structure */
status = naibrd_1553_BcMsgGetByIdDecoded(devnum, MSG2, &DecodedMsgStruct, 1);
if (status < 0)
{
naiif_printf("Error: naibrd_1553_BcMessageGetByIdDecoded status = %d", status);
return NAI_TRUE;
}
else if (status > 0)
{
naiif_printf("Control Word: 0x%04X\r\n", DecodedMsgStruct.bcControlWord);
naiif_printf("Command Word: 0x%04X\r\n", DecodedMsgStruct.commandWord1);
naiif_printf("Block Status: 0x%04X\r\n", DecodedMsgStruct.blockStatus);
naiif_printf("Time Tag: 0x%04X\r\n", DecodedMsgStruct.timeTag);
naiif_printf("Word Count: 0x%04X\r\n", DecodedMsgStruct.dataWordCount);
naiif_printf("RT Status Word: 0x%04X\r\n", DecodedMsgStruct.status1);
naiif_printf("Data:");
for (i = 0; i < DecodedMsgStruct.dataWordCount; i++)
{
if (i % 8 == 0)
{
naiif_printf("\r\n");
}
naiif_printf("0x%04X ", DecodedMsgStruct.data[i]);
}
}
naiif_printf("\r\n\r\n");
/* Get Decoded Msg Structure */
status = naibrd_1553_BcMsgGetByIdDecoded(devnum, MSG3, &DecodedMsgStruct, 1);
if (status < 0)
{
naiif_printf("Error: naibrd_1553_BcMessageGetByIdDecoded status = %d", status);
return NAI_TRUE;
}
else if (status > 0)
{
naiif_printf("Control Word: 0x%04X\r\n", DecodedMsgStruct.bcControlWord);
naiif_printf("Command Word: 0x%04X\r\n", DecodedMsgStruct.commandWord1);
naiif_printf("Block Status: 0x%04X\r\n", DecodedMsgStruct.blockStatus);
naiif_printf("Time Tag: 0x%04X\r\n", DecodedMsgStruct.timeTag);
naiif_printf("Word Count: 0x%04X\r\n", DecodedMsgStruct.dataWordCount);
naiif_printf("RT Status Word: 0x%04X\r\n", DecodedMsgStruct.status1);
naiif_printf("Data:");
for (i = 0; i < DecodedMsgStruct.dataWordCount; i++)
{
if (i % 8 == 0)
{
naiif_printf("\r\n");
}
naiif_printf("0x%04X ", DecodedMsgStruct.data[i]);
}
}
naiif_printf("\r\n\r\n");
naiif_printf("\r\nPress any key to send another message or Q to quit.");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (bQuit)
{
bContinue = NAI_FALSE;
}
}
}
}
}
/* Free 1553 Device */
status = naibrd_1553_Free(devnum);
if (status != 0)
{
naiif_printf("Error: naibrd_1553_Free status = %d", status);
return NAI_TRUE;
}
return bQuit;
}