mirror of https://github.com/ARMmbed/mbed-os.git
Tests: USB: Fix Python 3 compatibility
Use integer division explicitly in basic test. Convert bytes to str for Python 3 in serial test.pull/11546/head
parent
c323af8417
commit
2b4b64fafd
|
@ -1376,7 +1376,7 @@ def ep_test_abort(dev, log, verbose=False):
|
|||
payload_size = (NUM_PACKETS_UNTIL_ABORT + NUM_PACKETS_AFTER_ABORT) * ep_out.wMaxPacketSize
|
||||
num_bytes_written = 0
|
||||
while num_bytes_written < payload_size:
|
||||
payload_out = array.array('B', (num_bytes_written/ep_out.wMaxPacketSize
|
||||
payload_out = array.array('B', (num_bytes_written//ep_out.wMaxPacketSize
|
||||
for _ in range(ep_out.wMaxPacketSize)))
|
||||
try:
|
||||
num_bytes_written += ep_out.write(payload_out)
|
||||
|
|
|
@ -24,6 +24,7 @@ import uuid
|
|||
import sys
|
||||
import serial
|
||||
import serial.tools.list_ports as stlp
|
||||
import six
|
||||
import mbed_host_tests
|
||||
|
||||
|
||||
|
@ -268,7 +269,7 @@ class USBSerialTest(mbed_host_tests.BaseHostTest):
|
|||
mbed_serial.reset_output_buffer()
|
||||
mbed_serial.dtr = True
|
||||
try:
|
||||
payload = mbed_serial.read(LINE_CODING_STRLEN)
|
||||
payload = six.ensure_str(mbed_serial.read(LINE_CODING_STRLEN))
|
||||
while len(payload) == LINE_CODING_STRLEN:
|
||||
baud, bits, parity, stop = (int(i) for i in payload.split(','))
|
||||
new_line_coding = {
|
||||
|
@ -277,7 +278,7 @@ class USBSerialTest(mbed_host_tests.BaseHostTest):
|
|||
'parity': self._PARITIES[parity],
|
||||
'stopbits': self._STOPBITS[stop]}
|
||||
mbed_serial.apply_settings(new_line_coding)
|
||||
payload = mbed_serial.read(LINE_CODING_STRLEN)
|
||||
payload = six.ensure_str(mbed_serial.read(LINE_CODING_STRLEN))
|
||||
except serial.SerialException as exc:
|
||||
self.log('TEST ERROR: {}'.format(exc))
|
||||
self.notify_complete(False)
|
||||
|
|
Loading…
Reference in New Issue