Click here to Skip to main content
16,010,394 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to clear buffer of a COM port ? Pin
kapardhi10-Dec-08 20:19
kapardhi10-Dec-08 20:19 
QuestionRe: How to clear buffer of a COM port ? Pin
VC++Maniac10-Dec-08 20:27
VC++Maniac10-Dec-08 20:27 
AnswerRe: How to clear buffer of a COM port ? Pin
kapardhi10-Dec-08 21:15
kapardhi10-Dec-08 21:15 
GeneralRe: How to clear buffer of a COM port ? Pin
Roger Stoltz10-Dec-08 23:24
Roger Stoltz10-Dec-08 23:24 
QuestionRe: How to clear buffer of a COM port ? Pin
VC++Maniac10-Dec-08 23:30
VC++Maniac10-Dec-08 23:30 
AnswerRe: How to clear buffer of a COM port ? Pin
Roger Stoltz10-Dec-08 23:40
Roger Stoltz10-Dec-08 23:40 
GeneralRe: How to clear buffer of a COM port ? Pin
kapardhi11-Dec-08 1:17
kapardhi11-Dec-08 1:17 
GeneralRe: How to clear buffer of a COM port ? Pin
Roger Stoltz11-Dec-08 2:09
Roger Stoltz11-Dec-08 2:09 
kapardhi wrote:
The device which is attached to the COM port is sujected to a specific Baudrate, parity, databit and stopbit, whose values i do not know beforehand. so i send the command for all combinations of baudrate, parity, databit stopbits.


WTF | :WTF:
You actually mean that you have no idea, and cannot predict, what settings the device uses on start up? I find that very hard to believe, because it means that the device is uninitialized and hence should not be able to communicate at all.

Usually a device that supports multiple communication settings starts off with a known configuration; e.g 300 baud, 1 stop bit, no parity. Then the host negotiates with the device about a new configuration through a known protocol.

If you don't know anything about this device, you would be better off using an oscilloscope to find out what configuration is used.
But even if you find out what configuration is being used, you still have to know the protocol, which I suspect can be found at the same place as where the communication settings are documented.
The alternative is to set a timeout using ::SetCommTimeouts() to let the timeout of the read operation expire when the hardware hasn't received a new byte within e.g. ten byte times. Then it's reasonable to assume that you've received all data the device wants to send and you can continue and try another configuration.


"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknown


GeneralRe: How to clear buffer of a COM port ? Pin
kapardhi11-Dec-08 2:25
kapardhi11-Dec-08 2:25 
QuestionRe: How to clear buffer of a COM port ? Pin
Roger Stoltz11-Dec-08 3:01
Roger Stoltz11-Dec-08 3:01 
AnswerRe: How to clear buffer of a COM port ? Pin
Iain Clarke, Warrior Programmer11-Dec-08 0:13
Iain Clarke, Warrior Programmer11-Dec-08 0:13 
GeneralRe: How to clear buffer of a COM port ? Pin
kapardhi11-Dec-08 1:18
kapardhi11-Dec-08 1:18 
AnswerRe: How to clear buffer of a COM port ? Pin
JudyL_MD11-Dec-08 8:07
JudyL_MD11-Dec-08 8:07 
QuestionRe: How to clear buffer of a COM port ? Pin
kapardhi11-Dec-08 19:41
kapardhi11-Dec-08 19:41 
AnswerRe: How to clear buffer of a COM port ? Pin
JudyL_MD12-Dec-08 3:14
JudyL_MD12-Dec-08 3:14 
QuestionHow to create .DBX file (MS-OUTLOOK EXPRESS files) using vc++ 6.0 Pin
ravi malik10-Dec-08 19:44
ravi malik10-Dec-08 19:44 
QuestionCreate DIB from a HBITMAP Pin
VC++Maniac10-Dec-08 19:35
VC++Maniac10-Dec-08 19:35 
AnswerRe: Create DIB from a HBITMAP Pin
Hamid_RT10-Dec-08 20:17
Hamid_RT10-Dec-08 20:17 
QuestionRe: Create DIB from a HBITMAP Pin
VC++Maniac10-Dec-08 20:25
VC++Maniac10-Dec-08 20:25 
AnswerRe: Create DIB from a HBITMAP Pin
enhzflep10-Dec-08 23:34
enhzflep10-Dec-08 23:34 
GeneralRe: Create DIB from a HBITMAP Pin
VC++Maniac10-Dec-08 23:43
VC++Maniac10-Dec-08 23:43 
GeneralRe: Create DIB from a HBITMAP Pin
akirilov11-Dec-08 0:08
akirilov11-Dec-08 0:08 
GeneralRe: Create DIB from a HBITMAP Pin
enhzflep11-Dec-08 0:11
enhzflep11-Dec-08 0:11 
GeneralRe: Create DIB from a HBITMAP Pin
VC++Maniac11-Dec-08 0:25
VC++Maniac11-Dec-08 0:25 
AnswerRe: Create DIB from a HBITMAP Pin
Mark Salsbery11-Dec-08 7:08
Mark Salsbery11-Dec-08 7:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.