Index: DialityCoreCanProtocol.py =================================================================== diff -u -rd1a60e7570580cb962c8031394e04c3995a73057 -r939a86a215a1a244e493c6455292d921a77698e3 --- DialityCoreCanProtocol.py (.../DialityCoreCanProtocol.py) (revision d1a60e7570580cb962c8031394e04c3995a73057) +++ DialityCoreCanProtocol.py (.../DialityCoreCanProtocol.py) (revision 939a86a215a1a244e493c6455292d921a77698e3) @@ -440,7 +440,6 @@ sys.stderr.write("Incorrect CRC, received message: {}, crc: {}, calculated crc: {}\n".format( self.__dialinMessageList, DenaliMessage.getCRC(complete_dialin_message), DenaliMessage.crc8(self.__dialinMessageList))) - pass if dialin_ch_id in self.__longMsgChannelIDSet: # We need to remove channel ID from the long message set @@ -535,7 +534,7 @@ return self.__dialinCommandResponseMessage -def test_print_received_packet(message, sync=False): +def tst_print_received_packet(message, sync=False): channel_id = message[0] message[0] = DenaliMessage.START_BYTE introduction = "Received: " @@ -546,22 +545,22 @@ print(introduction, message, " in channel: ", channel_id) -def test_print_to_screen(message): +def tst_print_to_screen(message): if message is None: print("Timeout!!!") else: - test_print_received_packet(message) + tst_print_received_packet(message) -def test_function_for_sync(message): - test_print_received_packet(message, sync=True) +def tst_function_for_sync(message): + tst_print_received_packet(message, sync=True) -def test_print_sending_dg_board(message): +def tst_print_sending_dg_board(message): print("Sending to board: ", message['message'], " in channel: ", message['channel_id']) -def test_print_sending_dg_sim(message): +def tst_print_sending_dg_sim(message): print("Sending to DG simulator: ", message['message'], " in channel", message['channel_id'], end=" ---> ") @@ -573,15 +572,15 @@ test_received_message_id = 0x100 test_messenger.registerReceivingPublicationFunction(test_received_channel_id, test_received_message_id, - test_function_for_sync) + tst_function_for_sync) test_dg_simulator_received_channel_id = DenaliChannels.dialin_to_dg_ch_id test_dg_simulator_sync_msg_id = 0x05 test_dg_simulator_msg_id = 0x03 test_messenger.registerReceivingPublicationFunction(test_dg_simulator_received_channel_id, test_dg_simulator_sync_msg_id, - test_function_for_sync) + tst_function_for_sync) test_messenger.start() @@ -593,21 +592,21 @@ payload=[]) sleep(3.0) - test_print_sending_dg_board(test_msg) + tst_print_sending_dg_board(test_msg) test_response = test_messenger.send(test_msg) - test_print_to_screen(test_response) + tst_print_to_screen(test_response) sleep(3.0) - test_print_sending_dg_board(test_msg) + tst_print_sending_dg_board(test_msg) test_response = test_messenger.send(test_msg) - test_print_to_screen(test_response) + tst_print_to_screen(test_response) sleep(3.0) - test_print_sending_dg_sim(test_dg_msg) + tst_print_sending_dg_sim(test_dg_msg) test_response = test_messenger.send(test_dg_msg) - test_print_to_screen(test_response) + tst_print_to_screen(test_response) sleep(3.0) - test_print_sending_dg_sim(test_dg_msg) + tst_print_sending_dg_sim(test_dg_msg) test_response = test_messenger.send(test_dg_msg) - test_print_to_screen(test_response) + tst_print_to_screen(test_response) Index: DialysateGenerator.py =================================================================== diff -u -r921425cec163072566cf7d269474c4f28f9725c4 -r939a86a215a1a244e493c6455292d921a77698e3 --- DialysateGenerator.py (.../DialysateGenerator.py) (revision 921425cec163072566cf7d269474c4f28f9725c4) +++ DialysateGenerator.py (.../DialysateGenerator.py) (revision 939a86a215a1a244e493c6455292d921a77698e3) @@ -26,10 +26,6 @@ """ -def PublicationReceiverHandler(message): - print(".", end='', flush=True) - - class DG: """ \class DG @@ -59,7 +55,8 @@ self.__can_interface = DenaliCanMessenger(can_interface=can__interface) self.__can_interface.registerReceivingPublicationFunction(channel_id=DenaliChannels.dg_sync_broadcast_ch_id, message_id=self.DG_MSG_ID_BROADCAST, - function=PublicationReceiverHandler) + function=( + lambda message: print(".", end='', flush=True))) self.__can_interface.start() def fill(self, start_or_stop='start'): @@ -70,7 +67,6 @@ \returns True if ran the command, False otherwise, returns None if timeout """ - payload = [1] if start_or_stop == 'start' else [0] msg = DenaliMessage.buildMessage(channel_id=DenaliChannels.hd_to_dg_ch_id, @@ -87,30 +83,27 @@ return returnValue -def test_fill_print(msg): - if msg is not None: - print("f", end='', flush=True) - else: - print("t", end='', flush=True) +def test_dg_start(): + dg = DG() + sleep(2) + resp = dg.fill('start') + test_passed = isinstance(resp, bool) + if test_passed: + print("DG started and DG response is {}".format(test_passed)) -if __name__ == "__main__": - test_dg = DG() + assert test_passed + +def test_dg_stop(): + dg = DG() + sleep(1) + dg.fill('start') sleep(2) - test_packet = test_dg.fill('start') - test_fill_print(test_packet) + resp = dg.fill('stop') + test_passed = isinstance(resp, bool) - sleep(10) - test_packet = test_dg.fill('stop') - test_fill_print(test_packet) + if test_passed: + print("DG started/stopped and DG response is {}".format(test_passed)) -# del test_dg - -# sleep(1) -# test_packet = test_dg.fill('start') -# test_fill_print(test_packet) - -# sleep(2) -# test_packet = test_dg.fill('start') -# test_fill_print(test_packet) + assert test_passed