1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

tests/can_gateway: Make travis happy

This commit is contained in:
Jannes 2020-08-24 10:24:52 +02:00
parent d48e7b6d49
commit edd21af875
4 changed files with 23 additions and 16 deletions

View File

@ -1,4 +1,4 @@
APPLICATION = can_gateway
include ../Makefile.tests_common
BOARD ?= native

View File

@ -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);

View File

@ -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()

View File

@ -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):