Created
May 9, 2017 19:48
-
-
Save anonymous/f26c82e463c397cd716c6fb807111913 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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