Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Diagnostics;
- using System.Collections;
- using System.Text;
- using System.Threading;
- using GHIElectronics.TinyCLR.Storage.Streams;
- using GHIElectronics.TinyCLR.Devices.SerialCommunication;
- using GHIElectronics.TinyCLR.Pins;
- namespace g400uart
- {
- class Program
- {
- static DataReader UartA_ReadStream;
- static DataWriter UartA_WriteStream;
- static void Main()
- {
- byte ReadBuffer = 0;
- //SerialDevice UartA = SerialDevice.FromId(FEZ.UartPort.Usart1);
- SerialDevice UartA = SerialDevice.FromId(G400D.UartPort.Usart1);
- UartA.BaudRate = 115200;
- UartA.ReadTimeout = TimeSpan.Zero;
- UartA_ReadStream = new DataReader(UartA.InputStream);
- UartA_WriteStream = new DataWriter(UartA.OutputStream);
- UartA_WriteStream.WriteString("I am UART A!");
- UartA_WriteStream.Store();
- while (ReadBuffer != 0x5A)
- {
- if (UartA_ReadStream.Load(1) > 0)
- {
- ReadBuffer = UartA_ReadStream.ReadByte();
- Debug.WriteLine("Received: " + ReadBuffer);
- UartA_WriteStream.WriteByte(ReadBuffer);
- UartA_WriteStream.Store();
- }
- Thread.Sleep(10);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment