def make_msg(code, data=None, to_slave_addr=2, from_host_addr=1):
    """Makes a ccTalk message from a ccTalk code and data to be sent with this packet.

    Parameters
    ----------
    code : int
      ccTalk code for this message.
    data : list of integers
      Data to be sent in this message.
    to_slave_addr : int
      Address of slave to be sent to.  Defaults to 2.
    from_host_addr : int
      Address of host that is sending the message.  Defaults to 1.

    Returns
    -------
    packet : list of integers
      An integer equivalent of the ccTalk packet.
      This needs to be converted to a byte packet prior to sending.
    """
    if not data:
        seq = [to_slave_addr, 0, from_host_addr, code]
    else:
        seq = [to_slave_addr, len(data), from_host_addr, code] + data
    packet_sum = 0
    for i in seq:
        packet_sum += i
    end_byte = 256 - (packet_sum%256)
    packet = seq + [end_byte]
    return packet