OK, you have taken care of my earlier #1 and #2. That still leaves #3, #4, and #5. I also noticed something else, so: 6.
for (q = 2; q < msg.Length; q++) {
byte[] myTempRcv ={ byte.Parse(msg[q]) };
serialPort.Write(myTempRcv, 0, 1);
}
does not look good. Why would you send one byte at a time? here is something much more efficient:
int length=msg.Length;
byte[] myTempRcv =new byte[length];
for (q = 2; q < length; q++) {
byte[q]=byte.Parse(msg[q]);
}
serialPort.Write(myTempRcv, 2, length-2);
BTW: I am not sure the indexes are all correct, [ADDED] in fact I'm not sure your original code is correct as I don't know what the intention is, what the original content of msg is, and what exactly should be written to the serial port. [/ADDED] If you need more help about this, please provide an example with actual numbers (in decimal, or in hexadecimal, whatever suits you). :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
modified on Sunday, March 27, 2011 7:29 PM