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.Frame
object.Objects are created by giving them a
Dbc
database, and optionally a list of messages (either names orMessage
objects):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
channel
with:for frame in framebox.frames(): channel.write(frame)
Any
Framebox
methods that return messages requires the message to have been added to the framebox, either with themessages
constructor 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.message
andFrameBox.messages
, and all its signals will be available for uses ofFrameBox.signal
andFrameBox.signals
.The
message
argument can either be a message name, or acanlib.kvadblib.Message
object.
- message(name)[source]¶
Retrieves a message by name
Returns a
BoundMessage
that shares itsFrame
object with its child signals.
- signal(name)[source]¶
Retrieves a signal by name
Returns a
BoundSignal
that shares itsFrame
object 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
int
orfloat
- 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.