LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 01-15-2011, 03:02 AM   #1
mensfort
LQ Newbie
 
Registered: Nov 2010
Location: Eindhoven, NL
Distribution: Ubuntu
Posts: 5

Rep: Reputation: 0
Unhappy Why is 6400 baud not supported!


Hi,

I desperately want to get away from DOS and Windows, change to Linux... however I need 6400 baud for a special dongle.

I found out my PC is working in Windows perfect at this baudrate, but in Linux it is unsupported.

termios.h seems to have no support. I'm programming in C++ and want to use 6400 baud.

With setserial software I can have a divisor of 18, then the baudrate = 115200/18 = 6400. However, I want to use it in my programs (G++) and maybe also in Dosbox until my program is completely converted to Linux... however, if Linux does NOT support 6400 baud this operating system I have to stick to MFC, which is terrible.

Who has a decent solution to this?
 
Old 01-15-2011, 06:57 AM   #2
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 10,882
Blog Entries: 1

Rep: Reputation: 1307Reputation: 1307Reputation: 1307Reputation: 1307Reputation: 1307Reputation: 1307Reputation: 1307Reputation: 1307Reputation: 1307Reputation: 1307
Moved: This thread is more suitable in Programming and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 01-15-2011, 06:59 AM   #3
business_kid
Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 5,953

Rep: Reputation: 496Reputation: 496Reputation: 496Reputation: 496Reputation: 496
Why not change the dongle design? Or are you circumventing proprietary code?
 
Old 01-15-2011, 10:04 PM   #4
wje_lq
Member
 
Registered: Sep 2007
Location: Mariposa
Distribution: Debian lenny, Slackware 12
Posts: 806

Rep: Reputation: 161Reputation: 161
Quote:
Originally Posted by business_kid View Post
are you circumventing proprietary code?
We don't need to know the answer to this question, because what mensfort needs to do here is the same, regardless of whether he's circumventing proprietary code.

I found a hint here. I haven't tested the following code, but it ought to compile in both Microsoft(spit)(R) and Linux environments. Will something like this do the trick?
Code:
#if defined(__GLIBC__)
#include <asm/ioctls.h>
#include <linux/serial.h>
#endif

/* ... */

#if defined(__GLIBC__)
struct serial_struct cheerios;
#endif

/* ... */

#if defined(__GLIBC__)
if(ioctl(your_file_descriptor_here,TIOCGSERIAL,&cheerios))
{
  /* Handle error here. */
}
cheerios.flags&=(~ASYNC_SPD_MASK);
cheerios.flags|=(ASYNC_SPD_CUSTOM);
cheerios.custom_divisor=(115200/6400);
if(ioctl(your_file_descriptor_here,TIOCSSERIAL,&cheerios))
{
  /* Handle error here. */
}
#else
/* Do whatever one does in the Microsoft(spit)(R) world. */
#endif
The link mentioned above hints that before you use TIOC[GS]SERIAL, you should call tcsetattr() and set c_cflag to B38400. I'm not convinced that this is necessary, but if the above code doesn't work by itself, try adding this additional stuff first.

Hope this helps.
 
  


Reply

Tags
dosbox, hardware, serial port


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I make the baud rate be configured automatically? corone Linux - Server 6 11-03-2010 01:47 PM
SF Thinstation redirected com port baud rate JoDee Linux - Software 0 09-11-2006 12:25 PM
Change the network baud rate zaheer031 Linux - Software 1 05-15-2006 11:37 PM
Reading Baud Rate of Serial Port zaheer031 Programming 1 09-27-2004 12:47 PM
rs232 at non-standard baud rate possible? scgadgets Programming 1 09-14-2001 08:27 PM


All times are GMT -5. The time now is 08:25 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration