title: How can I set a custom baud rate on Linux?
body: <p>I want to communicate over my serial port on Linux to a device with a non-standard-baud rate that is not defined in <code>termios.h</code>.</p>
  
  <p>I tried the "baud rate aliasing"-method from <a href="https://stackoverflow.com/a/7152671/1707026">this post</a>, but when I execute my C-program (I’ve named it "testprogram"), Linux says <code>"testprogram sets custom speed on ttyS0. This is deprecated."</code></p>
  
  <p>I did some search on Google, and it seems that there is another (newer?) method to change the baud rate to a non-standard-value: On <a href="http://sourceware.org/ml/libc-help/2009-06/msg00016.html" rel="nofollow noreferrer">http://sourceware.org/ml/libc-help/2009-06/msg00016.html</a> the author says that the <code>c_flag</code> of <code>struct termios</code> must be OR’d with <code>BOTHER (=CBAUDEX | B0)</code>.</p>
  
  <p>With this method the baud rates are set directly in the <code>c_ispeed</code> and <code>c_ospeed</code>-members of the <code>struct termios</code>. However, I don’t know how I use this method in my C program. Like the author said, there is no <code>BOTHER</code> defined/available when I include <code>termios.h</code>, so what should be done to set the baud rate this way?</p>
  
  <p>How can I set the baud rate to a non-standard-value without changing the kernel?</p>