File tree 6 files changed +21
-46
lines changed
6 files changed +21
-46
lines changed Original file line number Diff line number Diff line change 1
1
import sys
2
+ import time
2
3
import string
3
4
import random
5
+ import pytest
4
6
import serial .tools .list_ports
7
+ from msg import tiny_frame
5
8
from msg import proto_i2c_msg as pm
9
+ from msg import proto_ctrl_msg as ctrl_pm
6
10
7
11
8
12
def print_error (* args , ** kwargs ):
@@ -18,6 +22,17 @@ def get_com_port() -> str:
18
22
raise Exception ("No Serial Port found!" )
19
23
20
24
25
+ @pytest .fixture ()
26
+ def serial_port ():
27
+ with serial .Serial (get_com_port (), 115200 , timeout = 1 ) as ser :
28
+ tiny_frame .tf_init (ser .write )
29
+ ctrl_pm .CtrlInterface .send_system_reset_msg ()
30
+ time .sleep (2 )
31
+
32
+ with serial .Serial (get_com_port (), 115200 , timeout = 1 ) as ser :
33
+ yield ser
34
+
35
+
21
36
def generate_ascii_data (min_size : int , max_size : int ) -> bytes :
22
37
size = random .randint (min_size , max_size )
23
38
tx_data = '' .join (random .choice (string .ascii_letters + string .digits ) for _ in range (size ))
Original file line number Diff line number Diff line change 4
4
"""
5
5
6
6
import pytest
7
- import serial
8
7
from msg import tiny_frame
9
8
from msg import proto_gpio_msg as pm
10
- from helper import get_com_port
11
-
12
-
13
- @pytest .fixture ()
14
- def serial_port ():
15
- with serial .Serial (get_com_port (), 115200 , timeout = 1 ) as ser :
16
- yield ser
9
+ from helper import serial_port
17
10
18
11
19
12
class TestGpio :
20
- REQUEST_COUNT = 1000
13
+ REQUEST_COUNT = 10000
21
14
22
15
def setup_class (self ):
23
16
self .reverse = False
Original file line number Diff line number Diff line change 3
3
""" Testing I2c master write/read
4
4
"""
5
5
6
- import pytest
7
- import serial
8
6
from msg import tiny_frame
9
7
from msg import proto_i2c_msg as pm
10
- from helper import (get_com_port , generate_master_write_read_requests ,
8
+ from helper import (serial_port , generate_master_write_read_requests ,
11
9
i2c_send_master_request , verify_master_write_read_requests )
12
10
13
11
14
- @pytest .fixture ()
15
- def serial_port ():
16
- with serial .Serial (get_com_port (), 115200 , timeout = 1 ) as ser :
17
- yield ser
18
-
19
-
20
12
class TestI2cMaster :
21
13
REQUEST_COUNT = 4 * 1000
22
14
DATA_SIZE_MIN = 1
Original file line number Diff line number Diff line change 4
4
"""
5
5
6
6
import pytest
7
- import serial
8
7
from msg import tiny_frame
9
8
from msg import proto_i2c_msg as pm
10
- from helper import (get_com_port , generate_master_write_read_requests ,
9
+ from helper import (serial_port , generate_master_write_read_requests ,
11
10
i2c_send_master_request , verify_master_write_read_requests )
12
11
13
12
14
- @pytest .fixture ()
15
- def serial_port ():
16
- with serial .Serial (get_com_port (), 115200 , timeout = 1 ) as ser :
17
- yield ser
18
-
19
-
20
13
class TestI2cMasterSlave :
21
14
REQUEST_COUNT = 4 * 1000
22
15
DATA_SIZE_MIN = 1
Original file line number Diff line number Diff line change 3
3
""" Testing I2c slave write and read memory updates (no physical I2c communication involved)
4
4
"""
5
5
6
- import pytest
7
- import serial
8
6
import random
9
7
from msg import tiny_frame
10
8
from msg import proto_i2c_msg as pm
11
- from helper import get_com_port , generate_ascii_data
12
-
13
-
14
- @pytest .fixture ()
15
- def serial_port ():
16
- with serial .Serial (get_com_port (), 115200 , timeout = 1 ) as ser :
17
- yield ser
9
+ from helper import serial_port , generate_ascii_data
18
10
19
11
20
12
class TestI2cSlave :
Original file line number Diff line number Diff line change 3
3
""" Testing USB communication with tinyframe in a loop
4
4
"""
5
5
6
- import pytest
7
- import serial
8
- import time
9
6
from msg import tiny_frame
10
- from msg import proto_ctrl_msg as ctrl_pm
11
- from helper import get_com_port , generate_ascii_data
12
-
13
-
14
- @pytest .fixture ()
15
- def serial_port ():
16
- with serial .Serial (get_com_port (), 115200 , timeout = 1 ) as ser :
17
- yield ser
7
+ from helper import serial_port , generate_ascii_data
18
8
19
9
20
10
def tiny_frame_receive_cb (_ , tf_msg ):
You can’t perform that action at this time.
0 commit comments