//for connection private void Button1_Click(object sender, EventArgs e) { try { ftStatus = myFtdiDevice.GetNumberOfDevices(ref devcount); } catch { commentbox.Text = "Driver not loaded"; } ftStatus = myFtdiDevice.OpenByIndex(0); // Update the Status text line if (ftStatus == FTDI.FT_STATUS.FT_OK) { DeviceOpen = true; commentbox.Text = "FT232RL 通信しました"; } else { DeviceOpen = false; commentbox.Text = "FT232RL 通信出来ないです"; } Update(); Application.DoEvents(); } //Read data private void ReadData_Click(object sender, EventArgs e) { if (DeviceOpen == true) { ftStatus = myFtdiDevice.GetRxBytesAvailable(ref numBytesAvailable); if (ftStatus != FTDI.FT_STATUS.FT_OK) { Console.WriteLine("Failed to get number of bytes available to read (error " + ftStatus.ToString() + ")"); Console.ReadKey(); return; } string readData = ""; UInt32 numBytesRead = 0; byte[] dataBuffer = new byte[1024]; // TODO: check so you don't over your buffer. ftStatus = myFtdiDevice.Read(out readData, numBytesAvailable, ref numBytesRead); Console.WriteLine(readData); Thread.Sleep(10000); } else { commentbox.Text = "not open"; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)