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.
BoundMessage¶
BoundSignal¶
- class canlib.kvadblib.BoundSignal(signal, frame)[source]¶
- property is_enum¶
Whether this signal is an enum-signal
New in version 1.7.
- Type
bool
- property name¶
Signal’s name string
- Type
str
- property phys¶
Signal’s physical value
- Type
intorfloat
- property raw¶
Signal’s raw value
- Type
int
- property unit¶
Signal’s unit string
- Type
str
- property value¶
Signal’s value
If the signal is an enum-signal (i.e. the signal has a defined value table), then the enum name is returned if found, otherwise the signals raw value (
raw) is returned. If the signal is not an enum-signal, the signals physical value (phys) is returned.New in version 1.7.