MX Foundation 4
Periodic Update Message Service

Channels 5 to 132 have the sub-class MXF_SCLASS_RT_CHANNEL, which allows setting a user response in transmission. All the channels are directly coupled to the user addresses 0 to 127 respectively.

The Periodic Update Message Service allows a message for a specified buffer to be refreshed. The mxfASCBTxPeriodicUpdateMsgWrite() function is used to refresh the data of a specific buffer.

For the User, the Periodic Update Message Service is useful to update the data for each of its side and alternate.

Every time an user transmits a message, the associate message in the message queue will be sent. By default, the messages for all sides and alternate are initialized to zero. If the message is not updated, 0 will be sent on the bus. When all messages of a buffer have been sent, the last message will be repeated indefinitely while the message queue is no longer updated.

The message refreshing does not start until the user is enabled. The mxfASCBUserEnableSet() function is used to enable the user.

Each side (left and right) of user and alternate may be enabled/disabled as required. By default, the bus left and right are disabled for each alternate, i.e. the user does not respond to any BC requests. (See the mxfASCBUserBusEnableSet() function)

Refer to the MXF_ASCB_DATAREC structure for data updating.

Periodic message updating step:

MXF_ASYNCEVENT_COND_TXPERIODIC_UPDATEMSG_BUFFER_THRESHOLD event condition can be registered so a callback handler can be automatically called when the number of messages of a buffer falls below a determined threshold.

uint32 rc;
HMXF_CHANNEL users[2];
HMXF_BUFFER tx[3];
uint32 txBufferSize=0;
MXF_ASCB_DATAREC* txBuffer=NULL;
MXF_ASCBDATAREC* txRecAscb;
uint64 bus=0;
...
// Allocates buffer for tx data
if(!rc)
{
txBufferSize = sizeof(MXF_ASCB_DATAREC);
// For user alternate 0
rc = mxfTxPeriodicUpdateMsgBufferAlloc(users[0], 0, txBufferSize, &tx[0], NULL);
// For user alternate 3
if(!rc)
rc = mxfTxPeriodicUpdateMsgBufferAlloc(users[0], 3, txBufferSize, &tx[1], NULL);
// For other user, no alternate
if(!rc)
rc = mxfTxPeriodicUpdateMsgBufferAlloc(users[1], 0, txBufferSize, &tx[2], NULL);
// Host allocation
if(!rc)
{
txBuffer = (MXF_ASCB_DATAREC*)malloc(txBufferSize);
if(!txBuffer)
rc = MAXT_ERROR_MEM;
}
}
// Assign buffer
if(!rc)
{
rc = mxfASCBUserBusEnableSet(users[0], 0, 0, tx[0]);
if(!rc)
rc = mxfASCBUserBusEnableSet(users[0], 0, 3, tx[1]);
if(!rc)
rc = mxfASCBUserBusEnableSet(users[1], 0, -1, tx[2]);
}
// Sets default users[1]
if(!rc)
{
txRecAscb = txBuffer;
//--- Set data on the first 6 bytes (remaining bytes will be 0) ---//
memset(txRecAscb, 0, sizeof(MXF_ASCB_DATAREC));
txRecAscb->repeatCount = 1;
txRecAscb->dataSize = 6
txRecAscb->data[0] = 0x4000;
txRecAscb->data[1] = 0x2222;
txRecAscb->data[2] = 0x3333;
rc = mxfASCBTxPeriodicUpdateMsgWrite(users[1], 1, txBuffer);
}
// Starts messages queues
if(!rc)
{
printf("Starting USERS\n\r");
rc = mxfASCBUserEnableSet(users[0], TRUE);
if(!rc)
rc = mxfASCBUserEnableSet(users[1], TRUE);
}
...
// Stops USERS
if(!rc)
rc = mxfASCBUserEnableSet(users[0], FALSE);
if(!rc)
rc = mxfASCBUserEnableSet(users[1], FALSE);
printf("\nStopping USERS\n\r");
// Unassign buffer
if(!rc)
{
rc = mxfASCBUserBusEnableSet(users[0], 0, 0, 0);
if(!rc)
rc = mxfASCBUserBusEnableSet(users[0], 0, 3, 0);
if(!rc)
rc = mxfASCBUserBusEnableSet(users[1], 0, -1, 0);
}
...

ascb_user.c

Updated 10/23/2023