Author Topic: FT232RL .NET library being shady  (Read 3296 times)

0 Members and 1 Guest are viewing this topic.

Offline osmosis321Topic starter

  • Regular Contributor
  • *
  • Posts: 64
FT232RL .NET library being shady
« on: March 19, 2011, 05:05:25 pm »
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?
 

Offline osmosis321Topic starter

  • Regular Contributor
  • *
  • Posts: 64
Update
« Reply #1 on: March 19, 2011, 07:07:51 pm »
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.
 

Offline red_mamba

  • Contributor
  • Posts: 15
Re: FT232RL .NET library being shady
« Reply #2 on: March 19, 2011, 07:14:27 pm »
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();
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf