使用Linux的FTDI TTL

时间:2013-07-17 16:21:25

标签: linux serial-port driver

为了向外部设备发送命令,我使用FTDI的TTL-232R-3V3线。我想设置特定的路径从高到低。不需要奇偶校验或停止位。

我的操作系统是Ubuntu Linux 13.04。

我想开发一个Java或C应用程序,它可以发送这些命令。但是当我尝试为电线安装驱动程序时出现错误:

我正在关注this指令,我决定安装D2XX驱动程序。我认为我已成功安装了共享对象和静态库,如步骤2.1所述,无论如何我没有收到任何错误消息。

但是当我尝试编译示例代码时,如步骤3所述,我得到了以下输出执行make -B命令。

for n in BitMode EEPROM/erase EEPROM/read EEPROM/write EEPROM/user/read EEPROM/user/size EEPROM/user/write Events LargeRead MultiThread SetVIDPID Simple Timeouts ; do make -C $n || exit 1; done
make[1]: Betrete Verzeichnis '/home/robin/Dokumente/Java/Stepper/lib/release/examples/BitMode'
gcc main.c -o bitmode -Wall -Wextra -L. -lftd2xx -Wl,-rpath /usr/local/lib  
make[1]: Verlasse Verzeichnis '/home/robin/Dokumente/Java/Stepper/lib/release/examples/BitMode'
make[1]: Betrete Verzeichnis '/home/robin/Dokumente/Java/Stepper/lib/release/examples/EEPROM/erase'
gcc main.c -o erase -Wall -Wextra -L. -lftd2xx -Wl,-rpath /usr/local/lib
make[1]: Verlasse Verzeichnis '/home/robin/Dokumente/Java/Stepper/lib/release/examples/EEPROM/erase'
make[1]: Betrete Verzeichnis '/home/robin/Dokumente/Java/Stepper/lib/release/examples/EEPROM/read'
gcc main.c -o read -Wall -Wextra -L. -lftd2xx -Wl,-rpath /usr/local/lib
make[1]: Verlasse Verzeichnis '/home/robin/Dokumente/Java/Stepper/lib/release/examples/EEPROM/read'
make[1]: Betrete Verzeichnis '/home/robin/Dokumente/Java/Stepper/lib/release/examples/EEPROM/write'
gcc main.c -o write -Wall -Wextra -L. -lftd2xx -Wl,-rpath /usr/local/lib
make[1]: Verlasse Verzeichnis '/home/robin/Dokumente/Java/Stepper/lib/release/examples/EEPROM/write'
make[1]: Betrete Verzeichnis '/home/robin/Dokumente/Java/Stepper/lib/release/examples/EEPROM/user/read'
gcc main.c -o readua -Wall -Wextra -L. -lftd2xx -Wl,-rpath /usr/local/lib
make[1]: Verlasse Verzeichnis '/home/robin/Dokumente/Java/Stepper/lib/release/examples/EEPROM/user/read'
make[1]: Betrete Verzeichnis '/home/robin/Dokumente/Java/Stepper/lib/release/examples/EEPROM/user/size'
gcc main.c -o sizeua -Wall -Wextra -L. -lftd2xx -Wl,-rpath /usr/local/lib
make[1]: Verlasse Verzeichnis '/home/robin/Dokumente/Java/Stepper/lib/release/examples/EEPROM/user/size'
make[1]: Betrete Verzeichnis '/home/robin/Dokumente/Java/Stepper/lib/release/examples/EEPROM/user/write'
gcc main.c -o writeua -Wall -Wextra -L. -lftd2xx -Wl,-rpath /usr/local/lib
make[1]: Verlasse Verzeichnis '/home/robin/Dokumente/Java/Stepper/lib/release/examples/EEPROM/user/write'
make[1]: Betrete Verzeichnis '/home/robin/Dokumente/Java/Stepper/lib/release/examples/Events'
gcc main.c -o events -Wall -Wextra -L. -lftd2xx -Wl,-rpath /usr/local/lib
make[1]: Verlasse Verzeichnis '/home/robin/Dokumente/Java/Stepper/lib/release/examples/Events'
make[1]: Betrete Verzeichnis '/home/robin/Dokumente/Java/Stepper/lib/release/examples/LargeRead'
gcc main.c -o largeread -Wall -Wextra -L. -lftd2xx -Wl,-rpath /usr/local/lib
make[1]: Verlasse Verzeichnis '/home/robin/Dokumente/Java/Stepper/lib/release/examples/LargeRead'
make[1]: Betrete Verzeichnis '/home/robin/Dokumente/Java/Stepper/lib/release/examples/MultiThread'
gcc main.c -o multi -Wall -Wextra -L. -lftd2xx -Wl,-rpath /usr/local/lib
make[1]: Verlasse Verzeichnis '/home/robin/Dokumente/Java/Stepper/lib/release/examples/MultiThread'
gcc main.c -o multi -Wall -Wextra -L. -lftd2xx -Wl,-rpath /usr/local/lib
/usr/bin/ld: /tmp/ccoAsrRg.o: undefined reference to symbol     'pthread_create@@GLIBC_2.2.5'
/usr/bin/ld: note: 'pthread_create@@GLIBC_2.2.5' is defined in DSO /lib/x86_64-linux-    gnu/libpthread.so.0 so try adding it to the linker command line
/lib/x86_64-linux-gnu/libpthread.so.0: could not read symbols: Ungültiger Vorgang
collect2: Fehler: ld gab 1 als Ende-Status zurück
make[1]: *** [multi] Fehler 1
make[1]: Verlasse Verzeichnis '/home/robin/Dokumente/Java/Stepper/lib/release/examples    /MultiThread'
make: *** [subdirs] Fehler 1

如何修复该错误?有人遇到过这种电线和Linux吗? 提前谢谢!

1 个答案:

答案 0 :(得分:0)

某些示例或其中一个依赖项正在使用pthread,但没有为其配置Makefile。

编辑Makefile并将-pthread添加到CFLAGSLDFLAGS。您可以通过添加行

来实现
CFLAGS += -pthread
LDFLAGS += -pthread

但是,您可能根本不需要D2XX库。 FTDI内核驱动程序应该创建一个/dev/ttyUSB n 设备,您可以像“真正的”串行端口一样使用它。