22
22
# THE SOFTWARE.
23
23
24
24
# udev rules :
25
- # SUBSYSTEM=="block ", SUBSYSTEMS=="usb", MODE="0666", PROGRAM="/bin/sh -c 'echo $$ID_SERIAL_SHORT | rev | cut -c -8 | rev'", SYMLINK+="blkUSB_ %c.%s{bInterfaceNumber}"
26
- # SUBSYSTEM=="tty ", SUBSYSTEMS=="usb", MODE="0666", PROGRAM="/bin/sh -c 'echo $$ID_SERIAL_SHORT | rev | cut -c -8 | rev'", SYMLINK +="ttyUSB_ %c.%s{bInterfaceNumber}"
25
+ # ACTION=="add", SUBSYSTEM=="tty ", SUBSYSTEMS=="usb", MODE="0666", PROGRAM="/bin/sh -c 'echo $$ID_SERIAL_SHORT | rev | cut -c -8 | rev'", SYMLINK+="ttyUSB_ %c.%s{bInterfaceNumber}"
26
+ # ACTION=="add", SUBSYSTEM=="block ", SUBSYSTEMS=="usb", ENV{ID_FS_USAGE}=="filesystem", MODE="0666", PROGRAM="/bin/sh -c 'echo $$ID_SERIAL_SHORT | rev | cut -c -8 | rev'", RUN{program} +="/usr/bin/systemd-mount --no-block --automount=yes --collect $devnode /media/blkUSB_ %c.%s{bInterfaceNumber}"
27
27
28
28
import os
29
29
import sys
@@ -80,16 +80,16 @@ def test_cdc_dual_ports(id):
80
80
81
81
def test_cdc_msc (id ):
82
82
port = f'/dev/ttyUSB_{ id [- 8 :]} .00'
83
- block = f'/dev /blkUSB_{ id [- 8 :]} .02'
83
+ file = f'/media /blkUSB_{ id [- 8 :]} .02/README.TXT '
84
84
# Wait device enum
85
85
timeout = 10
86
86
while timeout :
87
- if os .path .exists (port ) and os .path .exists ( block ):
87
+ if os .path .exists (port ) and os .path .isfile ( file ):
88
88
break
89
89
time .sleep (1 )
90
90
timeout = timeout - 1
91
91
92
- assert os .path .exists (port ) and os .path .exists ( block ), \
92
+ assert os .path .exists (port ) and os .path .isfile ( file ), \
93
93
'Device not available'
94
94
95
95
# Echo test
@@ -100,18 +100,18 @@ def test_cdc_msc(id):
100
100
str = b"test_str"
101
101
ser1 .write (str )
102
102
ser1 .flush ()
103
- assert ser1 .read (100 ) == str , 'Port wrong data'
103
+ assert ser1 .read (100 ) == str , 'CDC wrong data'
104
104
105
105
# Block test
106
- f = open (block , 'rb' )
106
+ f = open (file , 'rb' )
107
107
data = f .read ()
108
108
109
109
readme = \
110
110
b"This is tinyusb's MassStorage Class demo.\r \n \r \n \
111
111
If you find any bugs or get any questions, feel free to file an\r \n \
112
112
issue at github.com/hathach/tinyusb"
113
113
114
- assert data [ 0x600 : 0x600 + len ( readme )] == readme , 'Block wrong data'
114
+ assert data == readme , 'MSC wrong data'
115
115
print ('cdc_msc test done' )
116
116
117
117
def test_dfu (id ):
0 commit comments