import msgpack import freetime.entity.msg msg = freetime.entity.msg.MsgPack() msg.setAction('start') packed_data = msgpack.packb(msg)
import msgpack import freetime.entity.msg msg = freetime.entity.msg.MsgPack() actions = ['start', 'stop', 'pause'] for action in actions: msg.setAction(action) packed_data = msgpack.packb(msg)In this example, the setAction function is used inside a loop to set the action field to a list of different values. The MsgPack message is then converted into binary format using the msgpack.packb function. The package library used in this example is 'msgpack' which is imported at the beginning of the code.