MX Foundation 4
Attributes

CAN bus parameters such as bus speed and bus state can be read or modified using specific CAN bus functions:

Other attributes, like FIFO aging timeout or threshold can be read or modified using the mxfAttributeUint64Get(), mxfAttributeDoubleGet(), mxfAttributeUint64Set() and mxfAttributeDoubleSet() functions, passing the handle (device, module or channel) and attribute key-value pair.

See the section Attributes Reference for a description of all supported attributes.

Some other utility functions are used for getting more information about attributes;

The following code shows how to configure an CAN channel speed at 500Kbps and enabled it.

{
HMXF_SERVER server; // Server handle
HMXF_DEVICE device; // Device handle
HMXF_MODULE module; // Module handle
HMXF_CHANNEL channel; // Channel handle
uint64 deviceIdx = 0; // Device index #0
uint64 moduleType = MXF_MODULE_CANBUS; // CAN module
uint64 moduleCount;
uint32 rc;
MXF_CANBUS_TIMING timing; // CAN timing
//Connects to the server
rc=mxfServerConnect("0.0.0.0", "", "", 0, &server);
//MXF initialization
if (!rc)
rc = mxfSystemInit(server);
//Obtains the first device handle
if(!rc)
rc = mxfSystemDeviceGet(server, deviceIdx, &device);
//Obtains the first module handle
if(!rc)
rc = mxfDeviceModuleAllGet(device, moduleType, 1, &moduleCount, &module);
//Obtains first channel handle
if(!rc && moduleCount)
rc = mxfModuleChannelGet(module, 0, &channel);
//Sets the channel speed to 500Kbps with sampling point at 75%
if(!rc)
{
timing.options = 0; // reserved
timing.sjw = 1; // sync each bit
timing.sampTriple = 0; // sample once each bit
timing.brp = 4; // prescaler (clock 64MHz)
timing.tseg1 = 11; // quanta before sampling point
timing.tseg2 = 4; // quanta after sampling point
rc = mxfCanBusTimingSet(channel, &timing);
}
//Sets the bus state to enabled
if(!rc)
rc = mxfCanBusStateSet(channel, TRUE);
}
Updated 10/23/2023