Why is the USB_VCP module gone?

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Why is the USB_VCP module gone?

Post by dhylands » Sun Sep 14, 2014 8:09 am

bittware wrote:
dhylands wrote:USB_VCP has no concept of baud rate. It isn't needed.

When you connect to usb_serial, the baud rate that you use is ignored. You only need a baud rate with a UART.
I know REPL needs baud rate of 115200 which is fixed by design.
However, once I need USB_VCP for other purpose, e.g. customized data transmission, then I need to lower this baud rate in order to interface the communication software running on PC. This software communication does not support baud rate of 115200.
USB Serial doesn't work that way. If I open it at 115200 or 9600 baud it doesn't matter (I just verified that too). The USB serial is communicating at Full Speed (12 Mbits/sec) and the serial baud rate is a meaningless number. Yes, the device may be sending data faster than the host can receive. But that's what flow control is for, and that's something you need to design into your transfer protocol.

It doesn't matter what baud rate you open the usb serial port with, the data will arrive at the same 12 Mbits/sec. I think you're confusing USB Serial adapters, which do have a physical UART attached on the other end, and the baud rate you use on the USB serial link is forwarded to that physical serial port.

With USB_VCP there is no physical serial port. It's all virtual. baud rate doesn't matter.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Why is the USB_VCP module gone?

Post by dhylands » Sun Sep 14, 2014 8:17 am

And if you still don't believe me here's the code. When the host sets a baud rate, it sends a CDC_SET_LINE_CODING message, and guess what happens in the firmware when we receive that:
https://github.com/micropython/micropyt ... ace.c#L217
absolutely nothing. The firmware ignores all of the parameters because they aren't needed.

When the host queries the baud rate (CDC_GET_LINE_CODING), the firmware picks an arbitrary number, 115200 in this case, and reports back that this is the baud rate being used:
https://github.com/micropython/micropyt ... ace.c#L228

bittware
Posts: 45
Joined: Mon Aug 18, 2014 3:27 am

Re: Why is the USB_VCP module gone?

Post by bittware » Sun Sep 14, 2014 1:01 pm

dhylands wrote:
bittware wrote:
dhylands wrote:USB_VCP has no concept of baud rate. It isn't needed.

When you connect to usb_serial, the baud rate that you use is ignored. You only need a baud rate with a UART.
I know REPL needs baud rate of 115200 which is fixed by design.
However, once I need USB_VCP for other purpose, e.g. customized data transmission, then I need to lower this baud rate in order to interface the communication software running on PC. This software communication does not support baud rate of 115200.
USB Serial doesn't work that way. If I open it at 115200 or 9600 baud it doesn't matter (I just verified that too). The USB serial is communicating at Full Speed (12 Mbits/sec) and the serial baud rate is a meaningless number. Yes, the device may be sending data faster than the host can receive. But that's what flow control is for, and that's something you need to design into your transfer protocol.

It doesn't matter what baud rate you open the usb serial port with, the data will arrive at the same 12 Mbits/sec. I think you're confusing USB Serial adapters, which do have a physical UART attached on the other end, and the baud rate you use on the USB serial link is forwarded to that physical serial port.

With USB_VCP there is no physical serial port. It's all virtual. baud rate doesn't matter.
Yes. This is so true. I've verified it. Thanks for your thorough analysis. I learned something new. :-)

Post Reply