The branch, master has been updated
via fea34d21e44901df53210ec189ef6777cfbd58a0 (commit)
from 2e4e22c4f690d858b3d3a07f49b3ab8ad35b9cff (commit)
- Log -----------------------------------------------------------------
commit fea34d21e44901df53210ec189ef6777cfbd58a0
Author: Uwe Bonnes <bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Date: Wed Jul 20 11:12:49 2011 +0200
Rename serial_read to serial_test, as now write is also possible
-----------------------------------------------------------------------
Summary of changes:
examples/CMakeLists.txt | 4 +-
examples/Makefile.am | 2 +-
examples/serial_read.c | 85 -----------------------------------------------
examples/serial_test.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 88 insertions(+), 88 deletions(-)
delete mode 100644 examples/serial_read.c
create mode 100644 examples/serial_test.c
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index d8be6f5..10ed02b 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -18,7 +18,7 @@ if (EXAMPLES)
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)
+ add_executable(serial_test serial_test.c)
add_executable(baud_test baud_test.c)
add_executable(stream_test stream_test.c)
add_executable(eeprom eeprom.c)
@@ -30,7 +30,7 @@ if (EXAMPLES)
target_link_libraries(bitbang_cbus ftdi)
target_link_libraries(bitbang_ft2232 ftdi)
target_link_libraries(find_all ftdi)
- target_link_libraries(serial_read ftdi)
+ target_link_libraries(serial_test ftdi)
target_link_libraries(baud_test ftdi)
target_link_libraries(stream_test ftdi)
target_link_libraries(eeprom ftdi)
diff --git a/examples/Makefile.am b/examples/Makefile.am
index f45c7e5..7c0737a 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -17,7 +17,7 @@ all_examples = simple \
bitbang_ft2232 \
bitbang_cbus \
find_all \
- serial_read \
+ serial_test \
baud_test \
$(examples_libftdipp)
else
diff --git a/examples/serial_read.c b/examples/serial_read.c
deleted file mode 100644
index aec18d0..0000000
--- a/examples/serial_read.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/* serial_read.c
-
- Read data via serial I/O
-
- This program is distributed under the GPL, version 2
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <getopt.h>
-#include <ftdi.h>
-
-int main(int argc, char **argv)
-{
- struct ftdi_context ftdic;
- unsigned 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);
-
- return 0;
-}
diff --git a/examples/serial_test.c b/examples/serial_test.c
new file mode 100644
index 0000000..aec18d0
--- /dev/null
+++ b/examples/serial_test.c
@@ -0,0 +1,85 @@
+/* serial_read.c
+
+ Read data via serial I/O
+
+ This program is distributed under the GPL, version 2
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <ftdi.h>
+
+int main(int argc, char **argv)
+{
+ struct ftdi_context ftdic;
+ unsigned 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);
+
+ return 0;
+}
hooks/post-receive
--
port libftdi to libusb-1.0
--
libftdi-git - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi-git+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx
|