diff --git a/tests/can_gateway/Makefile b/tests/can_gateway/Makefile index cc68e0695e..a9240e0db0 100644 --- a/tests/can_gateway/Makefile +++ b/tests/can_gateway/Makefile @@ -1,4 +1,4 @@ -APPLICATION = can_gateway +include ../Makefile.tests_common BOARD ?= native diff --git a/tests/can_gateway/can_gateway.c b/tests/can_gateway/can_gateway.c index d7850964d6..41a9ea6cfd 100644 --- a/tests/can_gateway/can_gateway.c +++ b/tests/can_gateway/can_gateway.c @@ -659,7 +659,7 @@ static int _add_can_id(int argc, char **argv) } if (list_counter >= ID_LIST_COUNT) { - DEBUG("_add_can_id: List ist full!\n"); + DEBUG("_add_can_id: List is full!\n"); return -1; } else { uint32_t can_id = strtoul(argv[2], NULL, 16); diff --git a/tests/can_gateway/tests/config_gateway.py b/tests/can_gateway/tests/config_gateway.py index d27cbb5bb8..5ed3dd619c 100644 --- a/tests/can_gateway/tests/config_gateway.py +++ b/tests/can_gateway/tests/config_gateway.py @@ -8,7 +8,6 @@ import argparse import connect_if -import time DEFAULT_INPUT = 'None' DEFAULT_BAUDRATE = 115200 @@ -18,36 +17,38 @@ DEFAULT_SAMPLE_POINT = 875 DEFAULT_CAN_INTERFACE = 0 DEFAULT_CONFIG_FILE = 'configIPv6.json' + def main_func(): p = argparse.ArgumentParser() p.add_argument("-p", "--port", type=str, default=DEFAULT_PORT, - help="Set serial port, default: %s" % DEFAULT_PORT) + help="Set serial port, default: %s" % DEFAULT_PORT) p.add_argument("-b", "--baudrate", type=int, default=DEFAULT_BAUDRATE, - help="Set baudrate of the serial port, default: %d" % DEFAULT_BAUDRATE) + help="Set baudrate of the serial port, default: %d" % DEFAULT_BAUDRATE) p.add_argument("-i", "--input", type=str, default=DEFAULT_INPUT, - help="possible input: [add_config], [set_bitrate], [can_recv], [can_recv_stop]") + help="possible input: [add_config], [set_bitrate], [can_recv], [can_recv_stop]") p.add_argument("-br", "--bitrate", type=int, default=DEFAULT_BITRATE, - help="Set CAN bitrate, default: %d" %DEFAULT_BITRATE) + help="Set CAN bitrate, default: %d" % DEFAULT_BITRATE) p.add_argument("-sp", "--sample_point", type=int, default=DEFAULT_SAMPLE_POINT, - help="Set CAN sample point, default: %d" %DEFAULT_SAMPLE_POINT) + help="Set CAN sample point, default: %d" % DEFAULT_SAMPLE_POINT) p.add_argument("-if", "--interface", type=int, default=DEFAULT_CAN_INTERFACE, - help="Set CAN interface, default: %d" %DEFAULT_CAN_INTERFACE) + help="Set CAN interface, default: %d" % DEFAULT_CAN_INTERFACE) p.add_argument("-cf", "--config_file", type=str, default=DEFAULT_CONFIG_FILE, - help="Set config file, default: %s" %DEFAULT_CONFIG_FILE) + help="Set config file, default: %s" % DEFAULT_CONFIG_FILE) args = p.parse_args() connection = connect_if.Connect(port=args.port, baud=args.baudrate) if args.input == 'add_config': - device = connection.add_config(config_file=args.config_file) + connection.add_config(config_file=args.config_file) elif args.input == 'set_bitrate': - device = connection.can_set_bitrate(iface=args.interface, bitrate=args.bitrate, sample_point=args.sample_point) + connection.can_set_bitrate(iface=args.interface, bitrate=args.bitrate, sample_point=args.sample_point) elif args.input == 'can_recv': - device = connection.can_recv() + connection.can_recv() elif args.input == 'can_recv_stop': - device = connection.can_recv_stop() - else : + connection.can_recv_stop() + else: print("Nothing to do") + if __name__ == "__main__": main_func() diff --git a/tests/can_gateway/tests/connect_if.py b/tests/can_gateway/tests/connect_if.py index 477b5662eb..5248d4dcfd 100644 --- a/tests/can_gateway/tests/connect_if.py +++ b/tests/can_gateway/tests/connect_if.py @@ -12,6 +12,7 @@ import json DEFAULT_SLEEP_TIME = 0.01 + class Connect: def __init__(self, port, baud): @@ -23,7 +24,12 @@ class Connect: with open("{}".format(config_file)) as json_file: data = json.load(json_file) for entry in data['Entries']: - self.__dev.write("can_gateway add_id {} {} {} {} {} {}\n".format(entry['can_id'],entry['dst_port'],entry['ip_addr'],entry['eth_send'],entry['dst_ifnum'],entry['src_ifnum']).encode()) + self.__dev.write("can_gateway add_id {} {} {} {} {} {}\n".format(entry['can_id'], + entry['dst_port'], + entry['ip_addr'], + entry['eth_send'], + entry['dst_ifnum'], + entry['src_ifnum']).encode()) time.sleep(DEFAULT_SLEEP_TIME) def can_set_bitrate(self, iface, bitrate, sample_point):