Solved

COM Port Data Rate

Posted on 2002-05-13
14
384 Views
Last Modified: 2013-11-15
Is there a way to set the data rate for a COM port without using SetCommState and a DCB structure? That call seems to take a long time, and i'm looking for a way to set the data rate with a call that returns as fast as possible.
0
Comment
Question by:0x100
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 2
  • +4
14 Comments
 
LVL 49

Expert Comment

by:DanRollins
ID: 7007544
That is the only way to set the baud rate.  

If that takes too long, you should redesign your program so that it does not need to change the baud rate so often.

-- Dan
0
 

Author Comment

by:0x100
ID: 7007584
I only need to change it once (when my program starts). But it's a time sensitive operation. I need to do other things immediatley. Should I just put it in a thread?
0
 
LVL 4

Expert Comment

by:mblat
ID: 7007707
I find it strange that setting baud rate take any signifficunt time comparatevly to whole process of starting up application....

Yes, you can put it in separate thread, but then you have to make sure that you are not using comm. port BEFORE your thread have finished doing whatever it needs to do...

Still main question here - why does it take so long?  An what it is - "too long"?  Seconds? Minutes? What platform (computer/OS/compiler) are you using?
0
Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

 
LVL 49

Expert Comment

by:DanRollins
ID: 7007754
I think that you are overrating how long the SetCommState call is taking.  Put a breakpoint on it and use the debugger to step over it.  I'm sure it takes a fraction of a second.

I suppose you could set all of the defaults (in the Device Manager).  In that case, the CreateFile call will presumably start out with the the desired defaults.

I might be possible that TAPI is monitoring the COM port (because you have fax software running or something) and that when you change the port settings, settings TAPI must do a bunch of stuff to prevent the fax software (or whatever) from messing up.

-- Dan
0
 

Author Comment

by:0x100
ID: 7007863
i have no software accessing the port. the call to SetCommState takes about 2 seconds. If that's normal, i'll just live with it, but it seems abnormally high considering the speed at which other functions work.
0
 
LVL 4

Expert Comment

by:havman56
ID: 7007912
hi

hyperterminal is there with windows machine to acees the com port . use it!

it is very simple all windows packages support hyper terminal.

0
 
LVL 11

Expert Comment

by:griessh
ID: 7008376
>>SetCommState takes about 2 seconds

That sounds waaaaayy too long. Something else is going on ...

======
Werner
0
 
LVL 32

Expert Comment

by:jhance
ID: 7008737
I think you are doing something wrong.

Show your code for opening the COM port and setting the bit rate.
0
 
LVL 6

Expert Comment

by:DrDelphi
ID: 7009413
2 seconds is an ETERNITY for SetCommState. There must be something else happening in your code, or possibly on the system. Is there any fax service application or something similar that may be holding the port?


0
 
LVL 49

Accepted Solution

by:
DanRollins earned 50 total points
ID: 7009505
Other than fax software:  If you have set your computer to act as a host for dial-up networking, that would also cause TAPI to hold a lock on the port.  

Try some tests to see if you have the same problem setting the data rate for COM2 (some port that has no modem attached).

-- Dan
0
 
LVL 6

Expert Comment

by:DrDelphi
ID: 7009520
Good thought!
0
 

Author Comment

by:0x100
ID: 7012686
not exactly but it was TAPI related
thanks sir
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7012754
Hi 0x100,
Thanks for accepting.  

To satisfy my curiosity and to help those who later purchase this PAQ, would you mind briefly describing what exactly solved this problem?  Thanks!

-- Dan
0
 

Author Comment

by:0x100
ID: 7012894
I just realized that I had some old TAPI software on my computer. It was this TAPI based answering machine program (i'm pretty sure). I recently changed the port my modem was plugged in to and didn't change the settings in the program. I assume this was the problem because i changed the settings and the data rate is now set fast!
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Today companies are subjected to more-and-more data, and it won't stop any time soon.  But there are obvious opportunities for reducing data, particularly data duplicated among companies.
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
An overview on how to enroll an hourly employee into the employee database and how to give them access into the clock in terminal.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question