Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Threading;
- using System.IO.Ports;
- using System.Text;
- using Microsoft.SPOT;
- using Microsoft.SPOT.Hardware;
- using GHIElectronics.NETMF.Hardware;
- namespace MFConsoleApplication1
- {
- public class Program
- {
- private static byte[] rx_byte = new byte[1000];
- public static void Main()
- {
- SerialPort UART = new SerialPort("COM2");
- UART.BaudRate = 115200;
- UART.Parity = Parity.None;
- UART.StopBits = StopBits.One;
- UART.DataBits = 8;
- UART.Handshake = Handshake.None;
- UART.Open();
- UART.DataReceived += new SerialDataReceivedEventHandler(DataReceviedHandler);
- while (true)
- {
- Thread.Sleep(10);
- }
- }
- private static void DataReceviedHandler(object sender, SerialDataReceivedEventArgs e)
- {
- SerialPort UART = (SerialPort)sender;
- UART.Read(rx_byte, 0, rx_byte.Length);
- Debug.Print(rx_byte[0].ToString());
- }
- }
- }
Add Comment
Please, Sign In to add comment