Jak odswiezyc na biezaco zawartosc textboxa po odbiorze z FTDI . Zrobilem program, korzystając z D2XX, ktory wyswietla poprawna zawartosc, ale jak zmieniam dane nic sie nie zmienia. Gdy zmienie wejscie i uruchomie ponownie program to dopiero wtedy wyswietla poprawna wartosc.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using FTD2XX_NET;
using System.Threading;
namespace counter
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
readData();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void textBox5_TextChanged(object sender, EventArgs e)
{
textBox5.Refresh();
}
private void label6_Click(object sender, EventArgs e)
{
}
private void readData()
{
UInt32 ftdiDeviceCount = 0;
bool isopen;
string readData;
UInt32 numBytesRead = 0;
FTDI.FT_STATUS ftStatus = FTDI.FT_STATUS.FT_OK;
FTDI myFtdiDevice = new FTDI();
ftStatus = myFtdiDevice.GetNumberOfDevices(ref ftdiDeviceCount);
if (ftStatus == FTDI.FT_STATUS.FT_OK)
{
textBox1.Text += ftdiDeviceCount.ToString();
}
FTDI.FT_DEVICE_INFO_NODE[] ftdiDeviceList = new FTDI.FT_DEVICE_INFO_NODE[ftdiDeviceCount];
ftStatus = myFtdiDevice.GetDeviceList(ftdiDeviceList);
if (ftStatus == FTDI.FT_STATUS.FT_OK)
{
for (UInt32 i = 0; i < ftdiDeviceCount; i++)
{
textBox2.Text += ftdiDeviceList[i].SerialNumber.ToString();
textBox3.Text += ftdiDeviceList[i].Description.ToString();
}
}
if (ftStatus == FTDI.FT_STATUS.FT_OK)
{
ftStatus = myFtdiDevice.OpenBySerialNumber(ftdiDeviceList[0].SerialNumber);
if (ftStatus == FTDI.FT_STATUS.FT_OK)
{
isopen = myFtdiDevice.IsOpen;
textBox4.Text += isopen;
}
ftStatus = myFtdiDevice.SetBaudRate(19200);
ftStatus = myFtdiDevice.SetDataCharacteristics(8, 1, 0);
ftStatus = myFtdiDevice.SetFlowControl(FTDI.FT_FLOW_CONTROL.FT_FLOW_RTS_CTS, 0x11, 0x13);
ftStatus = myFtdiDevice.SetTimeouts(1000, 0);
ftStatus = myFtdiDevice.Read(out readData, 8, ref numBytesRead);
myFtdiDevice.Close();
textBox5.Text = readData;
}
}
}
}