Skip to content

Commit

Permalink
ftdipp_mpsse: add workaround for libftdi < 1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
trabucayre committed Nov 19, 2019
1 parent ec8d890 commit 0a604ba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ OBJS= $(SRC:.cpp=.o)
LDFLAGS=-lm -g -Wall -std=c++11 $(shell pkg-config --libs libftdipp1 libudev)
CXXFLAGS=-g -Wall -std=c++11 $(shell pkg-config --cflags libftdipp1 libudev)

# libftdi < 1.4 as no usb_addr
ifeq ($(shell pkg-config --atleast-version=1.4 libftdipp1 && echo 1),)
CXXFLAGS+=-DOLD_FTDI_VERSION=1
else
CXXFLAGS+=-DOLD_FTDI_VERSION=0
endif

all:$(EXEC_NAME)

$(EXEC_NAME):$(OBJS)
Expand Down
4 changes: 4 additions & 0 deletions ftdipp_mpsse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ void FTDIpp_MPSSE::open_device(unsigned int baudrate)
if (_bus == -1 or _addr == -1)
ret = ftdi_usb_open_desc(_ftdi, _vid, _pid, NULL, NULL);
else
#if (OLD_FTDI_VERSION == 1)
ret = ftdi_usb_open_desc(_ftdi, _vid, _pid, _product, NULL);
#else
ret = ftdi_usb_open_bus_addr(_ftdi, _bus, _addr);
#endif
if (ret < 0) {
fprintf(stderr, "unable to open ftdi device: %d (%s)\n",
ret, ftdi_get_error_string(_ftdi));
Expand Down

0 comments on commit 0a604ba

Please sign in to comment.