fcp package¶
Subpackages¶
Submodules¶
fcp.c_generator module¶
c-generator.
- Usage:
- c-generator.py generate <json> <template> <skel> <output> c-generator.py (-h | –help) c-generator.py –version
- Options:
- -h –help Show this screen. –version Show version.
fcp.can module¶
-
class
fcp.can.
CANMessage
(sid: int, dlc: int, timestamp: int, data16: List[int] = [], data64=-1)[source]¶ Bases:
object
-
static
decode_bstring
(bstring)[source]¶ Decode bytestring encoded message into CANMessage.
See encode_bstring for details on the string format used.
-
static
decode_json
(j)[source]¶ Decode JSON encoded message into CANMessage.
See encode_json for details on the JSON format used.
-
static
decode_struct
(s)[source]¶ Decode C struct encoded message into CANMessage.
See encode_struct for details on the struct format used.
-
encode_bstring
()[source]¶ Encode message as a utf-8 byte string encoded comma separated list of fields. Example: 100,8,1,2,3,4,1. Encodes sid: 100, dlc: 8, data[0]: 1, data[1]: 2, data[2]: 3, data[3]: 4, timestamp: 1
-
encode_json
()[source]¶ Encode message as a utf-8 byte string encoded JSON object. Example: {‘sid’: 100, ‘dlc’: 8, ‘data’: [1,2,3,4], ‘timestamp’: 1}
-
encode_struct
()[source]¶ Encode message as a CAN struct:
typedef struct { union { struct { uint16_t dev_id:5; // Least significant // First bit of msg_id determines if msg is reserved or not. // 0 == reserved (higher priority) (0-31 decimal) uint16_t msg_id:6; // Most significant }; uint16_t sid; }; uint16_t dlc:4; uint16_t data[4]; } CANdata;
-
static
fcp.dbc_reader module¶
fcp.dbc_writer module¶
fcp.docs module¶
fcp.docs_css module¶
fcp.generator module¶
fcp.gui module¶
-
class
fcp.gui.
ArgDetails
(gui, node: fcp.spec.Argument, parent)[source]¶ Bases:
fcp.gui.NodeDetails
-
staticMetaObject
= <PySide2.QtCore.QMetaObject object>¶
-
-
class
fcp.gui.
CfgDetails
(gui, node, parent)[source]¶ Bases:
fcp.gui.NodeDetails
-
staticMetaObject
= <PySide2.QtCore.QMetaObject object>¶
-
-
class
fcp.gui.
CfgWidget
(gui, parent)[source]¶ Bases:
PySide2.QtWidgets.QWidget
-
staticMetaObject
= <PySide2.QtCore.QMetaObject object>¶
-
-
class
fcp.gui.
CmdDetails
(gui, node, parent)[source]¶ Bases:
fcp.gui.NodeDetails
-
staticMetaObject
= <PySide2.QtCore.QMetaObject object>¶
-
-
class
fcp.gui.
CmdWidget
(gui, parent)[source]¶ Bases:
PySide2.QtWidgets.QWidget
-
staticMetaObject
= <PySide2.QtCore.QMetaObject object>¶
-
-
class
fcp.gui.
DeviceDetails
(gui, node: fcp.spec.Device, parent)[source]¶ Bases:
fcp.gui.NodeDetails
-
staticMetaObject
= <PySide2.QtCore.QMetaObject object>¶
-
-
class
fcp.gui.
DeviceWidget
(gui, node, details=None, layout=None)[source]¶ Bases:
fcp.gui.NodeDetails
-
staticMetaObject
= <PySide2.QtCore.QMetaObject object>¶
-
-
class
fcp.gui.
EnumDetails
(gui, node, parent)[source]¶ Bases:
fcp.gui.NodeDetails
-
staticMetaObject
= <PySide2.QtCore.QMetaObject object>¶
-
-
class
fcp.gui.
EnumValueDetails
(gui, node, parent)[source]¶ Bases:
fcp.gui.NodeDetails
-
staticMetaObject
= <PySide2.QtCore.QMetaObject object>¶
-
-
class
fcp.gui.
EnumWidget
(gui, parent)[source]¶ Bases:
PySide2.QtWidgets.QWidget
-
staticMetaObject
= <PySide2.QtCore.QMetaObject object>¶
-
-
class
fcp.gui.
Gui
(logger)[source]¶ Bases:
PySide2.QtWidgets.QMainWindow
-
staticMetaObject
= <PySide2.QtCore.QMetaObject object>¶
-
-
class
fcp.gui.
LogDetails
(gui, node, parent)[source]¶ Bases:
fcp.gui.NodeDetails
-
staticMetaObject
= <PySide2.QtCore.QMetaObject object>¶
-
-
class
fcp.gui.
LogWidget
(gui, parent)[source]¶ Bases:
PySide2.QtWidgets.QWidget
-
staticMetaObject
= <PySide2.QtCore.QMetaObject object>¶
-
-
class
fcp.gui.
MessageDetails
(gui, node: fcp.spec.Message, parent)[source]¶ Bases:
fcp.gui.NodeDetails
-
staticMetaObject
= <PySide2.QtCore.QMetaObject object>¶
-
-
class
fcp.gui.
MessageWidget
(gui, node: fcp.spec.Message, details=None, layout=None)[source]¶ Bases:
fcp.gui.NodeDetails
-
staticMetaObject
= <PySide2.QtCore.QMetaObject object>¶
-
-
class
fcp.gui.
NodeDetails
(gui, node, parent=None, details=None, layout=None)[source]¶ Bases:
PySide2.QtWidgets.QWidget
Node (Device, Message, Signal, Log, Config, Command) interface
-
staticMetaObject
= <PySide2.QtCore.QMetaObject object>¶
-
-
class
fcp.gui.
SignalDetails
(gui, node: fcp.spec.Signal, parent)[source]¶ Bases:
fcp.gui.NodeDetails
-
staticMetaObject
= <PySide2.QtCore.QMetaObject object>¶
-
-
class
fcp.gui.
SignalWidget
(gui, node, details=None, layout=None)[source]¶ Bases:
fcp.gui.NodeDetails
-
staticMetaObject
= <PySide2.QtCore.QMetaObject object>¶
-
fcp.spec module¶
-
class
fcp.spec.
Argument
(parent: Optional[fcp.spec.Command] = None, name: str = '', id: int = 0, comment: str = '')[source]¶ Bases:
object
Argument node. Represents a Command Argument.
Parameters: - name – Name of the Argument.
- id – Argument identifier.
- comment – description of the Argument.
-
compile
() → Dict[str, Any][source]¶ Transform python class node to its dictionary representation.
Returns: A dictionary containing the node parameters
-
class
fcp.spec.
Command
(parent: Optional[fcp.spec.Device] = None, name: str = '', n_args: int = 3, comment: str = '', id: int = 0, args: Dict[str, fcp.spec.Argument] = None, rets: Dict[str, fcp.spec.Argument] = None)[source]¶ Bases:
object
Command node. Represents a Command.
Parameters: - name – Name of the Command.
- n_args – Number of arguments in the Command.
- comment – description of the Command.
- id – Command identifier.
- args – Dictionary containing the Command’s input Arguments.
- rets – Dictionary containing the Command’s output Arguments.
-
add_arg
(arg: fcp.spec.Argument) → None[source]¶ Add a input Argument to Command.
Parameters: arg – Argument to be added Returns: Operation success status: True - Success, False - Failure
-
add_ret
(ret: fcp.spec.Argument) → None[source]¶ Add a output Argument to Command.
Parameters: ret – Argument to be added Returns: Operation success status: True - Success, False - Failure
-
compile
() → Dict[str, Any][source]¶ Transform python class node to its dictionary representation.
Returns: A dictionary containing the node parameters
-
class
fcp.spec.
Common
(parent: fcp.spec.Spec = None, name: str = 'common', id: int = 0, msgs: Dict[str, fcp.spec.Message] = None, cfgs: Dict[str, fcp.spec.Config] = None, cmds: Dict[str, fcp.spec.Command] = None)[source]¶ Bases:
object
-
compile
() → Dict[str, Any][source]¶ Transform python class node to its dictionary representation.
Returns: A dictionary containing the node parameters
-
-
class
fcp.spec.
Config
(parent: Optional[fcp.spec.Device] = None, name: str = '', id: int = 0, comment: str = '')[source]¶ Bases:
object
Config node. Represents a Config.
Parameters: - name – Name of the Config.
- id – Config identifier.
- comment – description of the Config.
-
compile
() → Dict[str, Any][source]¶ Transform python class node to its dictionary representation.
Returns: A dictionary containing the node parameters
-
class
fcp.spec.
Device
(parent: Optional[fcp.spec.Spec] = None, name: str = 'default_name', id: int = 0, msgs: Dict[str, fcp.spec.Message] = None, cmds: Dict[str, fcp.spec.Command] = None, cfgs: Dict[str, fcp.spec.Config] = None)[source]¶ Bases:
object
Device node, Represents a CAN device.
Parameters: - name – Name of the Device.
- id – FST Device identifier, lowest 5 bits of the identifier.
- msgs – Dictionary containing the Device messages.
- cmds – Dictionary containing the Device commands.
- cfgs – Dictionary containing the Device configs.
isn’t automatically sent.
-
add_msg
(msg: fcp.spec.Message) → bool[source]¶ Add a Message to Device.
Parameters: msg – Message to be added. Returns: Operation success status: True - Success, False - Failure
-
compile
() → Dict[str, Any][source]¶ Transform python class node to its dictionary representation.
Returns: A dictionary containing the node parameters
-
decompile
(d: Dict[str, Any]) → None[source]¶ Transform node dictionary representation into a python class.
Parameters: d – Node dictionary
-
get_cfg
(name: str) → Optional[fcp.spec.Config][source]¶ Get a Config from Device by its name.
Parameters: name – Config name. Returns: Config or None if not found.
-
get_cmd
(name: str) → Optional[fcp.spec.Command][source]¶ Get a Command from Device by its name.
Parameters: name – Command name. Returns: Command or None if not found.
-
get_msg
(name: str) → Optional[fcp.spec.Message][source]¶ Get a Message from Device by its name.
Parameters: name – Message name. Returns: Message or None if not found.
-
rm_cfg
(name: str) → bool[source]¶ Remove a Config from Device.
Parameters: name – Name of the Config to be removed.
-
rm_cmd
(name: str) → bool[source]¶ Remove a Command from Device.
Parameters: name – Name of the Command to be removed.
-
class
fcp.spec.
Enum
(parent: Optional[fcp.spec.Spec] = None)[source]¶ Bases:
object
Fcp Enum. C lookalike for FCP type definitions with name-value associations.
-
class
fcp.spec.
EnumValue
(parent: Optional[fcp.spec.Enum] = None)[source]¶ Bases:
object
Fcp EnumValue. C lookalike for FCP type definitions with name-value associations.
-
class
fcp.spec.
Log
(parent: Optional[fcp.spec.Spec] = None, id: int = 0, name: str = '', n_args: int = 3, comment: str = '', string: str = '')[source]¶ Bases:
object
Log protocol node.
Parameters: - id – Log integer identifier.
- name – Name of the Log node.
- n_args – Number of arguments in the Log node.
- comment – Description of the Log node
- string – Display string for the Log node.
-
compile
() → Dict[str, Any][source]¶ Transform python class node to its dictionary representation.
Returns: A dictionary containing the node parameters
-
class
fcp.spec.
Message
(parent: Optional[fcp.spec.Device] = None, name: str = '', id: int = 0, dlc: int = 8, signals: Dict[str, fcp.spec.Signal] = None, frequency: int = 0, description: str = '')[source]¶ Bases:
object
Message node, Represents a CAN message, similar to a DBC message.
Parameters: - name – Name of the Message.
- id – FST Message identifier, highest 6 bits of the identifier.
- dlc – Message DLC.
- signals – Dictionary containing the Message signals.
- frequency – Transmission period in millisecond. If 0 message
isn’t automatically sent.
-
add_signal
(signal: fcp.spec.Signal) → bool[source]¶ Add a Signal to Message.
Parameters: signal – Signal to be added Returns: Operation success status: True - Success, False - Failure
-
compile
() → Dict[str, Any][source]¶ Transform python class node to its dictionary representation.
Returns: A dictionary containing the node parameters
-
decompile
(d: Dict[str, Any]) → None[source]¶ Transform node dictionary representation into a python class.
Parameters: d – Node dictionary
-
get_signal
(name: str) → Optional[fcp.spec.Signal][source]¶ Get a Signal from Message by its name.
Parameters: name – Signal name. Returns: Signal or None if not found.
-
class
fcp.spec.
Signal
(parent: Optional[fcp.spec.Message] = None, name: str = '', start: int = 0, length: int = 0, scale: float = 1, offset: float = 0, unit: str = '', comment: str = '', min_value: int = 0, max_value: int = 0, type: str = 'unsigned', byte_order: str = 'little_endian', mux: str = '', mux_count: int = 1, alias: str = '')[source]¶ Bases:
object
Signal node. Represents a CAN signal, similar to a DBC signal.
Parameters: - name – Name of the Signal.
- start – Start bit
- length – Signal bit size.
- scale – Scaling applied to the signal’s data.
- offset – Offset applied to the signal’s data.
- unit – Unit of the Signal after applying scaling and offset.
- comment – Description of the Signal.
- min_value – Minimum value allowed to the Signal’s data.
- max_value – Maximum value allowed to the Signal’s data.
- type – Type of the Signal’s data.
- mux – Name of the mux Signal. None if the Signal doesn’t belong to a multiplexed Message.
- mux_count – Number of signals that the mux can reference for this Muxed signal.
-
compile
() → Dict[str, Any][source]¶ Transform python class node to its dictionary representation.
Returns: A dictionary containing the node parameters
-
class
fcp.spec.
Spec
[source]¶ Bases:
object
FCP root node. Holds all Devices, Messages, Signals, Logs, Configs, Commands and Arguments.
-
add_device
(device: fcp.spec.Device) → bool[source]¶ Add a Device to Spec.
Parameters: device – Device to be added Returns: Operation success status: True - Success, False - Failure
-
add_enum
(enum: fcp.spec.Enum) → bool[source]¶ Add a Enum to Spec.
Parameters: enum – Enum to be added Returns: Operation success status: True - Success, False - Failure
-
add_log
(log: fcp.spec.Log) → bool[source]¶ Add a Log to Spec.
Parameters: log – Log to be added Returns: Operation success status: True - Success, False - Failure
-
compile
() → Dict[str, Any][source]¶ Transform python class node to its dictionary representation.
Returns: A dictionary containing the node parameters
-
decompile
(d: Dict[str, Any]) → None[source]¶ Transform node dictionary representation into a python class.
Parameters: d – Node dictionary
-
get_device
(name: str) → Optional[fcp.spec.Device][source]¶ Get a Device from Spec by its name.
Parameters: name – Device name. Returns: Device or None if not found.
-
get_log
(name: str) → Optional[fcp.spec.Log][source]¶ Get a Log from Spec by its name.
Parameters: name – Log name. Returns: Log or None if not found.
-
rm_cmd
(command: fcp.spec.Command) → None[source]¶ Remove a Command from Spec.
Parameters: command – Command to be removed.
-
rm_config
(config: fcp.spec.Config) → None[source]¶ Remove a Config from Spec.
Parameters: config – Config to be removed.
-
rm_device
(device: fcp.spec.Device) → None[source]¶ Remove a Device from Spec.
Parameters: device – Device to be removed.
-
rm_enum_value
(enum_value)[source]¶ Remove a Enum from Spec.
Parameters: log – EnumValue to be removed.
-
-
fcp.spec.
decompose_id
(sid: int) → Tuple[int, int][source]¶ Find the dev_id and the msg_id from the sid.
fcp.template module¶
fcp.validator module¶
c-generator.
- Usage:
- validator.py validate <json> validator.py (-h | –help) validator.py –version
- Options:
- -h –help Show this screen. –version Show version.