Documentation search search close
CONTENTS
https://www.speedgoat.com/help/slrt/page/icon_documentation.jpg
v10.0.1.x for R2026a
View other versions

speedgoat.can.DbParserBlockConfig

speedgoat.can.DbParserBlockConfig — Create a DB Parser Block Config instance

Description

This DB Parser Block Config class constructs a class object for interacting with a CAN DB Parser Read or Write block in Simulink®. The Config instance is connected to the specified block. Upon construction, it checks for instances of the CAN DB Parser Read or Write application — these must be closed to proceed.

Several methods are available to retrieve or modify settings relevant to the functionality of instance the connected DB Parser block; these methods operate on the data managed by the Config class itself. Only after applying or saving the Config instance is data passed to the connected DB Parser block.

Syntax

Get a DB Parser Block Config instance for a specified CAN DB Parser Read or Write block:

configObj = speedgoat.can.DbParserBlockConfig(blockPath)

Get the value for one or more specified parameters:

configObj.getParameter(parameter1,...,parameterN)

Set the value for one or more specified parameters:

configObj.setParameter(parameter1,value1,...,parameterN,valueN)

Select or update from a .dbc file previously configured using the Database Manager:

configObj.selectDatabase(databaseName, ignoreMissingItems)

Refresh the list of Simulink input signals on the input port of the connected CAN DB Parser Write block:

configObj.refreshSimulinkInputSignals()

Add a predefined or custom CRC Message Protection profile:

configObj.addCrcProfile(label, type, customFile, customFunction)

Remove a CRC Message Protection profile:

configObj.removeCrcProfile(label)

Add a Counter Message Protection profile:

configObj.addCounterProfile(label, startValue, stopValue, stepValue, bitLength)

Remove a Counter Message Protection profile:

configObj.removeCounterProfile(label)

Get message structure for a specified message identifier: messages = configObj.getMessage(messageIdentifier, value)

Enable or disable one or more messages:

configObj.setEnable(messages, action)

Get mapping item structure for a specified mapping item identifier: mappingItems = configObj.getMappingItems(itemIdentifier, value)

Map one or more input items (Simulink input signals or Message Protection profiles) to corresponding mapping items:

configObj.setMapping(inputSignals, mappingItems)

Save persistent data to the connected CAN DB Parser Read or Write block without applying changes:

configObj.save()

Apply the mapping to the connected CAN DB Parser Read or Write block and save persistent data:

configObj.apply(ignoreMissingInputSignals)

Delete the DB Parser Block Config instance without saving persistent data or applying changes to the connected CAN DB Parser Read or Write block:

configObj.delete()

Examples

Get a DB Parser Block Config instance and connect it to the currently selected CAN DB Parser Read or Write block in a loaded Simulink model:

configObj = speedgoat.can.DbParserBlockConfig(gcb)

Get a DB Parser Block Config instance and connect it to the specified CAN DB Parser Read or Write block in a loaded Simulink model:

configObj = speedgoat.can.DbParserBlockConfig('myModel/CAN DB Parser Write 1')

Get the sample time of the connected CAN DB Parser Read or Write block:

sampleTime = configObj.getParameter('SampleTime')

Get the list of available Simulink input signals:

inputSignals = configObj.getParameter('SimulinkInputSignals')

Get the module ID of the selected CAN and LIN Setup block:

moduleId = configObj.getParameter('ModuleId')

Get the struct of all CAN messages for the selected .dbc file:

dbItems = configObj.getParameter('Messages')

Get the table of all .dbc file options and the currently selected .dbc file:

databaseConfiguration = configObj.getParameter('DatabaseOptions', 'SelectedDatabase')

Set the module ID to select the CAN and LIN Setup block:

configObj.setParameter('ModuleId', 2)

Set the module type and ID to select the CAN and LIN Setup block and the sample time:

configObj.setParameter('ModuleType', 'IO602-4', 'ModuleId', '1', 'SampleTime', '0.01')

