Hey guys, was wondering if somebody could give me a hand...
I'm relativly new to c# and I'm having difficulty writing subsequent characters to a com port.
I basically need to send a user-input character followed by a short pause before the char 'x'.
I can send either the input character...OR a char defined in the program but only the first instruction is executed and I'm not sure why. I've tried a few methods but none seem to do the trick...
Here's snippets of my code, I'd really appriciate the help.
Ideally I'd like the program to wait for a char to be entered into buff[0]; send this character to com port; send 'x' char to com port and then wait for the next character to be entered into buff[0]
attempt one...
char[] buff = new char[1];
char[] xbuff = new char[1];
buff[0] = e.KeyChar;
xbuff[0] = 'x';
serialPort1.Write(buff, 0, 1);
System.Threading.Thread.Sleep(500);
serialPort1.Write(xbuff, 0, 1);
System.Array.Clear(buff, 0, 1);
attempt two...
string lettera = ((char)97).ToString();
string letterb = ((char)98).ToString();
serialPort1.Write(lettera);
System.Threading.Thread.Sleep(500);
serialPort1.Write(letterb);
For some reason on both attempts only the first char will be sent. I've been pulling my hair out for the last 2 days and would really be grateful for any ideas
M.