Skip to main content
pierpaolo
Associate II
May 22, 2019 1:55 PM UTC
Question

USB CDC - Packets are lost on macOS

I'm using the P-NUCLEO-WB55 development board, with only USB (CDC Device) enabled/configured through the STM32CubeIDE.

I'm sending data from my laptop to the board over USB CDC (Virtual Com Port) in Full-Speed mode.

Specifically, my laptop is sending 1041 bytes, and I'm using the following (simple) Python script (it depends on pyserial):

import serial
 
s = serial.Serial('/dev/cu.usbmodem206F389630361 or COM3 or /dev/ttyACM0')
 
msg = bytearray(1041)
for i in range(0, len(msg)):
 msg[i] = 0xA5
 
print(s.write(msg))

When I run this script on Linux or Windows 10, everything works fine, i.e. the board receives the 1041 bytes sent by the laptop.

However, when I run this script on macOS, a lot of packets are lost. I'm not sure which ones specifically, but the board receives between 400 and 900 bytes instead of 1041.

Is it a macOS USB driver problem?

Any tips?

This topic has been closed for replies.

2 replies

waclawek.jan
Super User
May 22, 2019 2:59 PM UTC

> Is it a macOS USB driver problem?

Observing the traffic on the USB bus using an USB analyzer or a USB-decoding capable LA or oscilloscope, would reveal the truth quickly...

JW

AD.1
Visitor II
May 19, 2020 3:43 PM UTC

Bumping this, as it still an issue on MacOS not being able to send UART bytes to the microcontroller via the ST-LINK. If anyone has further information please share. This is very annoying.