Click here to Skip to main content
15,898,373 members
Home / Discussions / C#
   

C#

 
GeneralRe: how to use desktop composition + C# Pin
Richard MacCutchan25-Jun-12 4:48
mveRichard MacCutchan25-Jun-12 4:48 
GeneralRe: how to use desktop composition + C# Pin
BobJanova25-Jun-12 4:52
BobJanova25-Jun-12 4:52 
GeneralRe: how to use desktop composition + C# Pin
jojoba201125-Jun-12 17:51
jojoba201125-Jun-12 17:51 
Questionascii to decimal Pin
Member 916404524-Jun-12 8:29
Member 916404524-Jun-12 8:29 
AnswerRe: ascii to decimal Pin
Luc Pattyn24-Jun-12 8:53
sitebuilderLuc Pattyn24-Jun-12 8:53 
AnswerRe: ascii to decimal Pin
NeonMika24-Jun-12 10:29
NeonMika24-Jun-12 10:29 
GeneralRe: ascii to decimal Pin
Member 916404524-Jun-12 17:08
Member 916404524-Jun-12 17:08 
AnswerRe: ascii to decimal Pin
Luc Pattyn24-Jun-12 17:50
sitebuilderLuc Pattyn24-Jun-12 17:50 
When the data isn't text, you should NOT use text-oriented methods such as ReadExisting() as that would imply two conversions, one from binary to characters (by the method itself) and one back from characters to bytes (by you), both prone to mishaps. You really should use a byte-oriented read, which is Read()[^].

And then it becomes pretty easy to just pick the byte or bytes you really need and work with them.

Warnings:

1. serial communication may get out of sync (some garbage on the line, the PC temporarily not listening due to an overload, ...) , there is no guarantee what comes in will be exactly one message.

2. the DataReceived event will fire when there is "some data" available. There is no guarantee it will fire on the first byte coming in, and there sure is no guarantee the message will have been received completely before it fires. So there is a big chance you will have to collect data and somehow make sure you get synchronized with the messages, possibly having to keep the remainder as the start of the next message for later processing.

The best case would be when the transmission is fast and the pauses between messages are relatively large (say 9600Baud, i.e. could send 1000 bytes/sec, hence a burst of 64 msec and a gap of some 900msec. Then you could use DataReceived, insert a 100msec delay in it (to make sure the entire message has been received), then read it all in one go.

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

GeneralRe: ascii to decimal Pin
Basim 227-Jun-12 10:21
Basim 227-Jun-12 10:21 
AnswerRe: ascii to decimal Pin
Luc Pattyn27-Jun-12 11:17
sitebuilderLuc Pattyn27-Jun-12 11:17 
GeneralRe: ascii to decimal Pin
Richard MacCutchan24-Jun-12 22:35
mveRichard MacCutchan24-Jun-12 22:35 
GeneralRe: ascii to decimal Pin
Basim 225-Jun-12 4:41
Basim 225-Jun-12 4:41 
QuestionUnhanded Exception Error Pin
Saidrex23-Jun-12 22:42
Saidrex23-Jun-12 22:42 
AnswerRe: Unhanded Exception Error Pin
Sandeep Mewara23-Jun-12 22:57
mveSandeep Mewara23-Jun-12 22:57 
GeneralRe: Unhanded Exception Error Pin
Saidrex23-Jun-12 23:36
Saidrex23-Jun-12 23:36 
GeneralRe: Unhanded Exception Error Pin
Sandeep Mewara24-Jun-12 2:28
mveSandeep Mewara24-Jun-12 2:28 
GeneralRe: Unhanded Exception Error Pin
Saidrex24-Jun-12 2:32
Saidrex24-Jun-12 2:32 
AnswerRe: Unhanded Exception Error Pin
Eddy Vluggen23-Jun-12 23:40
professionalEddy Vluggen23-Jun-12 23:40 
GeneralRe: Unhanded Exception Error Pin
Saidrex24-Jun-12 0:09
Saidrex24-Jun-12 0:09 
GeneralRe: Unhanded Exception Error Pin
Eddy Vluggen24-Jun-12 0:14
professionalEddy Vluggen24-Jun-12 0:14 
GeneralRe: Unhanded Exception Error Pin
Saidrex24-Jun-12 0:17
Saidrex24-Jun-12 0:17 
GeneralRe: Unhanded Exception Error Pin
Eddy Vluggen24-Jun-12 0:25
professionalEddy Vluggen24-Jun-12 0:25 
GeneralRe: Unhanded Exception Error Pin
Saidrex24-Jun-12 0:32
Saidrex24-Jun-12 0:32 
GeneralRe: Unhanded Exception Error Pin
jschell24-Jun-12 12:27
jschell24-Jun-12 12:27 
QuestionDelete specific rows from database tables Pin
Saidrex23-Jun-12 10:16
Saidrex23-Jun-12 10:16 

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.