Frame Box¶
FrameBox¶
-
class
canlib.kvadblib.FrameBox(db, messages=())[source]¶ Helper class for sending signals
This class allows sending signals without worrying about what message they are defined in. It does this by binding a message and all its signals to the same
canlib.Frameobject.Objects are created by giving them a
Dbcdatabase, and optionally a list of messages (either names orMessageobjects):db = Dbc(...) framebox = FrameBox(db, messages=('Msg0','Msg1'))
Messages can also be added after instantiation with
add_message:framebox.add_message('Msg0', 'Msg1')
Then setting signal values for any added message is done with:
framebox.signal('Sig0').phys = 7 framebox.signal('Sig1').phys = 20
Once all values are set, they can easily be sent via the channel
channelwith:for frame in framebox.frames(): channel.write(frame)
Any
Frameboxmethods that return messages requires the message to have been added to the framebox, either with themessagesconstructor argument or withadd_message. Likewise, any methods that return signals require the signal’s message to have been added.-
add_message(message)[source]¶ Add a message to the framebox
The message will be available for all future uses of
FrameBox.messageandFrameBox.messages, and all its signals will be available for uses ofFrameBox.signalandFrameBox.signals.The
messageargument can either be a message name, or acanlib.kvadblib.Messageobject.
-
message(name)[source]¶ Retrieves a message by name
Returns a
BoundMessagethat shares itscanlib.Frameobject with its child signals.
-
signal(name)[source]¶ Retrieves a signal by name
Returns a
BoundSignalthat shares itscanlib.Frameobject with its parent message and sibling signals.
-