USB CDC : how can the firmware determine what baud rate etc. is being emulated


+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    2,374
    Thumbs Up
    Received: 87
    Given: 183
    Total Downloaded
    5.30 GB

    0 Not allowed!

    Default USB CDC : how can the firmware determine what baud rate etc. is being emulated

    Playing with the idea of remote serial via USB.
    George.

  2. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #2
    Senior Member tumbleweed's Avatar
    Join Date
    May 2011
    Posts
    542
    Thumbs Up
    Received: 61
    Given: 0
    Total Downloaded
    503.53 MB

    0 Not allowed!

    Default Re: USB CDC : how can the firmware determine what baud rate etc. is being emulated

    The USB CDC SET_LINE_CODING request message (0x20) is used to configure the baud rate, stop-bits, parity, and number of data bits.

  4. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #3
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    2,374
    Thumbs Up
    Received: 87
    Given: 183
    Total Downloaded
    5.30 GB

    0 Not allowed!

    Default Re: USB CDC : how can the firmware determine what baud rate etc. is being emulated

    Hi Tumbleweed, oh that sounds good. Any hints as to how to use this function appreciated.
    Last edited by towlerg; 30th August 2017 at 14:25.
    George.

  6. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  7. #4
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    2,374
    Thumbs Up
    Received: 87
    Given: 183
    Total Downloaded
    5.30 GB

    0 Not allowed!

    Default Re: USB CDC : how can the firmware determine what baud rate etc. is being emulated

    I did a little reading on the subject, I think I understand the principle but not the application. I think send a particular sequence of bytes to a particular end point and ger back the baud rate etc. I compiled the CDC example and found this code snippet. Can I just all this code rather than for the buffer and tx?

    Code:
    USBCHECKCDCREQUEST3
        movlw cSET_LINE_CODING
        cpfseq USB_aSetupPkt + cUSB_bRequest
        bra __USB_CHECKCDCREQUEST7
        movlw cLINE_CODING_LENGTH
        movwf USB_wOutCount
        clrf USB_wOutCountH
        movlw (USB_aLineCoding & 0XFF)
        movwf USB_wDst
        movlw ((USB_aLineCoding >> 8) & 0XFF)
        movwf USB_wDstH
        bsf USB_bOutFo,cUSB_Busy
        return
    Seems a little odd that all the other similar labels were prebended with a double underscore.
    George.

  8. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  9. #5
    Senior Member tumbleweed's Avatar
    Join Date
    May 2011
    Posts
    542
    Thumbs Up
    Received: 61
    Given: 0
    Total Downloaded
    503.53 MB

    1 Not allowed!

    Default Re: USB CDC : how can the firmware determine what baud rate etc. is being emulated

    George,

    I'm not 100% up on the inner workings of the stack, but it looks like that little snippet is where the driver recognizes the SET_LINE_CODING request and gets ready to copy the data from the packet into the 7-byte array defined in USB_MemAlloc.inc
    Code:
        Dim USB_aLineCoding[cLINE_CODING_LENGTH] As Byte At USB_aCtrlTrfData + cUSB_EP0_BUFF_SIZE
    
    '
    ' USB_aLineCoding Byte and Bit Aliases
    '
        $define cUSB_dwDTERate   0                           ' Complex data structure
        $define cUSB_bCharFormat 4
        $define cUSB_bParityType 5
        $define cUSB_bDataBits   6
    After a SET_LINE_CODING command that array should contain the baudrate (4 bytes at index 0), stop bits (1 byte at index 4), parity (1 byte at index 5), and data bits (1 byte at index 6) settings. You should be able to get the data from there.

  10. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  11. #6
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    2,374
    Thumbs Up
    Received: 87
    Given: 183
    Total Downloaded
    5.30 GB

    0 Not allowed!

    Default Re: USB CDC : how can the firmware determine what baud rate etc. is being emulated

    Now why didn't I think of that.

    Edit. actually my problem wasn't understanding the data returned it was with the byte sequence and the endpoint (which I believe is 0) to tx to.

    I tried adding this to an otherwise working CDC program but it hangs

    Code:
    ' hangs if this is encluded        
    '        Clear Array1
    '        Array1 = cGET_LINE_CODING , 0, cLINE_CODING_LENGTH, 0, 0, 0, 0, 0                   ' Fill the string with Null terminated characters
        
    '        Repeat
    '            USBOut 0, Array1, Auto             
    '        Until Carry_Flag = 0                            ' Keep trying if the microcontroller does not have control over the buffer
    Last edited by towlerg; 31st August 2017 at 15:38.
    George.

  12. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Baud rate problem
    By charliecoultas in forum Proton 24
    Replies: 13
    Last Post: 26th January 2019, 08:48
  2. [SOLVED !] Hi Baud Rate Project
    By nat in forum Proton Plus Compiler v3
    Replies: 4
    Last Post: 5th March 2011, 15:48
  3. Baud rate
    By pepito in forum quickBlue Bluetooth Development
    Replies: 4
    Last Post: 19th July 2007, 23:41
  4. baud rate
    By ADLIN SYSTEMS in forum USBWiz
    Replies: 7
    Last Post: 13th August 2006, 09:41
  5. [SOLVED !] Rs 232 baud rate
    By jackjay2 in forum Wish List / Product Feedback
    Replies: 4
    Last Post: 19th September 2004, 10:14

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts