The branch, master has been updated
via 6e828229089a09995a40ea1d0eaf96d775f8a3d2 (commit)
via 6167b919c63aae59b862fe80c293f628300c216c (commit)
via d69dbd9e2fb3b5b703bca5211cd297072415b147 (commit)
from e2f12a4fb7a27243c9c8fef2755b9ace5751fe5e (commit)
- Log -----------------------------------------------------------------
commit 6e828229089a09995a40ea1d0eaf96d775f8a3d2
Author: Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx>
Date: Fri Dec 4 10:12:15 2009 +0100
Updated ChangeLog
commit 6167b919c63aae59b862fe80c293f628300c216c
Author: Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx>
Date: Fri Dec 4 09:57:03 2009 +0100
Renamed examples/sio to examples/serial_read
commit d69dbd9e2fb3b5b703bca5211cd297072415b147
Author: Jim Paris <jim@xxxxxxxx>
Date: Wed Dec 2 18:13:44 2009 -0500
examples: add sio example
Simple example to just receive and print data.
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 3 ++
examples/CMakeLists.txt | 2 +
examples/Makefile.am | 2 +
examples/serial_read.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++
libftdi.spec.in | 3 +-
5 files changed, 90 insertions(+), 1 deletions(-)
create mode 100644 examples/serial_read.c
diff --git a/ChangeLog b/ChangeLog
index 305eedf..376175e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
New in 0.17 - 2009-XX-XX
------------------------
+* New serial input example code (Jim Paris)
+* Fix modem status byte filtering for USB high speed chips (Intra2net and Jim
Paris)
+* Add bitmode for synchronous fifo in FT2232H (Uwe Bonnes)
* Fix usb_set_configuration() call on Windows 64 (NIL)
* Fix usb index in ftdi_convert_baudrate() for FT2232H/FT4232H chips (Thimo
Eichstaedt)
* Set initial baudrate on correct interface instead of always the first one
(Thimo Eichstaedt)
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index ccd2f89..7be0978 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -13,6 +13,7 @@ add_executable(bitbang2 bitbang2.c)
add_executable(bitbang_cbus bitbang_cbus.c)
add_executable(bitbang_ft2232 bitbang_ft2232.c)
add_executable(find_all find_all.c)
+add_executable(serial_read serial_read.c)
# Linkage
target_link_libraries(simple ftdi)
@@ -21,6 +22,7 @@ target_link_libraries(bitbang2 ftdi)
target_link_libraries(bitbang_cbus ftdi)
target_link_libraries(bitbang_ft2232 ftdi)
target_link_libraries(find_all ftdi)
+target_link_libraries(serial_read ftdi)
# libftdi++ examples
if(FTDI_BUILD_CPP)
diff --git a/examples/Makefile.am b/examples/Makefile.am
index bcd50ec..aef1328 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -16,6 +16,7 @@ bin_PROGRAMS = simple \
bitbang_ft2232 \
bitbang_cbus \
find_all \
+ serial_read \
$(examples_libftdipp)
# Don't install the example files
@@ -27,6 +28,7 @@ bitbang2_SOURCES = bitbang2.c
bitbang_ft2232_SOURCES = bitbang_ft2232.c
bitbang_cbus_SOURCES = bitbang_cbus.c
find_all_SOURCES = find_all.c
+serial_read_SOURCES = serial_read.c
if HAVE_LIBFTDIPP
find_all_pp_SOURCES = find_all_pp.cpp
diff --git a/examples/serial_read.c b/examples/serial_read.c
new file mode 100644
index 0000000..754ca4a
--- /dev/null
+++ b/examples/serial_read.c
@@ -0,0 +1,81 @@
+/* serial_read.c
+
+ Read data via serial I/O
+
+ This program is distributed under the GPL, version 2
+*/
+
+#include <stdio.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <ftdi.h>
+
+int main(int argc, char **argv)
+{
+ struct ftdi_context ftdic;
+ char buf[1024];
+ int f, i;
+ int vid = 0x0403;
+ int pid = 0x6001;
+ int baudrate = 115200;
+ int interface = INTERFACE_ANY;
+
+ while ((i = getopt(argc, argv, "i:v:p:b:")) != -1)
+ {
+ switch (i)
+ {
+ case 'i': // 0=ANY, 1=A, 2=B, 3=C, 4=D
+ interface = strtoul(optarg, NULL, 0);
+ break;
+ case 'v':
+ vid = strtoul(optarg, NULL, 0);
+ break;
+ case 'p':
+ pid = strtoul(optarg, NULL, 0);
+ break;
+ case 'b':
+ baudrate = strtoul(optarg, NULL, 0);
+ break;
+ default:
+ fprintf(stderr, "usage: %s [-i interface] [-v vid] [-p pid] [-b
baudrate]\n", *argv);
+ exit(-1);
+ }
+ }
+
+ // Init
+ if (ftdi_init(&ftdic) < 0)
+ {
+ fprintf(stderr, "ftdi_init failed\n");
+ return EXIT_FAILURE;
+ }
+
+ // Select first interface
+ ftdi_set_interface(&ftdic, interface);
+
+ // Open device
+ f = ftdi_usb_open(&ftdic, vid, pid);
+ if (f < 0)
+ {
+ fprintf(stderr, "unable to open ftdi device: %d (%s)\n", f,
ftdi_get_error_string(&ftdic));
+ exit(-1);
+ }
+
+ // Set baudrate
+ f = ftdi_set_baudrate(&ftdic, 115200);
+ if (f < 0)
+ {
+ fprintf(stderr, "unable to set baudrate: %d (%s)\n", f,
ftdi_get_error_string(&ftdic));
+ exit(-1);
+ }
+
+ // Read data forever
+ while ((f = ftdi_read_data(&ftdic, buf, sizeof(buf))) >= 0) {
+ fprintf(stderr, "read %d bytes\n", f);
+ fwrite(buf, f, 1, stdout);
+ fflush(stderr);
+ fflush(stdout);
+ }
+
+ ftdi_usb_close(&ftdic);
+ ftdi_deinit(&ftdic);
+}
diff --git a/libftdi.spec.in b/libftdi.spec.in
index 8ce8a37..4f69daa 100644
--- a/libftdi.spec.in
+++ b/libftdi.spec.in
@@ -41,7 +41,7 @@ make
%install
make DESTDIR=$RPM_BUILD_ROOT install
-# Cleanup
+# Remove example programs
rm -f $RPM_BUILD_ROOT/usr/bin/simple
rm -f $RPM_BUILD_ROOT/usr/bin/bitbang
rm -f $RPM_BUILD_ROOT/usr/bin/bitbang2
@@ -49,6 +49,7 @@ rm -f $RPM_BUILD_ROOT/usr/bin/bitbang_ft2232
rm -f $RPM_BUILD_ROOT/usr/bin/bitbang_cbus
rm -f $RPM_BUILD_ROOT/usr/bin/find_all
rm -f $RPM_BUILD_ROOT/usr/bin/find_all_pp
+rm -f $RPM_BUILD_ROOT/usr/bin/serial_read
%clean
rm -fr $RPM_BUILD_ROOT
hooks/post-receive
--
A library to talk to FTDI chips
--
libftdi-git - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi-git+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx
|