Peter Witkowski | 10 May 2013 06:16
Picon

CPU Overhead?

Hello,

I am writing an application that uses the FTDI FT2232H chip to read RS-485 data.  The data is coming in at a fairly high rate (6 Mbps baud rate with an effective data rate of about 3.2 Mbps).  My application must read in the data and then process it as quickly as possible.  Latency is frowned up, however I can generally accept up to 250 ms.

I have interfaced with the device using the D2XX driver provided by FTDI.  Overall, the application works fine from a functional standpoint.  However, the D2XX driver alone pulls about 45% CPU usage.  I have to run the application on an embedded ARM processor, which runs at 720 Mhz, so I don't have alot of horsepower per say.  I am using the FT_Read() function in a loop to extract the data and then pass it along.  In a simple application I wrote to test the driver, I extract the data in the loop and just write it to a file.  This alone pulls the 45% CPU usage figure (numbers from the top command) referenced earlier.

My problem is that I just received requirements forcing me to add to the application.  As a result, I was wondering if you all could give me some sense of the type of performance (in terms of CPU load) that I could expect comparatively from libftdi.  I'm primarily interested in ball park numbers of what I could expect using the ftdi_stream functionality.  Note that the application is written in C++, so if there are any things to worry about in terms of compiling with g++ vice gcc, please let me know.

Thank you in advance for your assistance.  I will keep you appraised of my progress.

--
Peter Witkowski

libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe <at> developer.intra2net.com


Hannes Weisbach | 27 Apr 2013 17:41
Picon

ftdi_eeprom link failure

Hello libftdi-developers.

I wanted to compile libftdi1 under OS X 10.6.8 and I followed README.build to do so. However, ftdi_eeprom
failed to link with the following error:
Linking C executable ftdi_eeprom
Undefined symbols:
  "_libintl_setlocale", referenced from:
      _cfg_init in libconfuse.a(confuse.o)
      _cfg_init in libconfuse.a(confuse.o)
  "_libintl_bindtextdomain", referenced from:
      _cfg_init in libconfuse.a(confuse.o)
  "_libintl_dgettext", referenced from:
      _cfg_include in libconfuse.a(confuse.o)
      _cfg_getopt in libconfuse.a(confuse.o)
      _cfg_getopt in libconfuse.a(confuse.o)
      _cfg_setopt in libconfuse.a(confuse.o)
      _cfg_setopt in libconfuse.a(confuse.o)
      _cfg_parse_internal in libconfuse.a(confuse.o)
      _cfg_parse_internal in libconfuse.a(confuse.o)

A bit of research suggested, that "-lintl" may be missing from the linker flags. So I added it and everything
compiled and linked fine. I added the library to ftdi_eeprom/CMakeList.txt (see attached patch).

I don't know if this problem exists on other platforms or whether it even may break something.

Best regards,
Hannes

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe <at> developer.intra2net.com   

Attachment (libftdi_lintl.patch): application/octet-stream, 454 bytes
Newell Jensen | 23 Apr 2013 18:53
Picon
Gravatar

Re: FT2232H shows up like FT4232H

I just joined the mailing list and the email below has gone unanswered. I am also faced with this problem but I get this issue intermittently. That is, sometimes when I plug in the FT2232H mini module, it sometimes comes up as FT2232H and other times it comes up as FT4232H (he mentions FT4323H but mine comes up as FT4232H). When I run:
$ lsusb -v
and take a look at the output I see distinct differences when it comes up as FT2232H vs. FT4232H (obviously). Has anyone else ran into this issue before? I can easily reproduce this. I mean I guess I could keep plugging and unplugging my mini module until it shows up as FT2232H but this seems like something buggy to begin with that I would like to wrap my head around.
Thanks.******************************************************************** Hello all, I have problem with my FT2232H chip: I want to use it to communicate via sync FIFO. As the data sheet suggests you have to reprogram the eeprom, but when using the tool from libftdi I found that the chip id is FT4323H. Maybe someone who used the board beforehand overwrote the value. I tried to change the eeprom by hacking the eeprom example of the actual libftdi version (git clone), but I did not succeed. Can anyone tell me, how to change the chip id in the eeprom without breaking the device. Thanks a lot, Matthias Brugger -- motzblog.wordpress.com
***************************************************************************************************************

libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe <at> developer.intra2net.com


Chris Morgan | 23 Apr 2013 15:30
Picon

API changes between 0.xx and 1.0?

Hi.

I was wondering if there were any api changes between 0.xx and 1.0?
I'm starting to look at using libftdi and wasn't sure if I could start
using my distributions built in version of 0.19 and then seamlessly
upgrade to 1.0 or if I should start at the 1.0 version to avoid api
differences.

Chris

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe <at> developer.intra2net.com   

Jochen Sprickerhof | 22 Apr 2013 12:27
Picon

read/write timeout in C++ wrapper

Hi,

the C++ wrapper has no function to set the read/write timouts of the
ftdi_context. The attached patch fixes this. Would be great to have you
could merge it upstream.

Cheers Jochen

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe <at> developer.intra2net.com   
peter holly | 18 Apr 2013 21:16
Picon

ftdi_convert_baudrate()

Hi,
I have tried libftdi with 2 port FT2232C chip. Only problem I found was that the ftdi_set_baudrate() function did not work with second port. The port allways operated on highest baudrate. Looking closer on ftdi_convert_baudrate() i found out that the ftdi->index is aplied only on high speed devices. I have modified the code like this and it works fine. Is that ok ?

if (ftdi->type == TYPE_2232H ||
        ftdi->type == TYPE_4232H ||
        ftdi->type == TYPE_232H )
    {
        *index = (unsigned short)(encoded_divisor >> 8);
    }
    else
    {
        *index = (unsigned short)(encoded_divisor >> 16);
    }
    *index &= 0xFF00;
    *index |= ftdi->index;

Best regards,
Peter Holly



libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe <at> developer.intra2net.com


linux fddl | 18 Apr 2013 10:54
Picon

Why can not set DTR and RTS?

  I have a usb-to-serial cable(FTDI 232RL chip),
I am trying to control my board by a userland program(linux) basing on
libftdi, but can not set DTR and RTS. I really do not know why.
  I also tried to call ftdi_set_bitmode(ftdi, 0xFF, BITMODE_RESET) and
ftdi_setflowctrl(ftdi, SIO_DISABLE_FLOW_CTRL)/ftdi_setflowctrl(ftdi,
SIO_DTR_DSR_HS), but all of them were useless.

Here is my code(I'm so sorry, it's not clean enough), is there anything wrong?

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <getopt.h>
#include <string.h>
#include <ftdi.h>

#define DEBUG

#ifdef DEBUG
#define DBG printf
#else
#define DBG
#endif

#define VID 0x0403
#define PID 0x6001

struct usb_id_info {
int vendor;
int product;
};

/* ctrl the pin(s) or not */
struct ctrl_pins {
int dtr; /* ctrl RS232's DTR pin */
int rts; /* ctrl RS232's RTS pin */
};

struct cmd_context {
struct usb_id_info usb_id;
struct ctrl_pins pins;
};

static struct cmd_context cmd;
static char app_name[32] = {"ftdi-pin-ctrl"};

