########################################################################### # # Copyright (c) 2021-2024 Diality Inc. - All Rights Reserved. # # THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN # WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. # # @file test_dg_thermistors.py # # @author (last) Peter Lucia # @date (last) 21-May-2021 # @author (original) Peter Lucia # @date (original) 30-Apr-2021 # ############################################################################ import numpy as np import sys from time import sleep sys.path.append("../../") from dialin import DGSimulator from dialin.protocols.CAN import DenaliMessage, DenaliChannels from dialin.common import MsgIds from dialin.utils.conversions import integer_to_bytearray, float_to_bytearray def run(): dg_sim = DGSimulator(log_level="DEBUG") while True: onboard_temp = np.random.randint(0, 65535) power_supply_1 = np.random.randint(0, 65535) power_supply_2 = np.random.randint(0, 65535) payload = float_to_bytearray(onboard_temp) payload += float_to_bytearray(power_supply_1) payload += float_to_bytearray(power_supply_2) message = DenaliMessage.build_message(channel_id=DenaliChannels.dg_sync_broadcast_ch_id, message_id=MsgIds.MSG_ID_DG_THERMISTORS_DATA.value, payload=payload) dg_sim.can_interface.send(message, 0) sleep(1) if __name__ == '__main__': run()