CÁC GIẢI PHÁP LẬP TRÌNH C# - Trang 387

387

Chương 9: File, thư mục, và I/O

port.BaudRate = 9600;

port.Parity = 0;

port.PortNum = 1;

port.ReadTimeout = 10;

port.StopBits = 1;

port.ByteSize = 1;

// Mở cổng.

port.Open();

// Ghi dữ liệu.

port.Write(new byte[1]);

// Đóng cổng.

port.Close();

}catch (ApplicationException err) {

Console.WriteLine(err.Message);

}