Thread: Control BaudRate USB port

  1. #1
    carpe diem
    Join Date
    Jan 2010
    Posts
    46

    Control BaudRate USB port

    I need to output a stream of binary data at a constant rate to a USB port. I am using Windows7, I can connect and send the data to the USB port but what I just can't control is the frequency at which the data is sent. Does anybody know any functions I can use so I can control the baud rate of data getting into a USB port?
    Do I need to use a Real Time OS?

  2. #2
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,743
    This seems like a really good article on the subject:

    Embedded.com - An Introduction to USB Development

    Sorry I'm not an expert at communicating through USB ports myself, but my guess is that it'd be hard to get a guaranteed data transfer rate if you're not on a real-time OS...simply because your subject to the scheduling of the operating system.

    Can you say what kind of app your working on? Is constant rate 100% necessary?

    [EDIT]

    Shameless plug:

    http://sine.ni.com/nips/cds/view/p/lang/en/nid/2381

    [/EDIT]
    My Website

    "Circular logic is good because it is."

  3. #3
    carpe diem
    Join Date
    Jan 2010
    Posts
    46
    The stream of data needs to be recognized by a device that expects data in a specific format and specific frequency so constant rate is absolutely necessary - up to a 3% deviation is acceptable.
    Is there a way I can increase my driver/thread priority through my code so that the timing of the data won't be as suceptible to Windows scheduling?

    PS: Thanks for the article!

  4. #4
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,059
    No idea about Windows but on *nix systems, it's sort of

    1. open() the USB device using its device file
    2. create a structure object of type struct termios
    3. call tcgetattr() to obtain the current port options
    4. set the input baud rate with a call to cfsetispeed()
    5. set the output baud rate with a call to cfsetospeed().

    Hopefully you can find something similar on Windows

  5. #5
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    USB has no "baud rate." If you need data to be transmitted at a particular rate, then... transmit it at that rate. I'm not sure what your question is.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  6. #6
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,059
    The USB will have a baud rate if it is hooked to a serial port interface, which is what I thought the op had in mind when s/he posted the question. Guess the op will have to clarify what's exactly goin' on.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Comodo Firewall Vulnerability (Port 0)
    By Mario F. in forum Tech Board
    Replies: 0
    Last Post: 11-11-2009, 08:56 AM
  2. Parallel Port to USB controller and outb()
    By coletek in forum Linux Programming
    Replies: 1
    Last Post: 06-05-2009, 06:57 AM
  3. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 05:49 PM
  4. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 06:23 AM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM