1import stl_path
2from trex_stl_lib.api import *
3
4import time
5
6def simple ():
7
8    # create client
9    #verbose_level = LoggerApi.VERBOSE_HIGH
10    c = STLClient(verbose_level = LoggerApi.VERBOSE_REGULAR)
11    passed = True
12
13    try:
14        # connect to server
15        c.connect()
16
17        my_ports=[0,1]
18
19        # prepare our ports
20        c.reset(ports = my_ports)
21
22        print((" is connected {0}".format(c.is_connected())))
23
24        print((" number of ports {0}".format(c.get_port_count())))
25        print((" acquired_ports {0}".format(c.get_acquired_ports())))
26        # port stats
27        print(c.get_stats(my_ports))
28        # port info
29        print(c.get_port_info(my_ports))
30
31        c.ping()
32        profile_file = os.path.join(stl_path.STL_PROFILES_PATH, 'udp_1pkt_simple.py')
33
34        print("start")
35        c.start_line (" -f %s -m 10mpps --port 0 1 " % profile_file)
36        time.sleep(2);
37        c.pause_line("--port 0 1");
38        time.sleep(2);
39        c.resume_line("--port 0 1");
40        time.sleep(2);
41        c.update_line("--port 0 1 -m 5mpps");
42        time.sleep(2);
43        c.stop_line("--port 0 1");
44
45    except STLError as e:
46        passed = False
47        print(e)
48
49    finally:
50        c.disconnect()
51
52    if passed:
53        print("\nTest has passed :-)\n")
54    else:
55        print("\nTest has failed :-(\n")
56
57
58# run the tests
59simple()
60
61