Link to home
Start Free TrialLog in
Avatar of 0x100
0x100

asked on

COM Port Data Rate

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.
Avatar of DanRollins
DanRollins
Flag of United States of America image

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
Avatar of 0x100
0x100

ASKER

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?
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?
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
Avatar of 0x100

ASKER

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.
hi

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

it is very simple all windows packages support hyper terminal.

>>SetCommState takes about 2 seconds

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

======
Werner
I think you are doing something wrong.

Show your code for opening the COM port and setting the bit rate.
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?


ASKER CERTIFIED SOLUTION
Avatar of DanRollins
DanRollins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Good thought!
Avatar of 0x100

ASKER

not exactly but it was TAPI related
thanks sir
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
Avatar of 0x100

ASKER

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!