Serial over USB speed

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Serial over USB speed

Post by Tectu »

Hey there,

I borrowed some code from one of the examples in the demos folder to use the SDU driver. I packed everything neatly in a file which works just fine. What I reallydon't see is where I can set the baud rate. The SD driver does take this over the config struct you pass as the second parameter of sdStart(). However, the sdu config struct does only contain a pointer to the USB driver and the USB config struct dosen't seem to have a direct baud setting.
Can someone tell me how I can set a certain baud rate?


Thanks in advance,

~ Tectu
jscott
Posts: 129
Joined: Tue Jul 03, 2012 3:50 pm

Re: Serial over USB speed

Post by jscott »

Tectu,

in this case baud rate does not apply.

It is not a serial port in the traditional way.
it is a couple of drivers and configurations parameters that allow us
to send and receive data with our app in the same way we would
interact with a serial port.

On the stm32f4 I get about 900,000 bytes per second which comes
out to about 9mbaud.

-John Scott
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: Serial over USB speed

Post by Tectu »

Thank you very much for your reply, jscott.

When I want to connect to the new device on my host machine (on Linux I get a /dev/ttyACMx, Windows would be COMx), I need to set the traditional serial parameters like baud rate, parity, data and stop bits. I never tried it, but I guess it won't work when I set another baud rate? I'm currently running at a baud rate of 38400 (which I knew is the default of the SD driver).
How exactly did you get 9M? I took the example from one of the STM32F103 directories in the demos folder.


~ Tectu
jscott
Posts: 129
Joined: Tue Jul 03, 2012 3:50 pm

Re: Serial over USB speed

Post by jscott »

Tectu,

As I understand it, the baud rate is completely ignored. Both on the stm32 and the PC.
You should be able to test this by setting the PC baud rate to 300baud and see what happens.

I tested my speed by writing a shell command that output 100,000 lines of 100 characters.
I then timed it with my watch and did the math.

You can see my entire project template at: http://www.atl123.com/chibios-rt/project-software.html

Or if you don't want to look the whole template over, here is the shell command code that I used:

Code: Select all


void cmd_puke(BaseSequentialStream *chp, int argc, char *argv[])
{
    size_t n;

    (void)argv;
    if (argc > 0)
    {
        chprintf(chp, "Usage: mem\r\n");
        return;
    }
    for( n = 0; n < 100000; n++)
    {
        palSetPad(GPIOD, GPIOD_PIN9);
        chprintf(chp, "dp9HWE98fhhfHS(FH*HS(*hf9H(hf98H(S*hf9*HS(8fh(*HS9f8h(*FH98HF98h(*HF98we(&^^HFW&FWYF&GWfsrgergergr\r\n");
        palClearPad(GPIOD, GPIOD_PIN9);
    }
}


-John Scott
skute
Posts: 64
Joined: Wed Aug 29, 2012 10:17 pm

Re: Serial over USB speed

Post by skute »

Greetings,

For USB-CDC serial, the CDC spec provides a set line coding class specific command (6.3.10 SetLineCoding of CDC spec). This encapsulates the baud rate that would be used if you were actually making a usb-serial converter and has no impact on the usb transfer speed.
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: Serial over USB speed

Post by Tectu »

Okay, I just checked the thing with changing the baud rate and indeed, the thing works at all configurations :)
Thank you very much for your help, guys!


~ Tectu
Post Reply