Set the Setup block path directly to select the CAN and LIN Setup block:

configObj.setParameter('SetupBlock', 'myModel/CAN and LIN Setup 1')

Set the block port type to change the way Simulink input signals are input to the CAN DB Parser Write block or output for the CAN DB Parser Read block:

configObj.setParameter('BlockPortType', 'Signals')

Select or update from a .dbc file previously configured using the Database Manager (must be available in the DatabaseOptions parameter of the DB Parser Block Config instance):

configObj.selectDatabase('myDatabase')

Refresh the list of Simulink input signals on the input port of the connected CAN DB Parser Write block:

configObj.refreshSimulinkInputSignals()

Add a predefined CRC message protection profile with a specified label:

configObj.addCrcProfile('CRC_1_8-bit', 'CRC8-SAEJ1850')

Add a custom CRC message protection profile with a specified label (refer to the usage notes for more detailed information about custom CRC message protection):

configObj.addCrcProfile('CRC_2_12-bit', 'Custom', 'custom_crc.cpp', 'custom_crc_func')

Remove a CRC message protection profile using its label:

configObj.removeCrcProfile('CRC_1_12-bit')

Add a Counter message protection profile with a specified label:

configObj.addCounterProfile('Counter_1_8-bit', 0, 255, 2, 8)

Remove a Counter message protection profile using its label:

configObj.removeCounterProfile('Counter_1_8-bit')

Get message structure for CAN messages with a specified ID:

messages = configObj.getMessage('ID', 257)

Get message structure for CAN messages with a specified message name:

messages = configObj.getMessage('Name', 'CANMsg1')

Get message structure for CAN messages which contain a signal with a specified signal name:

messages = configObj.getMessage('SignalName', 'CANSignal1')

Get message structure for all CAN messages in the selected .dbc file:

messages = configObj.getMessage('All')

Set enabled state for a specified message structure:

configObj.setEnable(messages(1:end), true)

Get mapping items structure for CAN messages with a specified ID:

mappingItems = configObj.getMappingItems('ID', 257)

Get mapping items structure of items which contain a signal with a specified signal name:

mappingItems = configObj.getMappingItems('SignalName', 'CANSignal1')

Get mapping items structure of items which have been mapped to a specific Simulink input signal or message protection profile:

mappingItems = configObj.getMappingItems('MappedSignal', 'CRC_1_8-bit')

Get mapping items structure of all enabled items:

mappingItems = configObj.getMappingItems('All')

Map one Simulink input signal to a specified mapping items structure element:

configObj.setMapping('simulink.signal', mappingItems(1))

Map each Simulink input signal to a single mapping item:

configObj.setMapping(inputSignals(1:5), mappingItems(1:5))

Clear the mapping for a mapping item by mapping it to 'Ground(0)':

configObj.setMapping('Ground(0)', mappingItems(1))

Clear the mapping for all mapping items by mapping them to 'Ground(0)':

configObj.setMapping('Ground(0)', mappingItems)

Apply the mapping to the connected CAN DB Parser Read or Write block and save persistent data:

configObj.apply()

Save persistent data to the connected CAN DB Parser Read or Write block without applying changes:

configObj.save()

Delete the DB Parser Block Config instance without saving persistent data or applying changes to the connected CAN DB Parser Read or Write block:

configObj.delete()

Input Arguments

'blockPath' - Path to a CAN DB Parser Read or Write Simulink block [character vector | string]. The path to a CAN DB Parser Read or Write block in a loaded Simulink model file.

Output Arguments

'configObj' – Instance of the DB Parser Block Config class [DbParserBlockConfig] The DB Parser Block Config instance initialized for interacting with the specified CAN DB Parser Read or Write block. The block remains connected to the Config instance until the Config instance is deleted.

Notes

This constructor requires a loaded Simulink model with at least one CAN and LIN Setup block and one CAN DB Parser Read or Write block.