Share
By default, all messages for RTs, SAs, and TRs are legal. BusTools_RT_CbufWrite can be used to make a message illegal. This does not automatically filter-out these messages to the RT. What it does is allow the message to come through, but sets the Message Error (ME) bit in the interrupt status word. The ME bit in the 16-bit message status returned to the BC is also set. If there is a Message Error, only status is returned to the BC, not data. This allows the RT to know when the BC is sending illegal messages. To make a message or word count legal or illegal, you must change the corresponding bit value stored in cbuf.legal_wordcount.
Bit 0 controls operations for a message with 32 words (which is actually a word count entry of "0"). Bit 1 controls operations for a message with 1 word. Bit 2 controls operations for a message with 2 words. ****** Bit 30 controls operations for a message with 30 words. Bit 31 controls operations for a message with 31 words.If you wanted to legalize, say, word count 22, the following value would be stored in "legal_wordcount": (Bit ordering is always Little Endian)
0000 0000 0100 0000 0000 0000 0000 0000 or 0x00400000.The following code would do just that:
cbuf.legal_wordcount = 0x00400000; // legalize word count of only 22 status = BusTools_RT_CbufWrite(cardnum,RT_ADDR,SUB_ADDR, TR,RT_MBUF_COUNT,&cbuf);
This changes only the legal_wordcount for the specific RT_ADDR, SUB_ADDR, and TR settings. All other RTs, SAs, and TRs still have the default condition of all counts legal. If you want only word count 22 in a specific RT, SA, TR setting legal, you must program all other RT, SA, TR settings with no legal word counts by setting the legal_wordcount to 0x0 for all other RT, SA, TR settings. Here's an example of setting legal_wordcount of 22 for one RT while setting no legal word counts on all other RTs:
for ( rt = 0; rtIf you set the legal_wordcount to 22 for RT_ADDR, SUB_ADDR, for both transmit and receive, when the BC sends a message with another word count, the status response has the Message Error (ME) bit (bit 10) set. In addition, the BC receives no data on transmit messages. The Message Error bit in the interrupt status (BT1553_INT_ME_BIT 0x08000000) is also set. This could prompt an action such as setting the service request bit. The RT needs to check the interrupt status of the incoming messages and process only error-free messages. You can check this status for a Message Error (BT1553_INT_ME_BIT 0x08000000.) The code below show how you might check messages for a Message Error.
status = BusTools_RT_MessageRead(cardnum,rtaddr,subaddr, transrec,messno,&mbuf); if (status) return status; if(mbuf.status & BT1553_INT_ME_BIT) { // this is a illegal command } else . . .The only bit in the interrupt status field that is set on a valid 1553 message is BT1553_INT_END_OF_MESS. If any other bit is set, there is some type of problem. You can use the following to test the interrupt status word for errors.
if(mbuf.status & ~BT1553_INT_END_OF_MESS) { // Something is wrong } else . . .Of course, how you handle Message Errors or any other type of 1553 error is application dependent. But you need to check these the interrupt status on each message to know if there are any errors.