static void show_usage(void)
{
fprintf(stderr, "Usage: %s [-v hex] [-p hex] [-o pin]\n",
app_name);
fprintf(stderr, "Options are:\n");
fprintf(stderr, " -v hex assign a vendor id, default 0x0403\n");
fprintf(stderr, " -p hex assign a product id, default 0x6001\n");
fprintf(stderr, " -o pin which pin to ctrl, now only dtr and rts are
supported, default none\n");
}

static void exit_bad_args(void)
{
show_usage();
exit(EXIT_FAILURE);
}

static int parse_args(int argc, char **argv)
{
int result = 0;
const char short_opts[] = {"v:p:o:h"};
while((result = getopt(argc, argv, short_opts))  != -1) {
switch(result) {
case 'v':
DBG("option=%c, optarg=%s\n", result, optarg);
cmd.usb_id.vendor = (int)strtoul(optarg, NULL, 16);
break;
case 'p':
DBG("option=%c, optarg=%s\n", result, optarg);
cmd.usb_id.product = (int)strtoul(optarg, NULL, 16);
break;
case 'o':
DBG("option=%c, optarg=%s\n", result, optarg);
if(!strcmp("dtr", optarg))
cmd.pins.dtr = 1;
if(!strcmp("rts", optarg))
cmd.pins.rts = 1;
DBG("dtr[%d], rts[%d]\n", cmd.pins.dtr, cmd.pins.rts);
break;
case 'h':
show_usage();
exit(EXIT_SUCCESS);
default:
show_usage();
exit(EXIT_FAILURE);
}
}

DBG("vendor[0x%04x]\n", cmd.usb_id.vendor);
DBG("product[0x%04x]\n", cmd.usb_id.product);
DBG("dtr[%d], rts[%d]\n", cmd.pins.dtr, cmd.pins.rts);

return 0;
}

static void set_default_args(void)
{
memset(&cmd, 0, sizeof(cmd));
cmd.usb_id.vendor = VID;
cmd.usb_id.product = PID;
}

static int ctrl_dtr(struct ftdi_context *ftdi)
{
int f;
int i;
for (i = 0; i < 8; i++) {
if (f = ftdi_setdtr(ftdi, SIO_SET_DTR_HIGH))
return f;

usleep(1 * 1000000);

if (f = ftdi_setdtr(ftdi, SIO_SET_DTR_LOW))
return f;

usleep(1 * 1000000);
}
return f;
}

static int ctrl_rts(struct ftdi_context *ftdi)
{
int f;
int i;
for (i = 0; i < 8; i++) {

if (f = ftdi_setrts(ftdi, SIO_SET_DTR_HIGH))
return f;

usleep(1 * 1000000);

if (f = ftdi_setrts(ftdi, SIO_SET_DTR_LOW))
return f;

usleep(1 * 1000000);
}
return f;
}

int main(int argc, char **argv)
{
struct ftdi_context *ftdi;
int f,i;
unsigned char buf[1];
int retval = 0;

/* at least one args is needed */
if (argc <= 1)
exit_bad_args();

set_default_args();

parse_args(argc, argv);

if ((ftdi = ftdi_new()) == 0) {
fprintf(stderr, "ftdi_new failed\n");
return EXIT_FAILURE;
}

// f = ftdi_usb_open(ftdi, 0x0403, 0x6001);
f = ftdi_usb_open(ftdi, cmd.usb_id.vendor, cmd.usb_id.product);

if (f < 0 && f != -5) {
fprintf(stderr, "unable to open ftdi device: %d (%s)\n",
f, ftdi_get_error_string(ftdi));
retval = EXIT_FAILURE;
goto done;
}

printf("ftdi open succeeded: %d\n",f);

//sjh
printf("enabling bitbang mode\n");
ftdi_set_bitmode(ftdi, 0xFF, BITMODE_BITBANG);

//usleep(3 * 1000000);

#if 1
printf("resetting bitmode...\n");
f = ftdi_set_bitmode(ftdi, 0xFF, BITMODE_RESET);
if (f < 0) {
fprintf(stderr, "unable to RESET ftdi device: %d (%s)\n", f,
ftdi_get_error_string(ftdi));
retval = 1;
goto done;
}
#endif

#if 1
printf("disabling flowctrl...\n");
//f = ftdi_setflowctrl(ftdi, SIO_DISABLE_FLOW_CTRL);
f = ftdi_setflowctrl(ftdi, SIO_DTR_DSR_HS);
if (f < 0) {
fprintf(stderr, "fail to disable flowctrl ftdi device: %d (%s)\n", f,
ftdi_get_error_string(ftdi));
retval = 1;
goto done;
}
#endif

#if 1
printf("setting baudrage...\n");
f = ftdi_set_baudrate(ftdi, 9600);
if (f < 0) {
fprintf(stderr, "fail to set baudrate ftdi device: %d (%s)\n", f,
ftdi_get_error_string(ftdi));
retval = 1;
goto done;
}
#endif

//if (cmd.pins.dtr) {
printf("controlling dtr...\n");
f = ctrl_dtr(ftdi);
if (f < 0) {
fprintf(stderr,"setup failed for dtr, error %d (%s)\n",
f, ftdi_get_error_string(ftdi));
retval = EXIT_FAILURE;
goto done;
}
//}

//if (cmd.pins.rts) {
printf("controlling rts...\n");
f = ctrl_rts(ftdi);
if (f < 0) {
fprintf(stderr,"setup failed for dtr, error %d (%s)\n",
f, ftdi_get_error_string(ftdi));
retval = EXIT_FAILURE;
goto done;
}
//}
#if 1
buf[0] = 0x0;
printf("turning everything on\n");
f = ftdi_write_data(ftdi, buf, 1);
if (f < 0)
{
fprintf(stderr,"write failed for 0x%x, error %d (%s)\n",buf[0],f,
ftdi_get_error_string(ftdi));
}

//usleep(3 * 1000000);

buf[0] = 0xFF;
printf("turning everything off\n");
f = ftdi_write_data(ftdi, buf, 1);
if (f < 0)
{
fprintf(stderr,"write failed for 0x%x, error %d (%s)\n",buf[0],f,
ftdi_get_error_string(ftdi));
}

//usleep(3 * 1000000);

for (i = 0; i < 32; i++)
{
buf[0] =  0 | (0xFF ^ 1 << (i % 8));
if ( i > 0 && (i % 8) == 0)
{
printf("\n");
}
printf("%02hhx ",buf[0]);
fflush(stdout);
f = ftdi_write_data(ftdi, buf, 1);
if (f < 0)
{
fprintf(stderr,"write failed for 0x%x, error %d (%s)\n",buf[0],f,
ftdi_get_error_string(ftdi));
}
usleep(1 * 1000000);
}

printf("\n");
#endif
printf("disabling bitbang mode\n");
ftdi_disable_bitbang(ftdi);

ftdi_usb_close(ftdi);
done:
ftdi_free(ftdi);

return retval;
}

Best regards
ShiJinghui

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe <at> developer.intra2net.com   

Matthias Brugger | 16 Apr 2013 10:33
Picon

[PATCH] Typo in error message of ftdi_write_eeprom_location.

Signed-off-by: Matthias Brugger <matthias.bgg <at> gmail.com>
---
 src/ftdi.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/ftdi.c b/src/ftdi.c
index 3c86456..a438602 100644
--- a/src/ftdi.c
+++ b/src/ftdi.c
 <at>  <at>  -4126,7 +4126,7  <at>  <at>  int ftdi_write_eeprom_location(struct
ftdi_context *ftdi, int eeprom_addr,
     }

     if (ftdi_read_eeprom_location( ftdi, chip_type_location>>1, &chip_type))
-        ftdi_error_return(-5, "Reading failed failed");
+        ftdi_error_return(-5, "Reading failed");
     fprintf(stderr," loc 0x%04x val 0x%04x\n", chip_type_location,chip_type);
     if ((chip_type & 0xff) != 0x66)
     {
--
1.7.9.5

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe <at> developer.intra2net.com   

Matthias Brugger | 15 Apr 2013 19:13
Picon

FT2232H shows up like FT4232H

Hello all,

I have problem with my FT2232H chip:
I want to use it to communicate via sync FIFO. As the data sheet
suggests you have to reprogram the eeprom, but when using the tool
from libftdi I found that the chip id is FT4323H. Maybe someone who
used the board beforehand overwrote the value.
I tried to change the eeprom by hacking the eeprom example of the
actual libftdi version (git clone), but I did not succeed.

Can anyone tell me, how to change the chip id in the eeprom without
breaking the device.

Thanks a lot,
Matthias Brugger

--
motzblog.wordpress.com

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe <at> developer.intra2net.com   

Uwe Bonnes | 10 Apr 2013 13:18
Picon

Re: Aw: Re: FT232H:Bitbang, Access second port

>>>>> "Robert" == Robert Schilling <Fun_Extra_300 <at> gmx.net> writes:

    Robert> Sorry :/ It seems GMX has changed its default mailformat to HTML
    Robert> :( Here is my question in plain:

    Robert> I'm using a U232HM module in bitbang mode and libftdi using the
    Robert> python api.

    Robert> class FtdiSwitch: def __init__(self): self.__ftdic = ftdi.new()
    Robert> if self.__ftdic == 0: raise Exception("Error creating USB
    Robert> device", self.name()) ret = ftdi.usb_open(self.__ftdic, 0x0403,
    Robert> 0x6014) if ret < 0: raise Exception("Error opening USB device",
    Robert> self.name()) if ftdi.set_bitmode(self.__ftdic, 0xFF,
    Robert> ftdi.BITMODE_BITBANG) < 0: raise Exception("Error switching to
    Robert> bitbang mode", self.name()) def set_port(self, value):
    Robert> ftdi.write_data(self.__ftdic, chr(value), 1)

    Robert> This code snippet accesses the first port of the U232HM
    Robert> module. Since this module has 2 ports, I also would to access
    Robert> the second port.

Why do you think the module has two port? The datasheet tells:

FT232H Single Channel H
Speed USB to Multipurpos
      UART/FIFO IC

--

-- 
Uwe Bonnes                bon <at> elektron.ikp.physik.tu-darmstadt.de

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe <at> developer.intra2net.com   

Bryan.Richmond | 9 Apr 2013 18:21
Favicon

found a bug in libftdi

I wasn't to sure where/who to send this to

The current master branch (commit: 68e78641352b9ae737f15bd55d93b11739fd333b) of libftdi won't compile.

I get the folling error after running make

bryan <at> bryan-VirtualBox:/app/src/libftdi$ make
[  5%] Building C object src/CMakeFiles/ftdi1.dir/ftdi.c.o
/app/src/libftdi/src/ftdi.c: In function ‘ftdi_set_eeprom_value’:
/app/src/libftdi/src/ftdi.c:3775:5: error: ‘eeprom’ undeclared (first use in this function)
/app/src/libftdi/src/ftdi.c:3775:5: note: each undeclared identifier is reported only once for each function it appears in
make[2]: *** [src/CMakeFiles/ftdi1.dir/ftdi.c.o] Error 1
make[1]: *** [src/CMakeFiles/ftdi1.dir/all] Error 2
make: *** [all] Error 2
bryan <at> bryan-VirtualBox:/app/src/libftdi$

heres the code from that line,which was added in the lattest commit on the master branch:

eeprom->initialized_for_connected_device = 0;

if you change this to

ftdi->eeprom->initialized_for_connected_device = 0;

it compiles just fine.  Although I haven't tried using the library yet it yet.

Bryan T. Richmond
Software Engineer
Environmental Sensors

INFICON, Inc
2 Technology Place
East Syracuse, NY 13057-9714

Phone: (315) 434-2559
Fax:      (315) 437-3803

E-Mail: bryan.richmond <at> INFICON.com
Web: www.INFICON.com

**********************************************************************
NOTICE: - This message including any attachments is intended only for the use of the designated recipient(s) named above and may contain confidential information protected by law.  If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or the taking of any action in reliance on the contents of this information is strictly prohibited.  If you have received this transmission in error, please notify the sender immediately by e-mail and delete the original message including any attachments.
***********************************************************************

libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe <at> developer.intra2net.com


Gmane