#############################################################################
# Copyright (c) 2002-2021 MBARI
# Monterey Bay Aquarium Research Institute, all rights reserved.
#############################################################################
import lcm

from test.TestUtils import *


def test_publish_lcm(lc=lcm.LCM()):

    pub = LcmPublisher(lc)
    data = read_file()
    data.pop(0)  # drop first line

    channel_name = 'BackSeatDriver'
    var_name = 'bsd_command'
    cmd = 'shutdown'  # 'shutdown' | 'quit'

    print("Publishing BSD msg # {}".format(pub.seq_number))
    pub.clear_msg()
    pub.add_variable(var_name, cmd)
    pub.timestamp()
    pub.publish(channel_name)


if __name__ == "__main__":

    test_publish_lcm()
