Electronics > Projects, Designs, and Technical Stuff
FT232RL .NET library being shady
(1/1)
osmosis321:
I use PuTTY: bytes received correctly.
I use the .NET wrapper: everything appears to work, Write() returns with FT_OK and the right amount of bytes showing as written, but the PIC receives a single 0x00 byte. Subsequent Writes are identical except the PIC receives 0x01 from then on.
What the ..?! Either I'm doing something terribly wrong or there's a bug in the driver, or something.
Has this happened to anyone else?
osmosis321:
it turns out the problem is with the particular overload of the Write() method I'm using. The overload that accepts a String parameter fails, likely because of some Unicode encoding/decoding issue.
I've neither the time nor inclination to solve the String encoding problem. I'm thinking the best way to get past this is to just use the other overload, which accepts a char array, and which actually works.
The only annoyance there is I'll have to change my interfaces as well.
red_mamba:
Never had problems in C# ;D
--- Quote ---FTDI.FT_STATUS ftStatus;
FTDI myFTDI;
uint rd = 0;
myFTDI.OpenByIndex((uint)comboBox2.SelectedIndex);
myFTDI.SetBaudRate(115200);
myFTDI.SetDataCharacteristics(FTDI.FT_DATA_BITS.FT_BITS_8, FTDI.FT_STOP_BITS.FT_STOP_BITS_1, FTDI.FT_PARITY.FT_PARITY_NONE);
myFTDI.SetTimeouts(5000, 5000);
myFTDI.SetFlowControl(FTDI.FT_FLOW_CONTROL.FT_FLOW_NONE, 0, 0);
myFTDI.Write("AT+CPIN?\r", 9, ref rd);
rd = 0;
while (rd == 0)
{
myFTDI.GetRxBytesAvailable(ref rd);
Thread.Sleep(10);
}
Thread.Sleep(250);
Thread.Sleep(250);
myFTDI.GetRxBytesAvailable(ref rd);
if (rd > 0)
{
myFTDI.Read(out rec, rd, ref rd);
textBox1.Text += rec;
}
myFTDI.Close();
--- End quote ---
Navigation
[0] Message Index
Go to full version