# Frame Box

## FrameBox

class canlib.kvadblib.FrameBox(db, messages=())

  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 or `Message` 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 the `messages` constructor argument or with `add_message`. Likewise, any methods that return signals require the signal’s message to have been added.

  add_message(message)

    Add a message to the framebox

    The message will be available for all future uses of `FrameBox.message` and `FrameBox.messages`, and all its signals will be available for uses of `FrameBox.signal` and `FrameBox.signals`.

    The `message` argument can either be a message name, or a `canlib.kvadblib.Message` object.

  frames()

    Iterate over all frames of the signals/messages from this `FrameBox`

  message(name)

    Retrieves a message by name

    Returns a `BoundMessage` that shares its `canlib.Frame` object with its child signals.

  messages()

    Iterator over all messages that this `FrameBox` is aware of

  signal(name)

    Retrieves a signal by name

    Returns a `BoundSignal` that shares its `canlib.Frame` object with its parent message and sibling signals.

  signals()

    Iterator over all signals that this `FrameBox` is aware of

## BoundMessage

class canlib.kvadblib.BoundMessage(message, frame)

  A CAN data object that manipulates data through signals.

## BoundSignal

class canlib.kvadblib.BoundSignal(signal, frame)
  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` or `float`

  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.