The branch, master has been updated
via 92cbae17a56ce3c6e5f01ea89dafaec75d865be7 (commit)
via 3cfec24204a9b8b7e9716587b3c0763a72d218b0 (commit)
via 0220adfa93f4baab153efbe71873551f0325a42f (commit)
from 9a602b8a7d7963b7d19fed7da68899ed39ac720f (commit)
- Log -----------------------------------------------------------------
commit 92cbae17a56ce3c6e5f01ea89dafaec75d865be7
Merge: 9a602b8a7d7963b7d19fed7da68899ed39ac720f
3cfec24204a9b8b7e9716587b3c0763a72d218b0
Author: Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx>
Date: Thu Sep 29 11:09:35 2011 +0200
Merge remote-tracking branch 'origin/get-library-version'
-----------------------------------------------------------------------
Summary of changes:
examples/simple.c | 6 ++++++
src/CMakeLists.txt | 14 ++++++++++++++
src/ftdi.c | 18 ++++++++++++++++++
src/ftdi.h | 19 +++++++++++++++++++
src/ftdi_version_i.h.in | 11 +++++++++++
5 files changed, 68 insertions(+), 0 deletions(-)
create mode 100644 src/ftdi_version_i.h.in
diff --git a/examples/simple.c b/examples/simple.c
index 145e931..9fac121 100644
--- a/examples/simple.c
+++ b/examples/simple.c
@@ -13,12 +13,18 @@ int main(void)
{
int ret;
struct ftdi_context ftdic;
+ struct ftdi_version_info version;
if (ftdi_init(&ftdic) < 0)
{
fprintf(stderr, "ftdi_init failed\n");
return EXIT_FAILURE;
}
+ version = ftdi_get_library_version();
+ printf("Initialized libftdi %s (major: %d, minor: %d, micro: %d, snapshot
ver: %s)\n",
+ version.version_str, version.major, version.minor, version.micro,
+ version.snapshot_str);
+
if ((ret = ftdi_usb_open(&ftdic, 0x0403, 0x6001)) < 0)
{
fprintf(stderr, "unable to open ftdi device: %d (%s)\n", ret,
ftdi_get_error_string(&ftdic));
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 0816341..b7ae085 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -3,6 +3,20 @@ include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
)
+# Version information
+set(SNAPSHOT_VERSION "unknown")
+execute_process(COMMAND git describe
+ OUTPUT_VARIABLE GIT_DESCRIBE_OUTPUT
+ RESULT_VARIABLE GIT_DESCRIBE_RESULT
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+if(${GIT_DESCRIBE_RESULT} STREQUAL 0)
+ set(SNAPSHOT_VERSION ${GIT_DESCRIBE_OUTPUT})
+endif(${GIT_DESCRIBE_RESULT} STREQUAL 0)
+message(STATUS "Detected git snapshot version: ${SNAPSHOT_VERSION}")
+
+configure_file(ftdi_version_i.h.in
"${CMAKE_CURRENT_BINARY_DIR}/ftdi_version_i.h" @ONLY)
+
# Targets
set(c_sources ftdi.c ftdi_stream.c)
set(c_headers ftdi.h)
diff --git a/src/ftdi.c b/src/ftdi.c
index fba5288..de5ded1 100644
--- a/src/ftdi.c
+++ b/src/ftdi.c
@@ -35,6 +35,7 @@
#include <stdlib.h>
#include "ftdi.h"
+#include "ftdi_version_i.h"
#define ftdi_error_return(code, str) do { \
ftdi->error_str = str; \
@@ -257,6 +258,23 @@ void ftdi_set_usbdev (struct ftdi_context *ftdi,
libusb_device_handle *usb)
ftdi->usb_dev = usb;
}
+/**
+ * @brief Get libftdi library version
+ *
+ * @return ftdi_version_info Library version information
+ **/
+struct ftdi_version_info ftdi_get_library_version()
+{
+ struct ftdi_version_info ver;
+
+ ver.major = FTDI_MAJOR_VERSION;
+ ver.minor = FTDI_MINOR_VERSION;
+ ver.micro = FTDI_MICRO_VERSION;
+ ver.version_str = FTDI_VERSION_STRING;
+ ver.snapshot_str = FTDI_SNAPSHOT_VERSION;
+
+ return ver;
+}
/**
Finds all ftdi devices with given VID:PID on the usb bus. Creates a new
diff --git a/src/ftdi.h b/src/ftdi.h
index 4e3880e..759e61b 100644
--- a/src/ftdi.h
+++ b/src/ftdi.h
@@ -498,6 +498,23 @@ typedef struct
typedef int (FTDIStreamCallback)(uint8_t *buffer, int length,
FTDIProgressInfo *progress, void *userdata);
+/**
+ * Provide libftdi version information
+ * major: Library major version
+ * minor: Library minor version
+ * micro: Currently unused, ight get used for hotfixes.
+ * version_str: Version as (static) string
+ * snapshot_str: Git snapshot version if known. Otherwise "unknown" or empty
string.
+*/
+struct ftdi_version_info
+{
+ int major;
+ int minor;
+ int micro;
+ const char *version_str;
+ const char *snapshot_str;
+};
+
#ifdef __cplusplus
extern "C"
@@ -512,6 +529,8 @@ extern "C"
void ftdi_free(struct ftdi_context *ftdi);
void ftdi_set_usbdev (struct ftdi_context *ftdi, struct
libusb_device_handle *usbdev);
+ struct ftdi_version_info ftdi_get_library_version();
+
int ftdi_usb_find_all(struct ftdi_context *ftdi, struct ftdi_device_list
**devlist,
int vendor, int product);
void ftdi_list_free(struct ftdi_device_list **devlist);
diff --git a/src/ftdi_version_i.h.in b/src/ftdi_version_i.h.in
new file mode 100644
index 0000000..89e549a
--- /dev/null
+++ b/src/ftdi_version_i.h.in
@@ -0,0 +1,11 @@
+#ifndef FTDI_VERSION_INTERNAL_H
+#define FTDI_VERSION_INTERNAL_H
+
+#define FTDI_MAJOR_VERSION @MAJOR_VERSION@
+#define FTDI_MINOR_VERSION @MINOR_VERSION@
+#define FTDI_MICRO_VERSION 0
+
+const char FTDI_VERSION_STRING[] = "@VERSION_STRING@";
+const char FTDI_SNAPSHOT_VERSION[] = "@SNAPSHOT_VERSION@";
+
+#endif
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
|