Skip to content

Instantly share code, notes, and snippets.

Created May 9, 2017 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/f26c82e463c397cd716c6fb807111913 to your computer and use it in GitHub Desktop.
Save anonymous/f26c82e463c397cd716c6fb807111913 to your computer and use it in GitHub Desktop.
using GHIElectronics.TinyCLR.Devices.SerialCommunication;
using GHIElectronics.TinyCLR.Pins;
using GHIElectronics.TinyCLR.Storage.Streams;
using System.Threading;
namespace SerialExample {
class Program {
static void Main() {
var ser = SerialDevice.FromId(FEZPandaIII.SerialPort.Com1);
ser.BaudRate = 9600;
ser.StopBits = SerialStopBitCount.One;
ser.Parity = SerialParity.None;
ser.DataBits = 8;
ser.Handshake = SerialHandshake.None;
var reader = new DataReader(ser.InputStream);
var writer = new DataWriter(ser.OutputStream);
writer.WriteString("Ready\r\n");
writer.Store();
while (true) {
var read = reader.Load(10);
if (read > 0) {
var str = reader.ReadString(read);
writer.WriteString(str);
writer.Store();
}
Thread.Sleep(10);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment