Click here to Skip to main content
16,006,531 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Doc /View Debugging. Pin
Stuart Dootson15-Mar-09 0:45
professionalStuart Dootson15-Mar-09 0:45 
GeneralRe: Doc /View Debugging. Pin
grassrootkit15-Mar-09 1:13
grassrootkit15-Mar-09 1:13 
GeneralRe: Doc /View Debugging. Pin
Stuart Dootson15-Mar-09 1:39
professionalStuart Dootson15-Mar-09 1:39 
QuestionActiveX call OLEDraw to draw Flash(swf) Pin
l_arrow14-Mar-09 18:28
l_arrow14-Mar-09 18:28 
QuestionSerial port read latency (SERIOUS - NEED HELP FAST!) Pin
PeniWize14-Mar-09 14:24
PeniWize14-Mar-09 14:24 
AnswerRe: Serial port read latency (SERIOUS - NEED HELP FAST!) Pin
Luc Pattyn14-Mar-09 15:21
sitebuilderLuc Pattyn14-Mar-09 15:21 
GeneralRe: Serial port read latency (SERIOUS - NEED HELP FAST!) Pin
PeniWize14-Mar-09 20:48
PeniWize14-Mar-09 20:48 
GeneralRe: Serial port read latency (SERIOUS - NEED HELP FAST!) Pin
Luc Pattyn15-Mar-09 4:49
sitebuilderLuc Pattyn15-Mar-09 4:49 
Hi,

the protocol being fixed is very unfortunate; protocols should serve both parties involved, not used one, and receiving is much more difficult than transmitting, you figured that out yourself by now.

AFAIK the Windows serial driver's timing is based on the system timing, which in Windows leaves much to be desired. And all pre-empting, sleeping, and timeouts are based on a single clock which ticks at some 16 msec, the number may vary but AFAIK it never is down to the msec region. I wrote an article on timing from the .NET perspective, it may provide some insight; and if you happen to have .NET installed, you may run the app for some experiments.

Here are two ways for you to go and probably get better results than what you have now:

1. forget all timeouts, just start polling, i.e. have one thread dedicated to reading one byte from the serial port, zero timeout, create your own timeout (1, 2 or 3 msec) with a multimedia timer. That way you should be able, if system load by other processes and threads allows it, to
detect the absence of new characters for an interval of 5 or 6 msec. I would not recommend doing anything other to the serial port than just reading the data byte amd/or the status, changing the status might introduce extra phenomena.

2. the "hard" way: insert another device, micro-controller based, no OS required, that deals with the incoming bytes, and turns them into text-oriented characters with a proper and unique end-of-message marker (could be as simple as hex text, so each incoming 8-bit becomes two hex digits at a higher baud rate, detect end-of-message by timing and send an extra ASCII CR. Then ask the Windows serial driver for a line of text, it knows how to handle a single end-of-line marker, and should work swiftly (i.e. as swiftly as MS stuff can).

Both of the above still make you depend on the limited predictability of Windows stuff.
I have no idea how critical it is to you not to miss a single message...

final remark: do you know anything about the control lines, are they alive, i.e. is the other side signaling start and end of message using one of them. If so, you might poll the line and only launch a read when you already know the data has been received.

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets


GeneralRe: Serial port read latency (SERIOUS - NEED HELP FAST!) Pin
PeniWize15-Mar-09 10:13
PeniWize15-Mar-09 10:13 
GeneralRe: Serial port read latency (SERIOUS - NEED HELP FAST!) Pin
CPallini14-Mar-09 23:59
mveCPallini14-Mar-09 23:59 
AnswerRe: Serial port read latency (SERIOUS - NEED HELP FAST!) Pin
Stuart Dootson14-Mar-09 19:24
professionalStuart Dootson14-Mar-09 19:24 
GeneralRe: Serial port read latency (SERIOUS - NEED HELP FAST!) Pin
PeniWize14-Mar-09 20:55
PeniWize14-Mar-09 20:55 
GeneralRe: Serial port read latency (SERIOUS - NEED HELP FAST!) Pin
Stuart Dootson14-Mar-09 23:19
professionalStuart Dootson14-Mar-09 23:19 
GeneralRe: Serial port read latency (SERIOUS - NEED HELP FAST!) Pin
grassrootkit14-Mar-09 23:29
grassrootkit14-Mar-09 23:29 
GeneralRe: Serial port read latency (SERIOUS - NEED HELP FAST!) Pin
Stuart Dootson14-Mar-09 23:44
professionalStuart Dootson14-Mar-09 23:44 
GeneralRe: Serial port read latency (SERIOUS - NEED HELP FAST!) Pin
PeniWize15-Mar-09 9:59
PeniWize15-Mar-09 9:59 
GeneralRe: Serial port read latency (SERIOUS - NEED HELP FAST!) Pin
grassrootkit14-Mar-09 20:56
grassrootkit14-Mar-09 20:56 
AnswerRe: Serial port read latency (SERIOUS - NEED HELP FAST!) Pin
Trollslayer15-Mar-09 4:06
mentorTrollslayer15-Mar-09 4:06 
AnswerRe: Serial port read latency (SERIOUS - NEED HELP FAST!) Pin
Joe Woodbury15-Mar-09 17:42
professionalJoe Woodbury15-Mar-09 17:42 
Questionwin32 programming - How to use multiple colors in the same line of text? Pin
Member 294013214-Mar-09 12:14
Member 294013214-Mar-09 12:14 
AnswerRe: win32 programming - How to use multiple colors in the same line of text? Pin
Stuart Dootson14-Mar-09 12:35
professionalStuart Dootson14-Mar-09 12:35 
AnswerRe: win32 programming - How to use multiple colors in the same line of text? Pin
Code-o-mat14-Mar-09 13:05
Code-o-mat14-Mar-09 13:05 
QuestionHow to disable minimzing? Pin
daavena14-Mar-09 11:37
daavena14-Mar-09 11:37 
AnswerRe: How to disable minimzing? Pin
hxhl9514-Mar-09 12:11
hxhl9514-Mar-09 12:11 
GeneralRe: How to disable minimzing? Pin
daavena14-Mar-09 12:32
daavena14-Mar-09 12:32 

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.