Click here to Skip to main content
15,901,284 members
Home / Discussions / C#
   

C#

 
GeneralRe: UDP send /recieve problem... well mainly recieve Pin
Alberto Bar-Noy14-Nov-11 5:36
Alberto Bar-Noy14-Nov-11 5:36 
AnswerRe: UDP send /recieve problem... well mainly recieve Pin
Alberto Bar-Noy14-Nov-11 5:40
Alberto Bar-Noy14-Nov-11 5:40 
Questiondistribute stored procedure files Pin
Marcel Vreuls (www.agentbase.nl)14-Nov-11 2:30
Marcel Vreuls (www.agentbase.nl)14-Nov-11 2:30 
AnswerRe: distribute stored procedure files Pin
SilimSayo14-Nov-11 10:42
SilimSayo14-Nov-11 10:42 
QuestionMouse move (hover) over an Image with Graphics drawings Pin
eyalbi00714-Nov-11 2:12
eyalbi00714-Nov-11 2:12 
AnswerRe: Mouse move (hover) over an Image with Graphics drawings Pin
Luc Pattyn14-Nov-11 2:43
sitebuilderLuc Pattyn14-Nov-11 2:43 
QuestionClass for Serail Port Comms Pin
KeithF14-Nov-11 1:24
KeithF14-Nov-11 1:24 
AnswerRe: Class for Serail Port Comms Pin
Luc Pattyn14-Nov-11 1:48
sitebuilderLuc Pattyn14-Nov-11 1:48 
There are many ways to implement a comm protocol, the best one very much depends on the requirements on reliability, robustness and performance. Here are two extremes:

1.
A very easy approach would do everything in a synchronous way, which means NOT using events (e.g. DataReceived); e.g. have a separate thread that basically does what your protocol diagram shows, including some explicit delays:
Write ENQ
Wait 100
Read 1 and check for ACK0
Write STX msg ETX LRC
Wait 100
Read 1 and check for ACK1
...

The waits are necessary if you want a good chance of getting the next input all in one read(buf); if you read too early, you might get a partial message.

Warning: You have to decide what should happen when something unexpected is read!

2.
The general approach would be completely asynchronous, and it would use a state machine, so the DataReceived handler would consist of a big switch on the state variable, and a number of cases each handling one input line of your protocol diagram. Here too you must make sure your diagram is complete, i.e. in each state what should happen if arbitrary stuff is received?

And then you should also take care of time-outs: what when no data at all, or an insufficient amount of data, is received? Your app probably doesn't want to wait forever...

Smile | :)
Luc Pattyn [My Articles] Nil Volentibus Arduum

GeneralRe: Class for Serail Port Comms Pin
KeithF14-Nov-11 4:24
KeithF14-Nov-11 4:24 
AnswerRe: Class for Serail Port Comms Pin
Luc Pattyn14-Nov-11 5:06
sitebuilderLuc Pattyn14-Nov-11 5:06 
GeneralRe: Class for Serail Port Comms Pin
KeithF16-Nov-11 4:06
KeithF16-Nov-11 4:06 
AnswerRe: Class for Serail Port Comms Pin
Luc Pattyn16-Nov-11 16:02
sitebuilderLuc Pattyn16-Nov-11 16:02 
QuestionIterate all child forms and saving all reports to one excel. Pin
pinifg14-Nov-11 1:18
pinifg14-Nov-11 1:18 
AnswerRe: Iterate all child forms and saving all reports to one excel. Pin
Blue_Boy14-Nov-11 1:26
Blue_Boy14-Nov-11 1:26 
GeneralRe: Iterate all child forms and saving all reports to one excel. Pin
pinifg14-Nov-11 2:45
pinifg14-Nov-11 2:45 
AnswerRe: Iterate all child forms and saving all reports to one excel. Pin
DaveyM6914-Nov-11 1:45
professionalDaveyM6914-Nov-11 1:45 
QuestionConvert To English To Gujarati Pin
ramesh dabhi13-Nov-11 22:38
ramesh dabhi13-Nov-11 22:38 
AnswerRe: Convert To English To Gujarati Pin
Keith Barrow13-Nov-11 23:20
professionalKeith Barrow13-Nov-11 23:20 
AnswerRe: Convert To English To Gujarati Pin
Abhinav S14-Nov-11 1:42
Abhinav S14-Nov-11 1:42 
AnswerRe: Convert To English To Gujarati Pin
thatraja14-Nov-11 1:57
professionalthatraja14-Nov-11 1:57 
QuestionMultiple lines : datagridview Pin
abbd13-Nov-11 11:24
abbd13-Nov-11 11:24 
AnswerRe: Multiple lines : datagridview Pin
Richard MacCutchan13-Nov-11 22:42
mveRichard MacCutchan13-Nov-11 22:42 
AnswerRe: Multiple lines : datagridview Pin
thatraja14-Nov-11 2:05
professionalthatraja14-Nov-11 2:05 
QuestionCheckers Board game error Pin
xnaLearner13-Nov-11 11:03
xnaLearner13-Nov-11 11:03 
AnswerRe: Checkers Board game error PinPopular
Pete O'Hanlon13-Nov-11 11:27
mvePete O'Hanlon13-Nov-11 11:27 

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.