diff --git a/Deployment.md b/Deployment.md
index 18e1be1..05fee3c 100644
--- a/Deployment.md
+++ b/Deployment.md
@@ -30,9 +30,7 @@ _All rights reserved._
- `$(PROJROOT)/Sources/Swift/CANAPI.swift`
- `$(PROJROOT)/Libraries/CANAPI/Makefile`*
- `$(PROJROOT)/Libraries/TouCAN/Makefile`*
- - `$(PROJROOT)/Utilities/can_moni/Makefile`
- `$(PROJROOT)/Utilities/can_moni/README.md`
- - `$(PROJROOT)/Utilities/can_test/Makefile`
- `$(PROJROOT)/Utilities/can_test/README.md`
*_) Set variable_ `CURRENT_VERSION` _and_ `COMPATIBILITY_VERSION` _accordingly._
@@ -103,7 +101,7 @@ _All rights reserved._
1. Click on `Draft a new release` in the [GitHub](https://github.com/mac-can/RusokuCAN) repo.
2. Fill out all required fields:
- - Tag version: e.g `v0.3` (cf. semantic versioning)
+ - Tag version: e.g `v0.3.1` (cf. semantic versioning)
- Target: `main` (default branch)
- Release title: e.g. `Release of January 19, 2038`
- Change-log: list all major changes, e.g. from commit comments
diff --git a/Libraries/CANAPI/Makefile b/Libraries/CANAPI/Makefile
index 6566b2b..bd1f9cd 100644
--- a/Libraries/CANAPI/Makefile
+++ b/Libraries/CANAPI/Makefile
@@ -51,7 +51,7 @@ current_OS := $(patsubst MSYS%,MinGW,$(current_OS))
MAJOR = 0
MINOR = 3
-PATCH = 0
+PATCH = 1
ifeq ($(PATCH),0)
VERSION = $(MAJOR).$(MINOR)
diff --git a/Libraries/TouCAN/Makefile b/Libraries/TouCAN/Makefile
index 0e23d4b..ecd18cb 100644
--- a/Libraries/TouCAN/Makefile
+++ b/Libraries/TouCAN/Makefile
@@ -51,7 +51,7 @@ current_OS := $(patsubst MSYS%,MinGW,$(current_OS))
MAJOR = 0
MINOR = 3
-PATCH = 0
+PATCH = 1
ifeq ($(PATCH),0)
VERSION = $(MAJOR).$(MINOR)
diff --git a/Package.swift b/Package.swift
index ea1e510..9e75a7d 100644
--- a/Package.swift
+++ b/Package.swift
@@ -66,7 +66,7 @@ let package = Package(
CSetting.define("OPTION_TOUCAN_DYLIB=1"),
CSetting.define("OPTION_CANAPI_TOUCAN_DYLIB=0"),
CSetting.define("OPTION_CANAPI_DRIVER=1"),
- CSetting.define("OPTION_CANAPI_RETVALS=1"),
+ CSetting.define("OPTION_CANAPI_RETVALS=0"),
CSetting.define("OPTION_CANAPI_COMPANIONS=1"),
CSetting.define("OPTION_MACCAN_LOGGER=0"),
CSetting.define("OPTION_MACCAN_MULTICHANNEL=0"),
diff --git a/README.md b/README.md
index 870dc04..61fc64d 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
### macOS® User-Space Driver for TouCAN USB Interfaces from Rusoku
-_Copyright © 2020-2024 Uwe Vogt, UV Software, Berlin (info@mac-can.com)_
+_Copyright © 2020-2024 Uwe Vogt, UV Software, Berlin (info@mac-can.com)_
![macOS Build](https://github.com/mac-can/RusokuCAN.dylib/actions/workflows/macos-build.yml/badge.svg)
@@ -131,13 +131,13 @@ Type `can_test --help` to display all program options.
#### macOS Sonoma
-- macOS Sonoma (14.4.1) on a Mac mini (M1, 2020)
+- macOS Sonoma (14.5) on a Mac mini (M1, 2020)
- Apple clang version 15.0.0 (clang-1500.3.9.4)
-- Xcode Version 15.3 (15E204a)
+- Xcode Version 15.4 (15F31d)
#### macOS Monterey
-- macOS Monterey (12.7.4) on a MacBook Pro (2019)
+- macOS Monterey (12.7.5) on a MacBook Pro (2019)
- Apple clang version 13.0.0 (clang-1300.0.29.30)
- Xcode Version 13.2.1 (13C100)
@@ -153,7 +153,7 @@ For a list of known bugs and caveats see tab [Issues](https://github.com/mac-can
### CAN API V3 Reference
-A generic documentation of the CAN API V3 application programming interface can be found [here](https://uv-software.github.io/CANAPI-Docs/#/).
+A generic documentation of the CAN API V3 application programming interface can be found [here](https://uv-software.github.io/CANAPI-Docs).
### Dual-License
@@ -161,8 +161,6 @@ Except where otherwise noted, this work is dual-licensed under the terms of the
and under the terms of the GNU General Public License v3.0 (or any later version).
You can choose between one of them if you use these portions of this work in whole or in part.
-`SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-or-later`
-
### Trademarks
Mac and macOS are trademarks of Apple Inc., registered in the U.S. and other countries. \
diff --git a/Sources/CANAPI/.gitignore b/Sources/CANAPI/.gitignore
index 3ed3371..c30c556 100644
--- a/Sources/CANAPI/.gitignore
+++ b/Sources/CANAPI/.gitignore
@@ -1,3 +1,8 @@
-.svn/
+.svn
# we don't use the JSON files yet
can_dev.?
+vanilla.?
+# other blacklisted files
+SerialCAN_Defines.h
+SocketCAN_Defines.h
+RocketCAN_Defines.h
diff --git a/Sources/CANAPI/CANAPI.h b/Sources/CANAPI/CANAPI.h
index c774abb..7cdf20d 100644
--- a/Sources/CANAPI/CANAPI.h
+++ b/Sources/CANAPI/CANAPI.h
@@ -73,9 +73,9 @@
/// zero to compile your program with the CAN API source files or to
/// link your program with the static library at compile-time.
///
-/// \author $Author: eris $
+/// \author $Author: quaoar $
//
-/// \version $Rev: 1270 $
+/// \version $Rev: 1294 $
//
/// \defgroup can_api CAN Interface API, Version 3
/// \{
@@ -191,7 +191,20 @@ class CANCPP CCanApi {
char m_szVendorName[CANPROP_MAX_BUFFER_SIZE]; ///< vendor name at actual index in the vendor list
char m_szVendorDllName[CANPROP_MAX_BUFFER_SIZE]; ///< file name of the DLL at actual index in the vendor list
};
- /// \brief query library information of the first CAN API library in the
+ /// \brief sets the search path for readings library informations from
+ /// JSON files.
+ //
+ /// \note The search path can only be set once, either by ths function
+ /// or by the non-default constructor with a path argument.
+ //
+ /// \param[in] path - path name, or NULL for current working directory
+ //
+ /// \returns true if the search path has been successfully set, or
+ /// false on error.
+ //
+ static bool SetSearchPath(const char *path);
+
+ /// \brief queries library information of the first CAN API library in the
/// list of vendors, if any.
//
/// \param[out] info - the library information of the first entry in the list
@@ -201,7 +214,7 @@ class CANCPP CCanApi {
//
static bool GetFirstLibrary(SLibraryInfo &info);
- /// \brief query library information of the next CAN API library in the
+ /// \brief queries library information of the next CAN API library in the
/// list of vendors, if any.
//
/// \param[out] info - the library information of the next entry in the list
@@ -211,7 +224,7 @@ class CANCPP CCanApi {
//
static bool GetNextLibrary(SLibraryInfo &info);
#endif
- /// \brief query channel information of the first CAN interface in the
+ /// \brief queries channel information of the first CAN interface in the
/// list of CAN interfaces, if any.
//
/// \param[in] library - library id of the CAN interface list, or -1 for all vendors
@@ -227,7 +240,7 @@ class CANCPP CCanApi {
static bool GetFirstChannel(SChannelInfo &info, void *param = NULL);
#endif
- /// \brief query channel information of the next CAN interface in the
+ /// \brief queries channel information of the next CAN interface in the
/// list of CAN interfaces, if any.
//
/// \param[out] info - the channel information of the next entry in the list
@@ -464,8 +477,16 @@ class CANCPP CCanApi {
//
virtual char *GetFirmwareVersion() = 0; // deprecated
- /// \brief retrieves version information of the CAN API V3 driver
- /// as a zero-terminated string.
+#if (OPTION_CANAPI_LIBRARY != 0)
+ /// \brief retrieves version information of the CAN API V3 wrapper
+ /// library as a zero-terminated string.
+ //
+ /// \returns pointer to a zero-terminated string, or NULL on error.
+ //
+ virtual char *GetSoftwareVersion() = 0; // deprecated
+#endif
+ /// \brief retrieves version information of the CAN API V3 wrapper
+ /// (or loader) library as a zero-terminated string.
//
/// \returns pointer to a zero-terminated string, or NULL on error.
//
@@ -515,4 +536,4 @@ class CANCPP CCanApi {
/// \}
#endif // CANAPI_H_INCLUDED
/// \}
-// $Id: CANAPI.h 1270 2024-04-15 18:42:43Z eris $ Copyright (c) UV Software //
+// $Id: CANAPI.h 1294 2024-05-16 19:50:25Z quaoar $ Copyright (c) UV Software //
diff --git a/Sources/CANAPI/CANAPI_Defines.h b/Sources/CANAPI/CANAPI_Defines.h
index e9b8bef..8c64414 100644
--- a/Sources/CANAPI/CANAPI_Defines.h
+++ b/Sources/CANAPI/CANAPI_Defines.h
@@ -49,9 +49,9 @@
*
* @brief CAN API V3 for generic CAN Interfaces - Definitions and Options
*
- * @author $Author: eris $
+ * @author $Author: quaoar $
*
- * @version $Rev: 1270 $
+ * @version $Rev: 1293 $
*
* @addtogroup can_api
* @{
@@ -79,23 +79,25 @@ extern "C" {
/** @name Library IDs
* @brief Unique IDs to identify a CAN API library (CAN API V1 compatible)
+ * @note These defines are still valid, but IDs are taken from JSON files.
* @{ */
#define CANLIB_IXXAT_VCI 100 /**< IXXAT Virtual CAN interfaces */
#define CANLIB_IXXAT_CAC 800 /**< IXXAT canAnalyzer/32 Client */
-#define CANLIB_PEAK_PCAN 200 /**< PEAK PCAN interfaces */
+#define CANLIB_PEAK_PCAN 200 /**< PEAK PCAN-Light interfaces */
#define CANLIB_VECTOR_XL 300 /**< Vector XL-Driver library */
#define CANLIB_PCANBASIC 400 /**< PEAK PCAN-Basic interfaces */
-#define CANLIB_RUSOKU_LT 500 /**< Rusuko TouCAN interfaces */
+#define CANLIB_RUSOKU_LT 500 /**< Rusoku TouCAN interfaces */
#define CANLIB_KVASER_32 600 /**< Kvaser CANLIB (canlib32) */
#define CANLIB_ROCKETCAN 700 /**< CAN-over-IP (RocketCAN) */
#define CANLIB_SERIALCAN 900 /**< Serial-Line (SerialCAN) */
-#define CANLIB_SOCKETCAN 1000 /**< Linux CAN (SocketCAN) */
+#define CANLIB_SOCKETCAN 1000 /**< Linux-CAN (SocketCAN) */
#define CANLIB_CANAPILIB (-1) /**< CAN API Main Library */
-/** @note Peak's PCAN-Light DLL is outdated, so the library ID can be reused.
+/** @note PCAN-Light is outdated, its ID is reused by macCAN-PeakCAN.
* @} */
/** @name Library Names
* @brief Filenames of the CAN API libraries (depending on the platform)
+ * @note Theses defines are outdated. DLL names are taken from JSON files.
* @{ */
#if defined(__linux__)
#define CANAPI_PLATFORM "Linux"
@@ -154,9 +156,9 @@ extern "C" {
#define CAN_API_WEBSITE "www.uv-software.com"
#define CAN_API_CONTACT "info@uv-software.com"
#define CAN_API_LICENSE "BSD-2-Clause OR GPL-3.0-or-later"
-#define CAN_API_COPYRIGHT "Copyright (c) 2005-20%02u, UV Software, Berlin"
-#define CAN_API_HAZARD_NOTE "Do not connect your CAN device to a real CAN network when using this program.\n" \
- "This can damage your application."
+#define CAN_API_COPYRIGHT "Copyright (c) 2004-20%02u, UV Software, Berlin"
+#define CAN_API_HAZARD_NOTE "If you connect your CAN device to a real CAN network when using this library,\n" \
+ "you might damage your application."
/** @} */
diff --git a/Sources/CANAPI/CANAPI_Types.h b/Sources/CANAPI/CANAPI_Types.h
index c3ab159..017e81e 100644
--- a/Sources/CANAPI/CANAPI_Types.h
+++ b/Sources/CANAPI/CANAPI_Types.h
@@ -49,9 +49,9 @@
*
* @brief CAN API V3 for generic CAN Interfaces - Data Types and Defines
*
- * @author $Author: eris $
+ * @author $Author: quaoar $
*
- * @version $Rev: 1270 $
+ * @version $Rev: 1286 $
*
* @addtogroup can_api
* @{
@@ -320,13 +320,13 @@ extern "C" {
#define CANPROP_GET_PATCH_NO 2U /**< patch number of the library (uint8_t) */
#define CANPROP_GET_BUILD_NO 3U /**< build number of the library (uint32_t) */
#define CANPROP_GET_LIBRARY_ID 4U /**< library id of the library (int32_t) */
-#define CANPROP_GET_LIBRARY_VENDOR 5U /**< vendor name of the library (char[256]) */
-#define CANPROP_GET_LIBRARY_DLLNAME 6U /**< file name of the library DLL (char[256]) */
+#define CANPROP_GET_LIBRARY_VENDOR 5U /**< vendor name of the library (char[]) */
+#define CANPROP_GET_LIBRARY_DLLNAME 6U /**< file name of the library DLL (char[]) */
#define CANPROP_GET_DEVICE_TYPE 10U /**< device type of the CAN interface (int32_t) */
-#define CANPROP_GET_DEVICE_NAME 11U /**< device name of the CAN interface (char[256]) */
-#define CANPROP_GET_DEVICE_VENDOR 12U /**< vendor name of the CAN interface (char[256]) */
-#define CANPROP_GET_DEVICE_DLLNAME 13U /**< file name of the CAN interface DLL (char[256]) */
-#define CANPROP_GET_DEVICE_PARAM 14U /**< device parameter of the CAN interface (char[256]) */
+#define CANPROP_GET_DEVICE_NAME 11U /**< device name of the CAN interface (char[]) */
+#define CANPROP_GET_DEVICE_VENDOR 12U /**< vendor name of the CAN interface (char[]) */
+#define CANPROP_GET_DEVICE_DLLNAME 13U /**< file name of the CAN interface DLL (char[]) */
+#define CANPROP_GET_DEVICE_PARAM 14U /**< device parameter of the CAN interface (char[]) */
#define CANPROP_GET_OP_CAPABILITY 15U /**< supported operation modes of the CAN controller (uint8_t) */
#define CANPROP_GET_OP_MODE 16U /**< active operation mode of the CAN controller (uint8_t) */
#define CANPROP_GET_BITRATE 17U /**< active bit-rate of the CAN controller (can_bitrate_t) */
@@ -355,21 +355,21 @@ extern "C" {
#define CANPROP_GET_BTR_INDEX 64U /**< bit-rate as CiA index (int32_t) */
#define CANPROP_GET_BTR_VALUE 65U /**< bit-rate as struct (can_bitrate_t) */
#define CANPROP_GET_BTR_SPEED 66U /**< bit-rate as bus speed (can_speed_t) */
-#define CANPROP_GET_BTR_STRING 67U /**< bit-rate as string (char[256]) */
+#define CANPROP_GET_BTR_STRING 67U /**< bit-rate as string (char[]) */
#define CANPROP_GET_BTR_SJA1000 68U /**< bit-rate as SJA1000 register (uint16_t) */
#define CANPROP_SET_BTR_INDEX 72U /**< set value for conversion form CiA index (int32_t) */
#define CANPROP_SET_BTR_VALUE 73U /**< set value for conversion form struct (can_bitrate_t) */
#define CANPROP_SET_BTR_SPEED 74U /**< set value for conversion form bus speed (can_speed_t) */
-#define CANPROP_SET_BTR_STRING 75U /**< set value for conversion form string (char[256]) */
+#define CANPROP_SET_BTR_STRING 75U /**< set value for conversion form string (char[]) */
#define CANPROP_SET_BTR_SJA1000 76U /**< set value for conversion form SJA1000 register (uint16_t) */
/* - - build-in message formatter - - - - - - - - - - - - - - - - - - */
-#define CANPROP_GET_MSG_STRING 128U /**< last received or sent message as formatted string (char[1024]) */
-#define CANPROP_GET_MSG_TIME 129U /**< time-stamp of last received or sent message (char[256]) */
-#define CANPROP_GET_MSG_ID 130U /**< identifier of last received or sent message (char[256]) */
-#define CANPROP_GET_MSG_DLC 131U /**< DLC/length of last received or sent message (char[256]) */
-#define CANPROP_GET_MSG_FLAGS 132U /**< flags of last received or sent message (char[256]) */
-#define CANPROP_GET_MSG_DATA 133U /**< data of last received or sent message (char[256]) */
-#define CANPROP_GET_MSG_ASCII 134U /**< data as ASCII of last received or sent message (char[256]) */
+#define CANPROP_GET_MSG_STRING 128U /**< last received or sent message as formatted string (char[]) */
+#define CANPROP_GET_MSG_TIME 129U /**< time-stamp of last received or sent message (char[]) */
+#define CANPROP_GET_MSG_ID 130U /**< identifier of last received or sent message (char[]) */
+#define CANPROP_GET_MSG_DLC 131U /**< DLC/length of last received or sent message (char[]) */
+#define CANPROP_GET_MSG_FLAGS 132U /**< flags of last received or sent message (char[]) */
+#define CANPROP_GET_MSG_DATA 133U /**< data of last received or sent message (char[]) */
+#define CANPROP_GET_MSG_ASCII 134U /**< data as ASCII of last received or sent message (char[]) */
#define CANPROP_SET_MSG_FORMAT 144U /**< set message output format {DEFAULT, ...} (int) */
#define CANPROP_SET_FMT_TIMESTAMP 145U /**< set formatter option: time-stamp {ZERO, ABS, REL} (int) */
#define CANPROP_SET_FMT_TIEMUSEC 146U /**< set formatter option: time-stamp in usec {OFF, ON} (int) */
@@ -396,22 +396,23 @@ extern "C" {
#define CANPROP_SET_FIRST_VENDOR 224U /**< set index to the first entry in the vendor list (NULL) */
#define CANPROP_SET_NEXT_VENDOR 225U /**< set index to the next entry in the vendor list (NULL) */
#define CANPROP_GET_VENDOR_ID 226U /**< get library id at actual index in the vendor list (int32_t) */
-#define CANPROP_GET_VENDOR_NAME 227U /**< get vendor name at actual index in the vendor list (char[256]) */
-#define CANPROP_GET_VENDOR_DLLNAME 228U /**< get file name of the DLL at actual index in the vendor list (char[256]) */
+#define CANPROP_GET_VENDOR_NAME 227U /**< get vendor name at actual index in the vendor list (char[]) */
+#define CANPROP_GET_VENDOR_DLLNAME 228U /**< get file name of the DLL at actual index in the vendor list (char[]) */
#endif
#define CANPROP_SET_FIRST_CHANNEL 240U /**< set index to the first entry in the interface list (int32_t or NULL) */
#define CANPROP_SET_NEXT_CHANNEL 241U /**< set index to the next entry in the interface list (NULL) */
#define CANPROP_GET_CHANNEL_NO 242U /**< get channel no. at actual index in the interface list (int32_t) */
-#define CANPROP_GET_CHANNEL_NAME 243U /**< get channel name at actual index in the interface list (char[256]) */
-#define CANPROP_GET_CHANNEL_DLLNAME 244U /**< get file name of the DLL at actual index in the interface list (char[256]) */
+#define CANPROP_GET_CHANNEL_NAME 243U /**< get channel name at actual index in the interface list (char[]) */
+#define CANPROP_GET_CHANNEL_DLLNAME 244U /**< get file name of the DLL at actual index in the interface list (char[]) */
#define CANPROP_GET_CHANNEL_VENDOR_ID 245U /**< get library id at actual index in the interface list (int32_t) */
-#define CANPROP_GET_CHANNEL_VENDOR_NAME 246U /**< get vendor name at actual index in the interface list (char[256]) */
+#define CANPROP_GET_CHANNEL_VENDOR_NAME 246U /**< get vendor name at actual index in the interface list (char[]) */
/* - - search path for JSON files (for C++ wrapper classes) - - - - - */
#if (OPTION_CANAPI_LIBRARY != 0)
-#define CANPROP_SET_SEARCH_PATH 253U /**< set search path for interface configuration files (char[256]) */
+#define CANPROP_SET_SEARCH_PATH 253U /**< set search path for interface configuration files (char[]) */
+#define CANPROP_GET_SEARCH_PATH 254U /**< get search path for interface configuration files (char[]) */
#endif
/* - - access to device handle (for C++ wrapper classes) - - - - - - - */
-#define CANPROP_GET_CPP_BACKDOOR 255U /**< get device handle (int32_t) */
+#define CANPROP_GET_CPP_BACKDOOR 255U /**< get device handle (int) */
/* - - access to vendor-specific properties - - - - - - - - - - - - - */
#define CANPROP_GET_VENDOR_PROP 256U /**< offset to get a vendor-specific property value (void*) */
#define CANPROP_SET_VENDOR_PROP 512U /**< offset to set a vendor-specific property value (void*) */
diff --git a/Sources/CANAPI/README.md b/Sources/CANAPI/README.md
index 98691ec..f1370ab 100644
--- a/Sources/CANAPI/README.md
+++ b/Sources/CANAPI/README.md
@@ -1,9 +1,9 @@
### CAN Interface API, Version 3
-_Copyright © 2004-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com)_ \
+_Copyright © 2004-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com)_ \
_All rights reserved._
-Version $Rev: 1270 $
+Version $Rev: 1312 $
# A CAN Interface Wrapper Specification
@@ -69,13 +69,17 @@ See header file `can_api.h` for a description of the provided functions.
A generic documentation of the CAN API V3 application programming interface can be found [here](https://uv-software.github.io/CANAPI-Docs/#/).
+### vanilla-json
+
+The implementation is using [vanilla-json](https://github.com/uv-software/vanilla-json) to read CAN API wrapper configurations from JSON files.
+
+**vanilla-json** is a very simple JSON parser by UV Software written in C90, and it has the same dual-license model as CAN API V3; see below.
+
### Dual-License
This work is dual-licensed under the terms of the BSD 2-Clause "Simplified" License and under the terms of the GNU General Public License v3.0 (or any later version).
You can choose between one of them if you use this work in whole or in part.
-`SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-or-later`
-
### Contact
E-Mail: mailto://info@uv-software.com \
diff --git a/Sources/CANAPI/can_api.h b/Sources/CANAPI/can_api.h
index 9291285..cb4d572 100644
--- a/Sources/CANAPI/can_api.h
+++ b/Sources/CANAPI/can_api.h
@@ -49,9 +49,9 @@
*
* @brief CAN API V3 for generic CAN Interfaces
*
- * @author $Author: eris $
+ * @author $Author: quaoar $
*
- * @version $Rev: 1270 $
+ * @version $Rev: 1286 $
*
* @defgroup can_api CAN Interface API, Version 3
* @{
@@ -76,9 +76,14 @@ extern "C" {
* @brief Options for conditional compilation.
* @{ */
/** @note Set define OPTION_CANAPI_LIBRARY to a non-zero value to compile
- * the master loader library (e.g. in the build environment). Or
+ * the CAN API V3 loader library (e.g. in the build environment). Or
* optionally set define OPTION_CANAPI_DRIVER to a non-zero value
- * to compile a driver/wrapper library.
+ * to compile a CAN API V3 driver/wrapper library (default).
+ */
+/** @note Set define OPTION_CANAPI_RETVALS to a non-zero value to compile
+ * with CAN API V2 return values (e.g. in the build environment).
+ * This should be the default for the C interface. Unfortunately
+ * the logic is swapped.
*/
/** @note Set define OPTION_CANAPI_DLLEXPORT to a non-zero value to compile
* as a dynamic link library (e.g. in the build environment).
@@ -143,21 +148,31 @@ typedef int can_handle_t;
*/
#if (OPTION_CANAPI_LIBRARY != 0)
-/** @brief CAN Board Vendor:
+/** @brief CAN Board Vendor
+ * @note A CAN library from a board vendor is identified by its library id.
+ * @remarks Deprecated: This variable should not be used anymore!
+ * Use the properties 'CANPROP_GET_VENDOR_ID' and
+ * 'CANPROP_GET_VENDOR_NAME' in conjunction with
+ * 'CANPROP_SET_FIRST_VENDOR' and 'CANPROP_SET_NEXT_VENDOR'.
*/
typedef struct can_vendor_t_ {
- int32_t library; /**< library id */
+ int32_t library; /**< library id. */
char *name; /**< vendor name */
} can_vendor_t;
#endif
-/** @brief CAN Interface Board:
+/** @brief CAN Interface Board
+ * @note A CAN interface board is identified by its channel no.
+ * @remarks Deprecated: This variable should not be used anymore!
+ * Use the properties 'CANPROP_GET_CHANNEL_NO' and
+ * 'CANPROP_GET_CHANNEL_NAME' in conjunction with
+ * 'CANPROP_SET_FIRST_CHANNEL' and 'CANPROP_SET_NEXT_CHANNEL'.
*/
typedef struct can_board_t_ {
#if (OPTION_CANAPI_LIBRARY != 0)
- int32_t library; /**< library id */
+ int32_t library; /**< library id. */
#endif
- int32_t type; /**< board type */
- char *name; /**< board name */
+ int32_t type; /**< channel no. */
+ char *name; /**< channel name */
} can_board_t;
@@ -172,6 +187,22 @@ CANAPI can_board_t can_boards[]; /**< list of CAN interface boards */
/* ----------- prototypes ---------------------------------------------
*/
+#if (OPTION_CANAPI_LIBRARY != 0)
+/** @brief sets the search path for readings library informations from
+ * JSON files.
+ *
+ * @note The search path can only be set once, either by ths function
+ * or by the non-default constructor with a path argument.
+ *
+ * @param[in] pathname - path name, or NULL for current working directory
+ *
+ * @returns true if the search path has been successfully set, or
+ * false on error.
+ *
+ * @retval CANERR_YETINIT - search path already set
+ */
+CANAPI int can_path(const char* pathname);
+#endif
/** @brief probes if the CAN interface (hardware and driver) given by
* the argument [ 'library' and ] 'channel' is present, and
diff --git a/Sources/Driver/TouCAN_USB_Driver.c b/Sources/Driver/TouCAN_USB_Driver.c
index 9403ceb..861a02c 100644
--- a/Sources/Driver/TouCAN_USB_Driver.c
+++ b/Sources/Driver/TouCAN_USB_Driver.c
@@ -59,6 +59,8 @@
#include "MacCAN_Debug.h"
#include
+#define ISSUE_HAL_ERROR_CODES 1 // ICA for issue #32: Bus error states cannot be read from interface
+
#define TOUCAN_MSG_STD_FRAME (UInt8)0x00
#define TOUCAN_MSG_XTD_FRAME (UInt8)0x01
#define TOUCAN_MSG_RTR_FRAME (UInt8)0x02
@@ -241,8 +243,13 @@ CANUSB_Return_t TouCAN_USB_SetBitrate(TouCAN_Device_t *device, const TouCAN_Bitr
/* set mode flags depending on the operation mode */
modeFlags |= (device->opMode & CANMODE_MON) ? TOUCAN_ENABLE_SILENT_MODE : 0x00000000U;
+#ifndef ISSUE_HAL_ERROR_CODES
modeFlags |= (device->opMode & CANMODE_ERR) ? TOUCAN_ENABLE_STATUS_MESSAGES : 0x00000000U;
-
+#else
+ // issue #32: Bus error states cannot be read from interface
+ // >workaround: enable status messages to get the bus status
+ modeFlags |= TOUCAN_ENABLE_STATUS_MESSAGES;
+#endif
/* reset device state and pending errors */
retVal = TouCAN_ResetDevice(device->handle);
if (retVal < 0) {
@@ -361,7 +368,7 @@ CANUSB_Return_t TouCAN_USB_GetBusStatus(TouCAN_Device_t *device, TouCAN_Status_t
retVal = TouCAN_USB_CmdGetInterfaceErrorCode(device->handle, &errorCode);
if (retVal == CANUSB_SUCCESS) {
// FIXME: error code is always 0 even when there are errors on the bus
-#if (0)
+#ifndef ISSUE_HAL_ERROR_CODES
tmpStatus |= (errorCode & (HAL_CAN_ERROR_EWG |
HAL_CAN_ERROR_EPV)) ? CANSTAT_EWRN : 0;
tmpStatus |= (errorCode & (HAL_CAN_ERROR_BOF)) ? CANSTAT_BOFF : 0;
diff --git a/Sources/TouCAN.cpp b/Sources/TouCAN.cpp
index 586c37e..d44b045 100644
--- a/Sources/TouCAN.cpp
+++ b/Sources/TouCAN.cpp
@@ -46,7 +46,6 @@
// along with MacCAN-TouCAN. If not, see .
//
#include "TouCAN.h"
-#include "Version.h"
#include "can_defs.h"
#include "can_api.h"
diff --git a/Sources/TouCAN.h b/Sources/TouCAN.h
index 4afa6db..1ea9455 100644
--- a/Sources/TouCAN.h
+++ b/Sources/TouCAN.h
@@ -56,11 +56,7 @@
/// \brief TouCAN dynamic library
/// \{
#define TOUCAN_LIBRARY_ID CANLIB_RUSOKU_LT
-#if (OPTION_CANAPI_TOUCAN_DYLIB != 0)
#define TOUCAN_LIBRARY_NAME CANDLL_RUSOKU_LT
-#else
-#define TOUCAN_LIBRARY_NAME "libTouCAN.dylib"
-#endif
#define TOUCAN_LIBRARY_VENDOR "UV Software, Berlin"
#define TOUCAN_LIBRARY_LICENSE "BSD-2-Clause OR GPL-3.0-or-later"
#define TOUCAN_LIBRARY_COPYRIGHT "Copyright (c) 2020-2024 by Uwe Vogt, UV Software, Berlin"
diff --git a/Sources/TouCAN_Defines.h b/Sources/TouCAN_Defines.h
index ea13b8d..edaaa39 100644
--- a/Sources/TouCAN_Defines.h
+++ b/Sources/TouCAN_Defines.h
@@ -127,13 +127,13 @@ extern "C" {
* @{ */
#define TOUCAN_LIB_ID 500 /**< library ID (CAN/COP API V1 compatible) */
#if defined(_WIN32) || defined (_WIN64)
- #define TOUCAN_LIB_CANLIB "(none)"
+ #define TOUCAN_LIB_CANLIB "(driverless)"
#define TOUCAN_LIB_WRAPPER "u3cantou.dll"
#elif defined(__APPLE__)
- #define TOUCAN_LIB_CANLIB "(none)"
+ #define TOUCAN_LIB_CANLIB "(driverless)"
#define TOUCAN_LIB_WRAPPER "libUVCANTOU.dylib"
#else
-#error Platform not supported
+ #error Platform not supported
#endif
/** @} */
@@ -141,7 +141,7 @@ extern "C" {
* @brief More or less useful stuff
* @{ */
#define TOUCAN_LIB_VENDOR "Rusoku technologijos UAB, Lithuania"
-#define TOUCAN_LIB_WEBSITE "www.rusoku.com"
+#define TOUCAN_LIB_WEBSITE "https://www.rusoku.com"
#define TOUCAN_LIB_HAZARD_NOTE "If you connect your CAN device to a real CAN network when using this library,\n" \
"you might damage your application."
/** @} */
diff --git a/Sources/Version.h b/Sources/Version.h
index 05981fd..2bd8b54 100644
--- a/Sources/Version.h
+++ b/Sources/Version.h
@@ -50,7 +50,7 @@
#include "build_no.h"
#define VERSION_MAJOR 0
#define VERSION_MINOR 3
-#define VERSION_PATCH 0
+#define VERSION_PATCH 1
#define VERSION_BUILD BUILD_NO
#if (VERSION_PATCH == 0)
#define VERSION_STRING TOSTRING(VERSION_MAJOR) "." TOSTRING(VERSION_MINOR) " (" TOSTRING(BUILD_NO) ")"
diff --git a/Sources/Wrapper/can_api.c b/Sources/Wrapper/can_api.c
index c78ac88..30603fe 100644
--- a/Sources/Wrapper/can_api.c
+++ b/Sources/Wrapper/can_api.c
@@ -61,7 +61,6 @@
#include "can_btr.h"
#include "TouCAN_Driver.h"
-#include "Version.h"
#include
#include
@@ -182,10 +181,11 @@ EXPORT
int can_test(int32_t channel, uint8_t mode, const void *param, int *result)
{
int rc = CANERR_FATAL; // return value
+ int i; // loop variable
if (result) // the last resort
*result = CANBRD_NOT_TESTABLE;
- if (!init) { // when not initialized:
+ if (!init) { // if not initialized:
var_init(); // initialize the variables
// initialize the driver (MacCAN-Core driver)
if ((rc = TouCAN_InitializeDriver()) != CANERR_NOERROR)
@@ -195,17 +195,20 @@ int can_test(int32_t channel, uint8_t mode, const void *param, int *result)
if (!init) // must be initialized
return CANERR_FATAL;
if (!IS_HANDLE_VALID(channel)) // must be a valid channel!
-#ifndef OPTION_CANAPI_RETVALS
- return CANERR_HANDLE;
-#else
- // note: can_test shall return vendor-specific error code or
- // CANERR_NOTINIT in this case
return CANERR_NOTINIT;
-#endif
// probe the CAN channel and check it selected operation mode is supported by the CAN controller
rc = TouCAN_ProbeChannel(channel, mode, result);
+ // when the music's over, turn out the light
+ for (i = 0; i < CAN_MAX_HANDLES; i++) {
+ if (can[i].device.configured)
+ break;
+ }
+ if (i == CAN_MAX_HANDLES) {
+ (void)TouCAN_TeardownDriver();
+ init = 0;
+ }
// note: 1. parameter 'result' is checked for NULL pointer by the called function
- // 2. error code CANERR_ILLPARA is return in case the operation mode is not supported
+ // 2. error code CANERR_ILLPARA is returned in case the mode is not supported
(void) param;
return (int)rc;
}
@@ -225,13 +228,7 @@ int can_init(int32_t channel, uint8_t mode, const void *param)
if (!init) // must be initialized
return CANERR_FATAL;
if (!IS_HANDLE_VALID(channel)) // must be a valid channel!
-#ifndef OPTION_CANAPI_RETVALS
- return CANERR_HANDLE;
-#else
- // note: can_init shall return vendor-specific error code or
- // CANERR_NOTINIT in this case
return CANERR_NOTINIT;
-#endif
// initialize CAN channel with selected operation mode
if ((rc = TouCAN_InitializeChannel(channel, mode, &can[channel].device)) < CANERR_NOERROR)
return rc;
@@ -361,7 +358,6 @@ int can_start(int handle, const can_bitrate_t *bitrate)
can[handle].counters.rx = 0U;
can[handle].counters.err = 0U;
(void)CANQUE_Reset(can[handle].device.recvData.msgQueue);
-
// start the CAN controller with the selected operation mode
if ((rc = TouCAN_StartCan(&can[handle].device)) < CANERR_NOERROR)
return rc;
@@ -395,7 +391,7 @@ int can_reset(int handle)
if (!can[handle].device.configured) // must be an open handle
return CANERR_HANDLE;
if (can[handle].status.can_stopped) // must be running
-#ifndef OPTION_CANAPI_RETVALS
+#if (OPTION_CANAPI_RETVALS == OPTION_DISABLED)
return CANERR_OFFLINE;
#else
// note: can_reset shall return CANERR_NOERROR even if
@@ -444,8 +440,9 @@ int can_write(int handle, const can_message_t *message, uint16_t timeout)
if (message->dlc > CAN_MAX_LEN) // data length 0 .. 8!
return CANERR_ILLPARA;
- // transmit the given CAN message (w/ or w/o acknowledgment)
+ // transmit the CAN message (w/ or w/o acknowledgment)
rc = TouCAN_WriteMessage(&can[handle].device, message, timeout);
+ // update status and tx counter
can[handle].status.transmitter_busy = (rc != CANUSB_SUCCESS) ? 1 : 0;
can[handle].counters.tx += (rc == CANUSB_SUCCESS) ? 1U : 0U;
return rc;
@@ -467,7 +464,7 @@ int can_read(int handle, can_message_t *message, uint16_t timeout)
if (can[handle].status.can_stopped) // must be running
return CANERR_OFFLINE;
- // read one CAN message from the message queue, if any
+ // read one CAN message from message queue, if any
rc = TouCAN_ReadMessage(&can[handle].device, message, timeout);
can[handle].status.receiver_empty = (rc != CANUSB_SUCCESS) ? 1 : 0;
can[handle].status.queue_overrun = CANQUE_OverflowFlag(can[handle].device.recvData.msgQueue) ? 1 : 0;
@@ -497,8 +494,7 @@ int can_status(int handle, uint8_t *status)
// note: only bit 6 to 4 are set or cleared by the device
}
if (status) // status-register
- *status = can[handle].status.byte;
-
+ *status = can[handle].status.byte;
return rc;
}
@@ -507,7 +503,7 @@ int can_busload(int handle, uint8_t *load, uint8_t *status)
{
int rc = CANERR_FATAL; // return value
- uint8_t busLoad = 0U;
+ uint8_t busLoad = 0U; // bus-load (in [percent])
if (!init) // must be initialized
return CANERR_NOTINIT;
@@ -518,18 +514,19 @@ int can_busload(int handle, uint8_t *load, uint8_t *status)
#if (0)
// get bus load from device (0..10000 ==> 0%..100%)
- if ((rc = TouCAN_GetBusLoad(&can[handle].device, &busLoad)) == CANUSB_SUCCESS) {
- // get status-register from device
- rc = can_status(handle, status);
- }
- else
- busLoad = 0U;
// TODO: realize bus-load measurement
#else
- rc = can_status(handle, status);
+ rc = can_status(handle, status); // status-register
#endif
- if (load)
+ if (load) // bus-load (in [percent])
*load = (uint8_t)((busLoad + 50U) / 100U);
+#if (OPTION_CANAPI_RETVALS == OPTION_DISABLED)
+ if (rc == CANERR_NOERROR)
+ rc = !can[handle].status.can_stopped ? CANERR_NOERROR : CANERR_OFFLINE;
+#else
+ // note: can_busload shall return CANERR_NOERROR if
+ // the CAN controller has not been started
+#endif
return rc;
}
@@ -557,19 +554,20 @@ int can_bitrate(int handle, can_bitrate_t *bitrate, can_speed_t *speed)
tmpBitrate.btr.nominal.tseg1 = can[handle].device.bitRate.tseg1;
tmpBitrate.btr.nominal.tseg2 = can[handle].device.bitRate.tseg2;
tmpBitrate.btr.nominal.sjw = can[handle].device.bitRate.sjw;
- tmpBitrate.btr.nominal.sam = 0U; // note: SAM not used by TouCAN
+ tmpBitrate.btr.nominal.sam = 0U; // note: SAM not used by TouCAN
// calculate bus speed from bit-rate settings
- if ((rc = btr_bitrate2speed(&tmpBitrate, &tmpSpeed)) < CANERR_NOERROR)
+ if ((rc = btr_bitrate2speed(&tmpBitrate, &tmpSpeed)) < 0)
return CANERR_BAUDRATE;
if (bitrate)
memcpy(bitrate, &tmpBitrate, sizeof(can_bitrate_t));
if (speed)
memcpy(speed, &tmpSpeed, sizeof(can_speed_t));
-#ifdef OPTION_CANAPI_RETVALS
- // note: can_bitrate shall return CANERR_OFFLINE if
+#if (OPTION_CANAPI_RETVALS == OPTION_DISABLED)
+ if (rc == CANERR_NOERROR)
+ rc = !can[handle].status.can_stopped ? CANERR_NOERROR : CANERR_OFFLINE;
+#else
+ // note: can_bitrate shall return CANERR_NOERROR if
// the CAN controller has not been started
- if (can[handle].status.can_stopped)
- rc = CANERR_OFFLINE;
#endif
return rc;
}
@@ -581,10 +579,8 @@ int can_property(int handle, uint16_t param, void *value, uint32_t nbyte)
// note: library properties can be queried w/o a handle
return lib_parameter(param, value, (size_t)nbyte);
}
- if (!init) // must be initialized
- return CANERR_NOTINIT;
- if (!IS_HANDLE_VALID(handle)) // must be a valid handle
- return CANERR_HANDLE;
+ // note: library is initialized and handle is valid
+
if (!can[handle].device.configured) // must be an open handle
return CANERR_HANDLE;
// note: device properties must be queried with a valid handle
@@ -594,7 +590,7 @@ int can_property(int handle, uint16_t param, void *value, uint32_t nbyte)
EXPORT
char *can_hardware(int handle)
{
- static char string[CANPROP_MAX_BUFFER_SIZE] = "(unknown)";
+ static char string[CANPROP_MAX_BUFFER_SIZE+1] = "(unknown)";
if (!init) // must be initialized
return NULL;
@@ -607,15 +603,17 @@ char *can_hardware(int handle)
uint8_t major = (uint8_t)(can[handle].device.deviceInfo.hardware >> 24);
uint8_t minor = (uint8_t)(can[handle].device.deviceInfo.hardware >> 16);
uint8_t patch = (uint8_t)(can[handle].device.deviceInfo.hardware >> 8);
- sprintf(string, "%s, hardware %u.%u.%u (s/n %08x)", can[handle].device.deviceInfo.name,
- major, minor, patch, can[handle].device.deviceInfo.serialNo);
+ snprintf(string, CANPROP_MAX_BUFFER_SIZE, "%s, hardware %u.%u.%u (s/n %08x)",
+ can[handle].device.deviceInfo.name, major, minor, patch,
+ can[handle].device.deviceInfo.serialNo);
+ string[CANPROP_MAX_BUFFER_SIZE] = '\0';
return string;
}
EXPORT
char *can_firmware(int handle)
{
- static char string[CANPROP_MAX_BUFFER_SIZE] = "(unknown)";
+ static char string[CANPROP_MAX_BUFFER_SIZE+1] = "(unknown)";
if (!init) // must be initialized
return NULL;
@@ -628,8 +626,10 @@ char *can_firmware(int handle)
uint8_t major = (uint8_t)(can[handle].device.deviceInfo.firmware >> 24);
uint8_t minor = (uint8_t)(can[handle].device.deviceInfo.firmware >> 16);
uint8_t patch = (uint8_t)(can[handle].device.deviceInfo.firmware >> 8);
- sprintf(string, "%s, firmware %u.%u.%u (%s)", can[handle].device.deviceInfo.name,
- major, minor, patch, can[handle].device.website);
+ snprintf(string, CANPROP_MAX_BUFFER_SIZE, "%s, firmware %u.%u.%u (%s)",
+ can[handle].device.deviceInfo.name, major, minor, patch,
+ can[handle].device.website);
+ string[CANPROP_MAX_BUFFER_SIZE] = '\0';
return string;
}
@@ -649,9 +649,6 @@ static void var_init(void)
can[i].filter.std.mask = FILTER_STD_MASK;
can[i].filter.xtd.code = FILTER_XTD_CODE;
can[i].filter.xtd.mask = FILTER_XTD_MASK;
- //can[i].error.lec = 0x00u;
- //can[i].error.rx_err = 0u;
- //can[i].error.tx_err = 0u;
can[i].counters.tx = 0ull;
can[i].counters.rx = 0ull;
can[i].counters.err = 0ull;
@@ -744,27 +741,31 @@ static int lib_parameter(uint16_t param, void *value, size_t nbyte)
rc = CANERR_NOERROR;
}
break;
- case CANPROP_GET_LIBRARY_VENDOR: // vendor name of the library (char[256])
- if ((nbyte > strlen(CAN_API_VENDOR)) && (nbyte <= CANPROP_MAX_BUFFER_SIZE)) {
- strcpy((char*)value, CAN_API_VENDOR);
+ case CANPROP_GET_LIBRARY_VENDOR: // vendor name of the library (char[])
+ if (nbyte >= 1U) {
+ strncpy((char*)value, CAN_API_VENDOR, nbyte);
+ ((char*)value)[(nbyte - 1)] = '\0';
rc = CANERR_NOERROR;
}
break;
- case CANPROP_GET_LIBRARY_DLLNAME: // file name of the library (char[256])
- if ((nbyte > strlen(LIB_DLLNAME)) && (nbyte <= CANPROP_MAX_BUFFER_SIZE)) {
- strcpy((char*)value, LIB_DLLNAME);
+ case CANPROP_GET_LIBRARY_DLLNAME: // file name of the library (char[])
+ if (nbyte >= 1U) {
+ strncpy((char*)value, LIB_DLLNAME, nbyte);
+ ((char*)value)[(nbyte - 1)] = '\0';
rc = CANERR_NOERROR;
}
break;
- case CANPROP_GET_DEVICE_VENDOR: // vendor name of the CAN interface (char[256])
- if ((nbyte > strlen(DEV_VENDOR)) && (nbyte <= CANPROP_MAX_BUFFER_SIZE)) {
- strcpy((char*)value, DEV_VENDOR);
+ case CANPROP_GET_DEVICE_VENDOR: // vendor name of the CAN interface (char[])
+ if (nbyte >= 1U) {
+ strncpy((char*)value, DEV_VENDOR, nbyte);
+ ((char*)value)[(nbyte - 1)] = '\0';
rc = CANERR_NOERROR;
}
break;
- case CANPROP_GET_DEVICE_DLLNAME: // file name of the CAN interface DLL (char[256])
- if ((nbyte > strlen(DEV_DLLNAME)) && (nbyte <= CANPROP_MAX_BUFFER_SIZE)) {
- strcpy((char*)value, DEV_DLLNAME);
+ case CANPROP_GET_DEVICE_DLLNAME: // file name of the CAN interface DLL (char[])
+ if (nbyte >= 1U) {
+ strncpy((char*)value, DEV_DLLNAME, nbyte);
+ ((char*)value)[(nbyte - 1)] = '\0';
rc = CANERR_NOERROR;
}
break;
@@ -792,8 +793,8 @@ static int lib_parameter(uint16_t param, void *value, size_t nbyte)
rc = CANERR_RESOURCE;
}
break;
- case CANPROP_GET_CHANNEL_NAME: // get channel name at actual index in the interface list (char[256])
- if ((0U < nbyte) && (nbyte <= CANPROP_MAX_BUFFER_SIZE)) {
+ case CANPROP_GET_CHANNEL_NAME: // get channel name at actual index in the interface list (char[])
+ if (nbyte >= 1U) {
if ((0 <= idx_board) && (idx_board < NUM_CHANNELS) &&
(can_boards[idx_board].type != EOF)) {
strncpy((char*)value, can_boards[idx_board].name, nbyte);
@@ -804,8 +805,8 @@ static int lib_parameter(uint16_t param, void *value, size_t nbyte)
rc = CANERR_RESOURCE;
}
break;
- case CANPROP_GET_CHANNEL_DLLNAME: // get file name of the DLL at actual index in the interface list (char[256])
- if ((0U < nbyte) && (nbyte <= CANPROP_MAX_BUFFER_SIZE)) {
+ case CANPROP_GET_CHANNEL_DLLNAME: // get file name of the DLL at actual index in the interface list (char[])
+ if (nbyte >= 1U) {
if ((0 <= idx_board) && (idx_board < NUM_CHANNELS) &&
(can_boards[idx_board].type != EOF)) {
strncpy((char*)value, DEV_DLLNAME, nbyte);
@@ -827,8 +828,8 @@ static int lib_parameter(uint16_t param, void *value, size_t nbyte)
rc = CANERR_RESOURCE;
}
break;
- case CANPROP_GET_CHANNEL_VENDOR_NAME: // get vendor name at actual index in the interface list (char[256])
- if ((0U < nbyte) && (nbyte <= CANPROP_MAX_BUFFER_SIZE)) {
+ case CANPROP_GET_CHANNEL_VENDOR_NAME: // get vendor name at actual index in the interface list (char[])
+ if (nbyte >= 1U) {
if ((0 <= idx_board) && (idx_board < NUM_CHANNELS) &&
(can_boards[idx_board].type != EOF)) {
strncpy((char*)value, DEV_VENDOR, nbyte);
@@ -840,7 +841,7 @@ static int lib_parameter(uint16_t param, void *value, size_t nbyte)
}
break;
case CANPROP_GET_DEVICE_TYPE: // device type of the CAN interface (int32_t)
- case CANPROP_GET_DEVICE_NAME: // device name of the CAN interface (char[256])
+ case CANPROP_GET_DEVICE_NAME: // device name of the CAN interface (char[])
case CANPROP_GET_OP_CAPABILITY: // supported operation modes of the CAN controller (uint8_t)
case CANPROP_GET_OP_MODE: // active operation mode of the CAN controller (uint8_t)
case CANPROP_GET_BITRATE: // active bit-rate of the CAN controller (can_bitrate_t)
@@ -905,22 +906,24 @@ static int drv_parameter(int handle, uint16_t param, void *value, size_t nbyte)
rc = CANERR_NOERROR;
}
break;
- case CANPROP_GET_DEVICE_NAME: // device name of the CAN interface (char[256])
- if ((nbyte > strlen(can[handle].device.deviceInfo.name)) && (nbyte <= CANPROP_MAX_BUFFER_SIZE)) {
- strcpy((char*)value, can[handle].device.deviceInfo.name);
+ case CANPROP_GET_DEVICE_NAME: // device name of the CAN interface (char[])
+ if (nbyte >= 1U) {
+ strncpy((char*)value, can[handle].device.deviceInfo.name, nbyte);
+ ((char*)value)[(nbyte - 1)] = '\0';
rc = CANERR_NOERROR;
}
break;
- case CANPROP_GET_DEVICE_VENDOR: // vendor name of the CAN interface (char[256])
- if ((nbyte > strlen(can[handle].device.vendor)) && (nbyte <= CANPROP_MAX_BUFFER_SIZE)) {
- strcpy((char*)value, can[handle].device.vendor);
+ case CANPROP_GET_DEVICE_VENDOR: // vendor name of the CAN interface (char[])
+ if (nbyte >= 1U) {
+ strncpy((char*)value, DEV_VENDOR, nbyte);
+ ((char*)value)[(nbyte - 1)] = '\0';
rc = CANERR_NOERROR;
}
break;
- case CANPROP_GET_DEVICE_DLLNAME: // file name of the CAN interface DLL (char[256])
- if ((nbyte > strlen("(driverless)")) && (nbyte <= CANPROP_MAX_BUFFER_SIZE)) {
- strncpy((char*)value, "(driverless)", nbyte); // note: there is no kernel driver!
- ((char*)value)[nbyte-1] = '\0';
+ case CANPROP_GET_DEVICE_DLLNAME: // file name of the CAN interface DLL (char[])
+ if (nbyte >= 1U) {
+ strncpy((char*)value, DEV_DLLNAME, nbyte);
+ ((char*)value)[(nbyte - 1)] = '\0';
rc = CANERR_NOERROR;
}
break;
@@ -962,7 +965,7 @@ static int drv_parameter(int handle, uint16_t param, void *value, size_t nbyte)
break;
case CANPROP_GET_BUSLOAD: // current bus load of the CAN controller (uint16_t)
if (nbyte >= sizeof(uint8_t)) {
- if ((rc = can_busload(handle, &load, NULL)) == CANERR_NOERROR) {
+ if (((rc = can_busload(handle, &load, NULL)) == CANERR_NOERROR) || (rc == CANERR_OFFLINE)) {
if (nbyte > sizeof(uint8_t))
*(uint16_t*)value = (uint16_t)load * 100U; // 0..10000 ==> 0.00%..100.00%
else
diff --git a/Sources/Wrapper/can_defs.h b/Sources/Wrapper/can_defs.h
index 053fc96..6a073c7 100644
--- a/Sources/Wrapper/can_defs.h
+++ b/Sources/Wrapper/can_defs.h
@@ -54,6 +54,7 @@
/* ----------- includes ------------------------------------------------
*/
+#include "Version.h"
#include "CANAPI_Defines.h"
#include "TouCAN_Defines.h"
diff --git a/Tests/CANAPI/Driver.h b/Tests/CANAPI/Driver.h
index 38f384b..362bc8d 100644
--- a/Tests/CANAPI/Driver.h
+++ b/Tests/CANAPI/Driver.h
@@ -69,8 +69,8 @@ typedef CTouCAN CCanDriver;
#define FEATURE_BITRATE_FD_SAM FEATURE_UNSUPPORTED
#define FEATURE_BITRATE_SJA1000 FEATURE_UNSUPPORTED
#define FEATURE_FILTERING FEATURE_SUPPORTED
-#define FEATURE_ERROR_FRAMES FEATURE_UNSUPPORTED
-#define FEATURE_ERROR_CODE_CAPTURE FEATURE_UNSUPPORTED
+#define FEATURE_ERROR_FRAMES FEATURE_SUPPORTED
+#define FEATURE_ERROR_CODE_CAPTURE FEATURE_SUPPORTED
#define FEATURE_BLOCKING_READ FEATURE_SUPPORTED
#define FEATURE_BLOCKING_WRITE FEATURE_UNSUPPORTED
#define FEATURE_SIZE_RECEIVE_QUEUE 65536
@@ -91,16 +91,23 @@ typedef CTouCAN CCanDriver;
#define BITRATE_5K(x) TOUCAN_BR_5K(x)
// (§6) define macros for workarounds (e.g. TC01_3_ISSUE)
+#if (OPTION_REGRESSION_TEST == 0)
+#define TC04_15_ISSUE_TOUCAN_STATUS WORKAROUND_ENABLED // 2024-05-29: display only, fix for issue #32 works
+#define TC09_8_ISSUE_TOUCAN_STATUS WORKAROUND_ENABLED // 2024-05-29: test fails, fix for issue #32 is not stable
+#define TC09_9_ISSUE_TOUCAN_STATUS WORKAROUND_ENABLED // 2024-05-29: display only, fix for issue #32 works
+#define TC09_10_ISSUE_TOUCAN_STATUS WORKAROUND_ENABLED // 2024-05-29: test fails, fix for issue #32 is not working
+//#define TC09_8_ISSUE_BUS_OFF WORKAROUND_ENABLED // 2023-08-28: test hangs up (general issue)
+#endif
+// (§6.1) old PCANBasic issues (see macros in 'Settings.h')
+#define PCBUSB_INIT_DELAY_WORKAROUND WORKAROUND_DISABLED
+#define PCBUSB_QXMTFULL_WORKAROUND WORKAROUND_DISABLED
+
+// (§6.2) TouCAN USB harware issues with bit-rate 10K
#define TC03_7_ISSUE_RUSOKU_BITRATE_10K ISSUE_TOUCAN_BITRATE_10K_WORKAROUND
#define TC03_19_ISSUE_RUSOKU_BITRATE_10K ISSUE_TOUCAN_BITRATE_10K_WORKAROUND
#define TC11_10_ISSUE_RUSOKU_BITRATE_10K ISSUE_TOUCAN_BITRATE_10K_WORKAROUND
#define ISSUE_TOUCAN_BITRATE_10K_WORKAROUND 1 // set to none-zero value to skip the hardware bug
-//#define TC09_8_ISSUE_BUS_OFF WORKAROUND_ENABLED // 2023-08-28: test hangs up
-// (§6.1) old PCANBasic issues (see macros in 'Settings.h')
-#define PCBUSB_INIT_DELAY_WORKAROUND WORKAROUND_DISABLED
-#define PCBUSB_QXMTFULL_WORKAROUND WORKAROUND_DISABLED
-
// (§7) define macros for CAN 2.0 bit-rate indexes to be used in the tests
#if (ISSUE_TOUCAN_BITRATE_10K_WORKAROUND == WORKAROUND_DISABLED)
#define CAN_INDEX_DEFAULT CANBTR_INDEX_250K
@@ -140,7 +147,9 @@ typedef CTouCAN CCanDriver;
#define BITRATE_FD_125K1M(x) TOUCAN_FD_BR_125K1M(x)
// (§11) define macros for workarounds for CAN FD operation mode (e.g. TC01_3_ISSUE_FD)
+#if (OPTION_REGRESSION_TEST == 0)
//#define TC0x_y_ISSUE_FD_ WORKAROUND_ENABLED
+#endif
// (§12) define macros for CAN FD bit-rate settings to be used in the tests, if supported
#define CAN_BITRATE_FD_DEFAULT BITRATE_FD_250K2M
diff --git a/Tests/CANAPI/Makefile b/Tests/CANAPI/Makefile
index 8130c8a..fa40866 100644
--- a/Tests/CANAPI/Makefile
+++ b/Tests/CANAPI/Makefile
@@ -71,7 +71,13 @@ OBJECTS = $(OUTDIR)/main.o $(OUTDIR)/Device.o $(OUTDIR)/Options.o \
$(OUTDIR)/TC23_SetFilter11Bit.o $(OUTDIR)/TC25_SetFilter29Bit.o \
$(OUTDIR)/TC27_ResetFilter.o \
$(OUTDIR)/TCx1_CallSequences.o $(OUTDIR)/TCx2_BitrateConverter.o \
- $(OUTDIR)/Timer.o $(OUTDIR)/Progress.o
+ $(OUTDIR)/TCxX_Summary.o $(OUTDIR)/Timer.o $(OUTDIR)/Progress.o
+
+ifeq ($(REGRESSION),ON) # disable all workarounds
+REGRESSION_TEST = 1
+else
+REGRESSION_TEST = 0
+endif
ifeq ($(current_OS),Darwin) # macOS - libTouCAN.dylib
@@ -79,8 +85,9 @@ TARGET = tou_testing
INSTALL = ~/bin
-DEFINES = -DOPTION_CAN_2_0_ONLY=0 \
- -DOPTION_CANAPI_RETVALS=1
+DEFINES = -DOPTION_REGRESSION_TEST=$(REGRESSION_TEST) \
+ -DOPTION_CAN_2_0_ONLY=0 \
+ -DOPTION_CANAPI_RETVALS=0
HEADERS = -I$(HOME_DIR) \
-I$(MAIN_DIR) \
@@ -190,6 +197,9 @@ $(OUTDIR)/TCx1_CallSequences.o: $(TEST_DIR)/TCx1_CallSequences.cc
$(OUTDIR)/TCx2_BitrateConverter.o: $(TEST_DIR)/TCx2_BitrateConverter.cc
$(CXX) $(CXXFLAGS) -MMD -MF $*.d -o $@ -c $<
+$(OUTDIR)/TCxX_Summary.o: $(TEST_DIR)/TCxX_Summary.cc
+ $(CXX) $(CXXFLAGS) -MMD -MF $*.d -o $@ -c $<
+
$(OUTDIR)/main.o: $(MAIN_DIR)/main.cpp
$(CXX) $(CXXFLAGS) -MMD -MF $*.d -o $@ -c $<
diff --git a/Tests/CANAPI/README.md b/Tests/CANAPI/README.md
index f2f6dfe..00bc688 100644
--- a/Tests/CANAPI/README.md
+++ b/Tests/CANAPI/README.md
@@ -3,8 +3,6 @@
_Copyright © 2004-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com)_ \
_All rights reserved._
-Version $Rev: 1273 $
-
# CAN Interface Wrapper Specification
[CAN API V3](https://mac-can.github.io/wrapper/canapi-v3/) is a wrapper specification by UV Software to have a uniform Application Programming Interface (API) for various CAN interface devices from different vendors running under multiple operating systems.
@@ -115,6 +113,8 @@ See header file `CANAPI.h` for a description of the provided methods.
## CAN API V3 Testing
+This work (***CAN API V3 Testing***) provides test suites for the methods of class `CCanApi` in CAN API V3 C++ wrapper implementions.
+
### GoogleTest
GoogleTest (aka gtest) is a unit testing library for the C++ programming language based on the xUnit architecture.
@@ -138,10 +138,9 @@ The CAN API V3 Testing sources are maintained in a SVN repo to synchronized them
### Dual-License
-This work is dual-licensed under the terms of the BSD 2-Clause "Simplified" License and under the terms of the GNU General Public License v3.0 (or any later version).
-You can choose between one of them if you use this work in whole or in part.
-
-`SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-or-later`
+Except where otherwise noted, this work is dual-licensed under the terms of the BSD 2-Clause "Simplified" License
+and under the terms of the GNU General Public License v3.0 (or any later version).
+You can choose between one of them if you use these portions of this work in whole or in part.
### GoogleTest License
diff --git a/Tests/CANAPI/Sources/Device.cpp b/Tests/CANAPI/Sources/Device.cpp
index 31d084f..f3f48b0 100644
--- a/Tests/CANAPI/Sources/Device.cpp
+++ b/Tests/CANAPI/Sources/Device.cpp
@@ -514,7 +514,11 @@ void CCanDevice::ShowBitrateSettings(const char *prefix) {
}
bool CCanDevice::GetChannelInfoFromDeviceList(CCanApi::SChannelInfo &info) {
+#if (OPTION_CANAPI_LIBRARY != 0)
+ bool found = CCanDevice::GetFirstChannel(m_nLibraryId, info);
+#else
bool found = CCanDevice::GetFirstChannel(info);
+#endif
while (found) {
if ((info.m_nLibraryId == m_nLibraryId) && (info.m_nChannelNo == m_nChannelNo)) {
return true;
@@ -533,10 +537,17 @@ void CCanDevice::ShowChannelInformation(const char* prefix) {
if (prefix)
std::cout << prefix << ' ';
if (GetStatus(status) != CCanApi::NoError) {
+#if (OPTION_CANAPI_LIBRARY != 0)
+ if ((retVal = InitializeChannel(m_nLibraryId, m_nChannelNo, opMode)) != CCanApi::NoError) {
+ std::cout << "error(" << retVal << "): channel " << m_nChannelNo << " could not be initialized" << std::endl;
+ return;
+ }
+#else
if ((retVal = InitializeChannel(m_nChannelNo, opMode)) != CCanApi::NoError) {
std::cout << "error(" << retVal << "): channel " << m_nChannelNo << " could not be initialized" << std::endl;
return;
}
+#endif
bInitialized = false;
}
if ((retVal = GetProperty(CANPROP_GET_DEVICE_NAME, (void*)szDeviceName, CANPROP_MAX_BUFFER_SIZE)) != CCanApi::NoError) {
@@ -561,10 +572,17 @@ void CCanDevice::ShowChannelCapabilities(const char* prefix) {
if (prefix)
std::cout << prefix << ' ';
if (GetStatus(status) != CCanApi::NoError) {
+#if (OPTION_CANAPI_LIBRARY != 0)
+ if ((retVal = InitializeChannel(m_nLibraryId, m_nChannelNo, opMode)) != CCanApi::NoError) {
+ std::cout << "error(" << retVal << "): channel " << m_nChannelNo << " could not be initialized" << std::endl;
+ return;
+ }
+#else
if ((retVal = InitializeChannel(m_nChannelNo, opMode)) != CCanApi::NoError) {
std::cout << "error(" << retVal << "): channel " << m_nChannelNo << " could not be initialized" << std::endl;
return;
}
+#endif
bInitialized = false;
}
if ((retVal = GetProperty(CANPROP_GET_OP_CAPABILITY, (void*)&opCapa.byte, sizeof(uint8_t))) != CCanApi::NoError) {
@@ -590,4 +608,4 @@ void CCanDevice::ShowChannelCapabilities(const char* prefix) {
std::cout << std::endl;
}
-// $Id: Device.cpp 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin //
+// $Id: Device.cpp 1314 2024-05-26 08:39:33Z quaoar $ Copyright (c) UV Software, Berlin //
diff --git a/Tests/CANAPI/Sources/Device.h b/Tests/CANAPI/Sources/Device.h
index 21aaa1a..6e49f84 100644
--- a/Tests/CANAPI/Sources/Device.h
+++ b/Tests/CANAPI/Sources/Device.h
@@ -116,7 +116,11 @@ class CCanDevice : public CCanDriver {
bool IsCanFdCapable() {
CANAPI_OpMode_t opCapa = { CANMODE_FDOE };
EChannelState state = CCanApi::ChannelNotTestable;
+#if (OPTION_CANAPI_LIBRARY != 0)
+ return (CCanDriver::ProbeChannel(m_nLibraryId, m_nChannelNo, opCapa, state) == CCanApi::NoError) ? true : false;
+#else
return (CCanDriver::ProbeChannel(m_nChannelNo, opCapa, state) == CCanApi::NoError) ? true : false;
+#endif
}
bool IsCanIdAccepted(uint32_t canId, uint32_t accCode, uint32_t accMask) {
return (((canId ^ accCode) & accMask) == 0x00000000U) ? true : false;
@@ -173,4 +177,4 @@ class CCanDevice : public CCanDriver {
#endif // DEVICE_H_INCLUDED
-// $Id: Device.h 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin.
+// $Id: Device.h 1314 2024-05-26 08:39:33Z quaoar $ Copyright (c) UV Software, Berlin.
diff --git a/Tests/CANAPI/Sources/Options.cpp b/Tests/CANAPI/Sources/Options.cpp
index 1ca26f1..9d506a5 100644
--- a/Tests/CANAPI/Sources/Options.cpp
+++ b/Tests/CANAPI/Sources/Options.cpp
@@ -55,6 +55,9 @@
#include
#include
+#if (DUT1 != 0) || (DUT2 != 1)
+#error Definition of DUT1 or DUT2 wrong
+#endif
#define OPTION_HELP "--can_help"
#define OPTION_PATH "--can_path"
#define OPTION_DUT1 "--can_dut1"
@@ -78,10 +81,17 @@ static const bool c_fRtrDevice = false;
static const bool c_fRunQuick = false;
static const bool c_fCallSequences = false;
static const bool c_fBitrateConverter = false;
+#if (OPTION_CANAPI_LIBRARY != 0)
+static const char c_szDefaultSearchPath[] = ".";
+#endif
COptions g_Options = COptions();
COptions::COptions() {
+#if (OPTION_CANAPI_LIBRARY != 0)
+ // configuration from JSON files
+ m_szSearchPath = (char*)c_szDefaultSearchPath;
+#endif
// device under test #1
if (!GetChannelInfoFromDeviceList(TEST_LIBRARY, TEST_CHANNEL1, m_Dut[DUT1].m_Info)) {
m_Dut[DUT1].m_Info.m_nLibraryId = INVALID_HANDLE;
@@ -113,18 +123,37 @@ COptions::COptions() {
}
bool COptions::GetChannelInfoByDeviceName(const char *name, CCanApi::SChannelInfo &info) {
- bool found = CCanDevice::GetFirstChannel(info);
- while (found) {
+#if (OPTION_CANAPI_LIBRARY != 0)
+ CCanApi::SLibraryInfo libInfo;
+ bool library = CCanDevice::GetFirstLibrary(libInfo);
+ while (library) {
+ bool channel = CCanDevice::GetFirstChannel(libInfo.m_nLibraryId, info);
+ while (channel) {
+ if (!strcmp(info.m_szDeviceName, name)) {
+ return true;
+ }
+ channel = CCanDevice::GetNextChannel(info);
+ }
+ library = CCanDevice::GetNextLibrary(libInfo);
+ }
+#else
+ bool channel = CCanDevice::GetFirstChannel(info);
+ while (channel) {
if (!strcmp(info.m_szDeviceName, name)) {
return true;
}
- found = CCanDevice::GetNextChannel(info);
+ channel = CCanDevice::GetNextChannel(info);
}
+#endif
return false;
}
bool COptions::GetChannelInfoFromDeviceList(int32_t library, int32_t channel, CCanApi::SChannelInfo &info) {
+#if (OPTION_CANAPI_LIBRARY != 0)
+ bool found = CCanDevice::GetFirstChannel(library, info);
+#else
bool found = CCanDevice::GetFirstChannel(info);
+#endif
while (found) {
if ((info.m_nLibraryId == library) && (info.m_nChannelNo == channel)) {
return true;
@@ -194,15 +223,23 @@ int COptions::ScanOptions(int argc, char* argv[], char* err, size_t len) {
else {
opt = (char*)TEST_SEARCH_PATH;
}
- CCanDriver *dummy = new CCanDriver();
- if (dummy->SetProperty(CANPROP_SET_SEARCH_PATH, (void*)opt, 0) != CCanApi::NoError) {
+ if (!CCanDriver::SetSearchPath(opt)) {
if (err)
- snprintf(err, len, "search path not set -- %s", opt);
- delete dummy;
+ snprintf(err, len, "search path cannot be set -- %s", opt);
return false;
}
- std::cout << "JSON path: " << opt << std::endl;
- delete dummy;
+ // default device under test #1 from JSON
+ if (!GetChannelInfoFromDeviceList(TEST_LIBRARY, TEST_CHANNEL1, m_Dut[DUT1].m_Info)) {
+ m_Dut[DUT1].m_Info.m_nLibraryId = INVALID_HANDLE;
+ m_Dut[DUT1].m_Info.m_nChannelNo = INVALID_HANDLE;
+ }
+ // default device under test #2 from JSON
+ if (!GetChannelInfoFromDeviceList(TEST_LIBRARY, TEST_CHANNEL2, m_Dut[DUT2].m_Info)) {
+ m_Dut[DUT2].m_Info.m_nLibraryId = INVALID_HANDLE;
+ m_Dut[DUT2].m_Info.m_nChannelNo = INVALID_HANDLE;
+ }
+ m_szSearchPath = opt;
+ std::cout << "JSON path: " << m_szSearchPath << std::endl;
}
#endif
// option: --can_dut1=
@@ -716,4 +753,4 @@ int COptions::ShowHelp() {
return m_fShowHelp;
}
-// $Id: Options.cpp 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin //
+// $Id: Options.cpp 1315 2024-05-26 12:23:58Z makemake $ Copyright (c) UV Software, Berlin //
diff --git a/Tests/CANAPI/Sources/Options.h b/Tests/CANAPI/Sources/Options.h
index 92cbeca..818394a 100644
--- a/Tests/CANAPI/Sources/Options.h
+++ b/Tests/CANAPI/Sources/Options.h
@@ -70,6 +70,10 @@ class COptions {
CANAPI_Bitrate_t m_Bitrate; // bit-rate settings
void *m_pParameter; // non PnP parameter
} m_Dut[NUM_DUTS];
+#if (OPTION_CANAPI_LIBRARY != 0)
+ // search path for configurations
+ char *m_szSearchPath; // search path for JSON files
+#endif
// test options
int32_t m_s32TestFrames; // number of CAN frames to be sent during tests
int32_t m_s32SmokeTestFrames; // number of CAN frames to be sent during smoketest
@@ -85,6 +89,11 @@ class COptions {
COptions();
virtual ~COptions() {};
// getter/setter
+#if (OPTION_CANAPI_LIBRARY != 0)
+ char *GetSearchPath() {
+ return m_szSearchPath;
+ }
+#endif
int32_t GetLibraryId(int dut) {
return ((0 <= dut) && (dut < NUM_DUTS)) ? m_Dut[dut].m_Info.m_nLibraryId : INVALID_HANDLE;
}
@@ -139,4 +148,4 @@ extern COptions g_Options; // global access to testing options
#endif // OPTIONS_H_INCLUDED
-// $Id: Options.h 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin.
+// $Id: Options.h 1314 2024-05-26 08:39:33Z quaoar $ Copyright (c) UV Software, Berlin.
diff --git a/Tests/CANAPI/Sources/Settings.h b/Tests/CANAPI/Sources/Settings.h
index dba564c..44eb97d 100644
--- a/Tests/CANAPI/Sources/Settings.h
+++ b/Tests/CANAPI/Sources/Settings.h
@@ -55,7 +55,7 @@
#elif defined(__linux__)
#define TEST_SEARCH_PATH "~/Projects/CAN/DRV/API/json"
#else
-#define TEST_SEARCH_PATH "C:\\Projekte\\CAN\\DRV\\API\\json"
+#define TEST_SEARCH_PATH "C:\\Program Files (x86)\\UV Software\\CAN API V3"
#endif
// - devices under test (2 devices are required)
#define TEST_DEVICE(dut) g_Options.GetLibraryId(dut), g_Options.GetChannelNo(dut), g_Options.GetOpMode(dut), g_Options.GetBitrate(dut), g_Options.GetParameter(dut)
@@ -158,4 +158,4 @@
#endif
#endif // SETTINGS_H_INCLUDED
-// $Id: Settings.h 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin.
+// $Id: Settings.h 1314 2024-05-26 08:39:33Z quaoar $ Copyright (c) UV Software, Berlin.
diff --git a/Tests/CANAPI/Testcases/TC01_ProbeChannel.cc b/Tests/CANAPI/Testcases/TC01_ProbeChannel.cc
index 9e10318..75ac76a 100644
--- a/Tests/CANAPI/Testcases/TC01_ProbeChannel.cc
+++ b/Tests/CANAPI/Testcases/TC01_ProbeChannel.cc
@@ -55,6 +55,11 @@
#warning CAN_FD_SUPPORTED not set, default = FEATURE_SUPPORTED
#endif
#endif
+#if (OPTION_CANAPI_LIBRARY != 0)
+#define TEST_GET_LIBRARY_ID(dut, arg) g_Options.GetLibraryId(dut), (arg)
+#else
+#define TEST_GET_LIBRARY_ID(dut, arg) (arg)
+#endif
class ProbeChannel : public testing::Test {
virtual void SetUp() {}
@@ -248,11 +253,11 @@ TEST_F(ProbeChannel, GTEST_TESTCASE(WithValidChannelNo, GTEST_ENABLED)) {
// @test:
// @- loop over the list of devices to get the channel no.
CCounter counter = CCounter();
- bool found = CCanDevice::GetFirstChannel(info);
+ bool found = CCanDevice::GetFirstChannel(TEST_GET_LIBRARY_ID(DUT1, info));
while (found) {
counter.Increment();
// @-- probe found channel with default mode (must be supported)
- retVal = dut1.ProbeChannel(info.m_nChannelNo, opMode, state);
+ retVal = dut1.ProbeChannel(TEST_GET_LIBRARY_ID(DUT1, info.m_nChannelNo), opMode, state);
EXPECT_EQ(CCanApi::NoError, retVal);
// @ note: state can take all possible values.
if ((state == CCanApi::ChannelAvailable) || (state == CCanApi::ChannelOccupied))
@@ -301,7 +306,7 @@ TEST_F(ProbeChannel, GTEST_TESTCASE(WithValidChannelNo, GTEST_ENABLED)) {
// @gtest TC01.5: Probe CAN channel with invalid channel number(s)
//
-// @expected !CANERR_NOERROR (maybe a vendor-specific error code)
+// @expected: CANERR_NOTINIT or vendor-specific error code
//
TEST_F(ProbeChannel, GTEST_TESTCASE(WithInvalidChannelNo, GTEST_ENABLED)) {
CCanDevice dut1 = CCanDevice(TEST_DEVICE(DUT1));
@@ -312,14 +317,14 @@ TEST_F(ProbeChannel, GTEST_TESTCASE(WithInvalidChannelNo, GTEST_ENABLED)) {
CANAPI_Return_t retVal;
// @test:
// @- try to probe channel with invalid channel no. -1
- retVal = dut1.ProbeChannel((-1), opMode, state);
- EXPECT_NE(CCanApi::NoError, retVal);
+ retVal = dut1.ProbeChannel(TEST_GET_LIBRARY_ID(DUT1, (-1)), opMode, state);
+ EXPECT_TRUE((retVal == CCanApi::NotInitialized) || (retVal <= CCanApi::VendorSpecific));
// @- try to probe channel with invalid channel no. -2
- retVal = dut1.ProbeChannel((-2), opMode, state);
- EXPECT_NE(CCanApi::NoError, retVal);
+ retVal = dut1.ProbeChannel(TEST_GET_LIBRARY_ID(DUT1, (-2)), opMode, state);
+ EXPECT_TRUE((retVal == CCanApi::NotInitialized) || (retVal <= CCanApi::VendorSpecific));
// @- try to probe channel with invalid channel no. INT32_MIN
- retVal = dut1.ProbeChannel(INT32_MIN, opMode, state);
- EXPECT_NE(CCanApi::NoError, retVal);
+ retVal = dut1.ProbeChannel(TEST_GET_LIBRARY_ID(DUT1, INT32_MIN), opMode, state);
+ EXPECT_TRUE((retVal == CCanApi::NotInitialized) || (retVal <= CCanApi::VendorSpecific));
// @ note: channel numbers are defined by the CAN device vendor.
// @ Therefore, no assumptions can be made for positive values!
//
@@ -1021,14 +1026,63 @@ TEST_F(ProbeChannel, GTEST_TESTCASE(InAllChannelStates, GTEST_ENABLED)) {
#if (OPTION_CANAPI_LIBRARY != OPTION_DISBALED)
// @gtest TC01.15: Probe CAN channel with invalid library number(s)
//
-// @expected: CANERR_xyz
+// @expected: CANERR_LIBRARY
//
-TEST_F(ProbeChannel, GTEST_TESTCASE(WithInvalidLibraryId, GTEST_DISABLED)) {
- // @note: this test case can only run with the loader library
- // @todo: implement with CAN API V3 loader liabrary
- // TODO: insert coin here
+TEST_F(ProbeChannel, GTEST_TESTCASE(WithInvalidLibraryId, GTEST_ENABLED)) {
+ CCanDevice dut1 = CCanDevice(TEST_DEVICE(DUT1));
+ CCanDevice dut2 = CCanDevice(TEST_DEVICE(DUT2));
+ CCanApi::EChannelState state;
+ CANAPI_OpMode_t opMode = { TEST_CANMODE };
+ CANAPI_Status_t status = {};
+ CANAPI_Return_t retVal;
+ // @test:
+ // @- try to probe channel with invalid library id. -1
+ retVal = dut1.ProbeChannel((-1), g_Options.GetChannelNo(DUT1), opMode, state);
+ EXPECT_EQ(CCanApi::InvalidLibrary, retVal);
+ // @- try to probe channel with invalid library id. -2
+ retVal = dut1.ProbeChannel((-2), g_Options.GetChannelNo(DUT1), opMode, state);
+ EXPECT_EQ(CCanApi::InvalidLibrary, retVal);
+ // @- try to probe channel with invalid library id. INT32_MIN
+ retVal = dut1.ProbeChannel(INT32_MIN, g_Options.GetChannelNo(DUT1), opMode, state);
+ EXPECT_EQ(CCanApi::InvalidLibrary, retVal);
+ // @ note: library numbers are positive numbers, but
+ // @ no assumptions can be made for them!
+ //
+ // @post:
+ // @- initialize DUT1 with configured settings
+ retVal = dut1.InitializeChannel();
+ ASSERT_EQ(CCanApi::NoError, retVal) << "[ ERROR! ] dut1.InitializeChannel() failed with error code " << retVal;
+ // @- get status of DUT1 and check to be in INIT state
+ retVal = dut1.GetStatus(status);
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ EXPECT_TRUE(status.can_stopped);
+ // @- start DUT1 with configured bit-rate settings
+ retVal = dut1.StartController();
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ // @- get status of DUT1 and check to be in RUNNING state
+ retVal = dut1.GetStatus(status);
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ EXPECT_FALSE(status.can_stopped);
+ // @- send some frames to DUT2 and receive some frames from DUT2
+ int32_t frames = g_Options.GetNumberOfTestFrames();
+ EXPECT_EQ(frames, dut1.SendSomeFrames(dut2, frames));
+ EXPECT_EQ(frames, dut1.ReceiveSomeFrames(dut2, frames));
+ // @- get status of DUT1 and check to be in RUNNING state
+ retVal = dut1.GetStatus(status);
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ EXPECT_FALSE(status.can_stopped);
+ // @- stop/reset DUT1
+ retVal = dut1.ResetController();
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ // @- get status of DUT1 and check to be in INIT state
+ retVal = dut1.GetStatus(status);
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ EXPECT_TRUE(status.can_stopped);
+ // @- tear down DUT1
+ retVal = dut1.TeardownChannel();
+ EXPECT_EQ(CCanApi::NoError, retVal);
// @end.
}
#endif // (OPTION_CANAPI_LIBRARY != OPTION_DISBALED)
-// $Id: TC01_ProbeChannel.cc 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin.
+// $Id: TC01_ProbeChannel.cc 1335 2024-06-02 16:26:04Z makemake $ Copyright (c) UV Software, Berlin.
diff --git a/Tests/CANAPI/Testcases/TC02_InitializeChannel.cc b/Tests/CANAPI/Testcases/TC02_InitializeChannel.cc
index af62aac..73b759c 100644
--- a/Tests/CANAPI/Testcases/TC02_InitializeChannel.cc
+++ b/Tests/CANAPI/Testcases/TC02_InitializeChannel.cc
@@ -55,6 +55,11 @@
#warning CAN_FD_SUPPORTED not set, default = FEATURE_SUPPORTED
#endif
#endif
+#if (OPTION_CANAPI_LIBRARY != 0)
+#define TEST_GET_LIBRARY_ID(dut, arg) g_Options.GetLibraryId(dut), (arg)
+#else
+#define TEST_GET_LIBRARY_ID(dut, arg) (arg)
+#endif
class InitializeChannel : public testing::Test {
virtual void SetUp() {}
@@ -355,10 +360,10 @@ TEST_F(InitializeChannel, GTEST_TESTCASE(WithValidChannelNo, GTEST_ENABLED)) {
// @test:
// @- loop over the list of devices to get the channel no.
CCounter counter = CCounter();
- bool found = CCanDevice::GetFirstChannel(info);
+ bool found = CCanDevice::GetFirstChannel(TEST_GET_LIBRARY_ID(DUT1, info));
while (found) {
// @-- try to initialize found channel with default mode (must be supported)
- retVal = dut1.InitializeChannel(info.m_nChannelNo, opMode);
+ retVal = dut1.InitializeChannel(TEST_GET_LIBRARY_ID(DUT1, info.m_nChannelNo), opMode);
if (retVal == CCanApi::NoError) {
// @-- on success: tear down the channel straightaway
(void)dut1.TeardownChannel();
@@ -420,13 +425,13 @@ TEST_F(InitializeChannel, GTEST_TESTCASE(WithInvalidChannelNo, GTEST_ENABLED)) {
CANAPI_Return_t retVal;
// @test:
// @- try to initialize channel with invalid channel no. -1
- retVal = dut1.InitializeChannel((-1), opMode);
+ retVal = dut1.InitializeChannel(TEST_GET_LIBRARY_ID(DUT1, (-1)), opMode);
EXPECT_TRUE((retVal == CCanApi::NotInitialized) || (retVal <= CCanApi::VendorSpecific));
// @- try to initialize channel with invalid channel no. -2
- retVal = dut1.InitializeChannel((-2), opMode);
+ retVal = dut1.InitializeChannel(TEST_GET_LIBRARY_ID(DUT1, (-2)), opMode);
EXPECT_TRUE((retVal == CCanApi::NotInitialized) || (retVal <= CCanApi::VendorSpecific));
// @- try to initialize channel with invalid channel no. INT32_MIN
- retVal = dut1.InitializeChannel(INT32_MIN, opMode);
+ retVal = dut1.InitializeChannel(TEST_GET_LIBRARY_ID(DUT1, INT32_MIN), opMode);
EXPECT_TRUE((retVal == CCanApi::NotInitialized) || (retVal <= CCanApi::VendorSpecific));
// @note: channel numbers are defined by the CAN device vendor.
// @ Therefore, no assumptions can be made for positive values!
@@ -903,14 +908,62 @@ TEST_F(InitializeChannel, GTEST_TESTCASE(CheckBitrateSwitchingEnabledWithoutCanF
#if (OPTION_CANAPI_LIBRARY != OPTION_DISBALED)
// @gtest TC02.15: Initialize CAN channel with invalid library number(s)
//
-// @expected: CANERR_xyz
+// @expected: CANERR_LIBRARY
//
-TEST_F(InitializeChannel, GTEST_TESTCASE(WithInvalidLibraryId, GTEST_DISABLED)) {
- // @note: this test case can only run with the loader library
- // @todo: implement with CAN API V3 loader liabrary
- // TODO: insert coin here
+TEST_F(InitializeChannel, GTEST_TESTCASE(WithInvalidLibraryId, GTEST_ENABLED)) {
+ CCanDevice dut1 = CCanDevice(TEST_DEVICE(DUT1));
+ CCanDevice dut2 = CCanDevice(TEST_DEVICE(DUT2));
+ CANAPI_OpMode_t opMode = { TEST_CANMODE };
+ CANAPI_Status_t status = {};
+ CANAPI_Return_t retVal;
+ // @test:
+ // @- try to initialize channel with invalid library id. -1
+ retVal = dut1.InitializeChannel((-1), g_Options.GetChannelNo(DUT1), opMode);
+ EXPECT_EQ(CCanApi::InvalidLibrary, retVal);
+ // @- try to initialize channel with invalid library id. -2
+ retVal = dut1.InitializeChannel((-2), g_Options.GetChannelNo(DUT1), opMode);
+ EXPECT_EQ(CCanApi::InvalidLibrary, retVal);
+ // @- try to initialize channel with invalid library id. INT32_MIN
+ retVal = dut1.InitializeChannel(INT32_MIN, g_Options.GetChannelNo(DUT1), opMode);
+ EXPECT_EQ(CCanApi::InvalidLibrary, retVal);
+ // @ note: library numbers are positive numbers, but
+ // @ no assumptions can be made for them!
+ //
+ // @post:
+ // @- initialize DUT1 with configured settings
+ retVal = dut1.InitializeChannel();
+ ASSERT_EQ(CCanApi::NoError, retVal) << "[ ERROR! ] dut1.InitializeChannel() failed with error code " << retVal;
+ // @- get status of DUT1 and check to be in INIT state
+ retVal = dut1.GetStatus(status);
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ EXPECT_TRUE(status.can_stopped);
+ // @- start DUT1 with configured bit-rate settings
+ retVal = dut1.StartController();
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ // @- get status of DUT1 and check to be in RUNNING state
+ retVal = dut1.GetStatus(status);
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ EXPECT_FALSE(status.can_stopped);
+ // @- send some frames to DUT2 and receive some frames from DUT2
+ int32_t frames = g_Options.GetNumberOfTestFrames();
+ EXPECT_EQ(frames, dut1.SendSomeFrames(dut2, frames));
+ EXPECT_EQ(frames, dut1.ReceiveSomeFrames(dut2, frames));
+ // @- get status of DUT1 and check to be in RUNNING state
+ retVal = dut1.GetStatus(status);
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ EXPECT_FALSE(status.can_stopped);
+ // @- stop/reset DUT1
+ retVal = dut1.ResetController();
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ // @- get status of DUT1 and check to be in INIT state
+ retVal = dut1.GetStatus(status);
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ EXPECT_TRUE(status.can_stopped);
+ // @- tear down DUT1
+ retVal = dut1.TeardownChannel();
+ EXPECT_EQ(CCanApi::NoError, retVal);
// @end.
}
#endif // (OPTION_CANAPI_LIBRARY != OPTION_DISBALED)
-// $Id: TC02_InitializeChannel.cc 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin.
+// $Id: TC02_InitializeChannel.cc 1314 2024-05-26 08:39:33Z quaoar $ Copyright (c) UV Software, Berlin.
diff --git a/Tests/CANAPI/Testcases/TC04_ReadMessage.cc b/Tests/CANAPI/Testcases/TC04_ReadMessage.cc
index eb20a3a..ba86785 100644
--- a/Tests/CANAPI/Testcases/TC04_ReadMessage.cc
+++ b/Tests/CANAPI/Testcases/TC04_ReadMessage.cc
@@ -190,7 +190,7 @@ TEST_F(ReadMessage, GTEST_TESTCASE(SunnydayScenario, GTEST_SUNNYDAY)) {
// @gtest TC04.3: Read a CAN message if CAN channel is not initialized
//
-// @expected: CANERR_HANDLE (would it not be better to return NOTINIT in C++ API?)
+// @expected: CANERR_NOTINIT (wrapper/driver libraries return CANERR_HANDLE)
//
TEST_F(ReadMessage, GTEST_TESTCASE(IfChannelNotInitialized, GTEST_ENABLED)) {
CCanDevice dut1 = CCanDevice(TEST_DEVICE(DUT1));
@@ -236,7 +236,13 @@ TEST_F(ReadMessage, GTEST_TESTCASE(IfChannelNotInitialized, GTEST_ENABLED)) {
CCounter counter = CCounter(true);
// @- DUT1 try to read the message (with time-out)
retVal = dut1.ReadMessage(rcvMsg, TEST_READ_TIMEOUT);
+#if (OPTION_CANAPI_LIBRARY != 0)
+ EXPECT_EQ(CCanApi::NotInitialized, retVal);
+#else
+ // @note: wrapper/driver libraries return CANERR_HANDLE in this case.
+ // @ Would it not be better to return NOTINIT in C++ API?
EXPECT_EQ(CCanApi::InvalidHandle, retVal);
+#endif
// @post:
counter.Clear();
// @- initialize DUT1 with configured settings
@@ -260,6 +266,14 @@ TEST_F(ReadMessage, GTEST_TESTCASE(IfChannelNotInitialized, GTEST_ENABLED)) {
EXPECT_EQ(CCanApi::NoError, retVal);
// @- compare sent and received message
EXPECT_TRUE(dut1.CompareMessages(trmMsg, rcvMsg));
+#if (TC04_3_ISSUE_PCBUSB_BUFFERED_MSGS == WORKAROUND_ENABLED)
+ counter.Reset();
+ // @- issue(PCBUSB): buffered messages from device (PCAN-USB [Pro] FD)
+ while (dut1.ReadMessage(rcvMsg, TEST_READ_TIMEOUT) == CCanApi::NoError) {
+ counter.Increment();
+ }
+ counter.Clear();
+#endif
// @- send some frames to DUT2 and receive some frames from DUT2
int32_t frames = g_Options.GetNumberOfTestFrames();
EXPECT_EQ(frames, dut1.SendSomeFrames(dut2, frames));
@@ -473,7 +487,7 @@ TEST_F(ReadMessage, GTEST_TESTCASE(IfControllerStopped, GTEST_ENABLED)) {
// @gtest TC04.6: Read a CAN message if CAN channel was previously torn down
//
-// @expected: CANERR_HANDLE (would it not be better to return NOTINIT in C++ API?)
+// @expected: CANERR_NOTINIT (wrapper/driver libraries return CANERR_HANDLE)
//
TEST_F(ReadMessage, GTEST_TESTCASE(IfChannelTornDown, GTEST_ENABLED)) {
CCanDevice dut1 = CCanDevice(TEST_DEVICE(DUT1));
@@ -553,7 +567,13 @@ TEST_F(ReadMessage, GTEST_TESTCASE(IfChannelTornDown, GTEST_ENABLED)) {
CCounter counter = CCounter(true);
// @- DUT1 try to read the message (with time-out)
retVal = dut1.ReadMessage(rcvMsg, TEST_READ_TIMEOUT);
+#if (OPTION_CANAPI_LIBRARY != 0)
+ EXPECT_EQ(CCanApi::NotInitialized, retVal);
+#else
+ // @note: wrapper/driver libraries return CANERR_HANDLE in this case.
+ // @ Would it not be better to return NOTINIT in C++ API?
EXPECT_EQ(CCanApi::InvalidHandle, retVal);
+#endif
// @post:
counter.Clear();
// @- tear down DUT2
@@ -742,9 +762,19 @@ TEST_F(ReadMessage, GTEST_TESTCASE(IfReceiveQueueFull, GTEST_TC04_8_ENABLED)) {
#endif
// @test:
int32_t spam = (FEATURE_SIZE_RECEIVE_QUEUE + TEST_QRCVFULL);
-#if (TC04_8_ISSUE_QUEUE_SIZE == WORKAROUND_ENABLED)
+#if (TC04_8_ISSUE_PCBUSB_QUEUE_SIZE == WORKAROUND_ENABLED)
// @- issue(PCBUSB.TOS): last element of the receive queue is not accessible
- spam -= 1;
+ CANAPI_OpMode_t opCapa = { CANMODE_DEFAULT };
+ (void)dut1.GetOpCapabilities(opCapa);
+ if (!opCapa.fdoe) // note: PCAN-USB devices only!
+ spam -= 1;
+#endif
+#if (TC04_8_ISSUE_PCANBASIC_QUEUE_SIZE == WORKAROUND_ENABLED)
+ // @- issue(PCANBasic): I didn't understand the issue
+ CANAPI_OpMode_t opCapa = { CANMODE_DEFAULT };
+ (void)dut1.GetOpCapabilities(opCapa);
+ if (opCapa.fdoe) // note: PCAN-USB [Pro] FD devices only!
+ spam -= 1;
#endif
CProgress progress = CProgress(spam);
// @- DUT2 spam the receive queue of DUT1 (with one message more than the queue can hold)
@@ -1365,7 +1395,7 @@ TEST_F(ReadMessage, GTEST_TESTCASE(WithFlagRtrInOperationModeNoRtr, GTEST_ENABLE
//
// @expected: CANERR_NOERROR but status bit 'warning_level' is set and no status frame in the receive queue
//
-#if defined(__MAC_11_0)
+#if !defined(__APPLE__) || defined(__MAC_11_0)
#define GTEST_TC04_15_ENABLED GTEST_ENABLED
#else
#define GTEST_TC04_15_ENABLED GTEST_DISABLED
@@ -1393,15 +1423,20 @@ TEST_F(ReadMessage, GTEST_TESTCASE(WithFlagStsInOperationModeNoErr, GTEST_TC04_1
trmMsg.esi = 0;
trmMsg.dlc = 0;
memset(trmMsg.data, 0, CANFD_MAX_LEN);
-#endif
-#if (TC04_15_ISSUE_PCBUSB_WARNING_LEVEL == WORKAROUND_ENABLED)
- ASSERT_TRUE(false) << "[ TC04.15 ] No warning level from device!";
#endif
// @
// @note: This test cannot run if there is another device on bus!
if (g_Options.Is3rdDevicePresent())
GTEST_SKIP() << "This test cannot run if there is another device on bus!";
// @pre:
+#if (TC04_15_ISSUE_PCBUSB_WARNING_LEVEL == WORKAROUND_ENABLED)
+ // @- issue(PCBUSB): no warning level from device -> abort test
+ ASSERT_TRUE(false) << "[ TC04.15 ] No warning level from device!";
+#endif
+#if (TC04_15_ISSUE_TOUCAN_STATUS == WORKAROUND_ENABLED)
+ // @- issue(MacCAN-TouCAN): issue #32 (no bus error states from device) -> run with ICA
+ EXPECT_TRUE(false) << "[ TC04.15 ] Issue #32 (no bus error states from device)";
+#endif
// @- initialize DUT1 configured settings
retVal = dut1.InitializeChannel();
ASSERT_EQ(CCanApi::NoError, retVal) << "[ ERROR! ] dut1.InitializeChannel() failed with error code " << retVal;
@@ -1528,7 +1563,7 @@ TEST_F(ReadMessage, GTEST_TESTCASE(WithFlagStsInOperationModeNoErr, GTEST_TC04_1
//
// @expected: CANERR_NOERROR but status bit 'warning_level' is set and a status frame in the receive queue
//
-#if (FEATURE_ERROR_FRAMES != FEATURE_UNSUPPORTED) && defined(__MAC_11_0)
+#if (FEATURE_ERROR_FRAMES != FEATURE_UNSUPPORTED) && (!defined(__APPLE__) || defined(__MAC_11_0))
#define GTEST_TC04_16_ENABLED GTEST_ENABLED
#else
#define GTEST_TC04_16_ENABLED GTEST_DISABLED
@@ -1844,9 +1879,9 @@ TEST_F(ReadMessage, GTEST_TESTCASE(InOperationModeListenOnly, GTEST_ENABLED)) {
}
// @gtest TC04.18: Read a CAN message from empty queue with different time-out values
-//
+//
// @expected: CANERR_RX_EMPTY after time-out time has expired
-//
+//
TEST_F(ReadMessage, GTEST_TESTCASE(WithDifferentTimeoutValues, GTEST_ENABLED)) {
CCanDevice dut1 = CCanDevice(TEST_DEVICE(DUT1));
CCanDevice dut2 = CCanDevice(TEST_DEVICE(DUT2));
@@ -1978,4 +2013,4 @@ TEST_F(ReadMessage, GTEST_TESTCASE(WithDifferentTimeoutValues, GTEST_ENABLED)) {
// @todo: (1) blocking read
// @todo: (2) test reentrancy
-// $Id: TC04_ReadMessage.cc 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin.
+// $Id: TC04_ReadMessage.cc 1329 2024-05-30 18:13:31Z quaoar $ Copyright (c) UV Software, Berlin.
diff --git a/Tests/CANAPI/Testcases/TC05_WriteMessage.cc b/Tests/CANAPI/Testcases/TC05_WriteMessage.cc
index dc45d96..2a4b66b 100644
--- a/Tests/CANAPI/Testcases/TC05_WriteMessage.cc
+++ b/Tests/CANAPI/Testcases/TC05_WriteMessage.cc
@@ -178,7 +178,7 @@ TEST_F(WriteMessage, GTEST_TESTCASE(SunnydayScenario, GTEST_SUNNYDAY)) {
// @gtest TC05.3: Send a CAN message if CAN channel is not initialized
//
-// @expected: CANERR_HANDLE (would it not be better to return NOTINIT in C++ API?)
+// @expected: CANERR_NOTINIT (wrapper/driver libraries return CANERR_HANDLE)
//
TEST_F(WriteMessage, GTEST_TESTCASE(IfChannelNotInitialized, GTEST_ENABLED)) {
CCanDevice dut1 = CCanDevice(TEST_DEVICE(DUT1));
@@ -221,7 +221,13 @@ TEST_F(WriteMessage, GTEST_TESTCASE(IfChannelNotInitialized, GTEST_ENABLED)) {
CCounter counter = CCounter(true);
// @- DUT1 try to send out one message
retVal = dut1.WriteMessage(trmMsg);
+#if (OPTION_CANAPI_LIBRARY != 0)
+ EXPECT_EQ(CCanApi::NotInitialized, retVal);
+#else
+ // @note: wrapper/driver libraries return CANERR_HANDLE in this case.
+ // @ Would it not be better to return NOTINIT in C++ API?
EXPECT_EQ(CCanApi::InvalidHandle, retVal);
+#endif
// @- DUT2 wait in vain for the message
retVal = dut2.ReadMessage(rcvMsg, TEST_READ_TIMEOUT);
EXPECT_EQ(CCanApi::ReceiverEmpty, retVal);
@@ -457,7 +463,7 @@ TEST_F(WriteMessage, GTEST_TESTCASE(IfControllerStopped, GTEST_ENABLED)) {
// @gtest TC05.6: Send a CAN message if CAN channel was previously torn down
//
-// @expected: CANERR_HANDLE (would it not be better to return NOTINIT in C++ API?)
+// @expected: CANERR_NOTINIT (wrapper/driver libraries return CANERR_HANDLE)
//
TEST_F(WriteMessage, GTEST_TESTCASE(IfChannelTornDown, GTEST_ENABLED)) {
CCanDevice dut1 = CCanDevice(TEST_DEVICE(DUT1));
@@ -534,7 +540,13 @@ TEST_F(WriteMessage, GTEST_TESTCASE(IfChannelTornDown, GTEST_ENABLED)) {
CCounter counter = CCounter(true);
// @- DUT1 try to send out one message
retVal = dut1.WriteMessage(trmMsg);
+#if (OPTION_CANAPI_LIBRARY != 0)
+ EXPECT_EQ(CCanApi::NotInitialized, retVal);
+#else
+ // @note: wrapper/driver libraries return CANERR_HANDLE in this case.
+ // @ Would it not be better to return NOTINIT in C++ API?
EXPECT_EQ(CCanApi::InvalidHandle, retVal);
+#endif
// @- DUT2 wait in vain for the message
retVal = dut2.ReadMessage(rcvMsg, TEST_READ_TIMEOUT);
EXPECT_EQ(CCanApi::ReceiverEmpty, retVal);
@@ -2211,4 +2223,4 @@ TEST_F(WriteMessage, GTEST_TESTCASE(WithFlagEsi, GTEST_ENABLED)) {
// @todo: (1) blocking write
// @todo: (2) test reentrancy
-// $Id: TC05_WriteMessage.cc 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin.
+// $Id: TC05_WriteMessage.cc 1314 2024-05-26 08:39:33Z quaoar $ Copyright (c) UV Software, Berlin.
diff --git a/Tests/CANAPI/Testcases/TC09_GetStatus.cc b/Tests/CANAPI/Testcases/TC09_GetStatus.cc
index 634d9d5..f615c17 100644
--- a/Tests/CANAPI/Testcases/TC09_GetStatus.cc
+++ b/Tests/CANAPI/Testcases/TC09_GetStatus.cc
@@ -388,7 +388,12 @@ TEST_F(GetStatus, GTEST_TESTCASE(IfChannelTornDown, GTEST_ENABLED)) {
//
// @expected: CANERR_NOERROR but status bit 'bus_off' is set
//
-TEST_F(GetStatus, GTEST_TESTCASE(IfInBusOffState, GTEST_ENABLED)) {
+#if !defined(__APPLE__) || defined(__MAC_11_0)
+#define GTEST_TC09_8_ENABLED GTEST_ENABLED
+#else
+#define GTEST_TC09_8_ENABLED GTEST_DISABLED
+#endif
+TEST_F(GetStatus, GTEST_TESTCASE(IfInBusOffState, GTEST_TC09_8_ENABLED)) {
CCanDevice dut1 = CCanDevice(TEST_DEVICE(DUT1));
CCanDevice dut2 = CCanDevice(TEST_DEVICE(DUT2));
CANAPI_Bitrate_t newBtr1 = {}, oldBtr1 = {};
@@ -410,15 +415,23 @@ TEST_F(GetStatus, GTEST_TESTCASE(IfInBusOffState, GTEST_ENABLED)) {
trmMsg.esi = 0;
trmMsg.dlc = 0;
memset(trmMsg.data, 0, CANFD_MAX_LEN);
-#endif
-#if (TC09_8_ISSUE_BUS_OFF == WORKAROUND_ENABLED)
- ASSERT_TRUE(false) << "[ TC09.8 ] No bus-off state from device!";
#endif
// @
+ // @note: This test can be very fragile
+ if (g_Options.RunQuick())
+ GTEST_SKIP() << "This test can be very fragile!";
// @note: This test cannot run if there is another device on bus!
if (g_Options.Is3rdDevicePresent())
GTEST_SKIP() << "This test cannot run if there is another device on bus!";
// @pre:
+#if (TC09_8_ISSUE_BUS_OFF == WORKAROUND_ENABLED)
+ // @- issue(*): no bus-off state from device -> abort test
+ ASSERT_TRUE(false) << "[ TC09.8 ] No bus-off state from device!";
+#endif
+#if (TC09_8_ISSUE_TOUCAN_STATUS == WORKAROUND_ENABLED)
+ // @- issue(MacCAN-TouCAN): issue #32 (no bus error states from device) -> abort test
+ ASSERT_TRUE(false) << "[ TC09.8 ] Issue #32 (no bus error states from device)";
+#endif
// @- initialize DUT1 with configured settings
retVal = dut1.InitializeChannel();
ASSERT_EQ(CCanApi::NoError, retVal) << "[ ERROR! ] dut1.InitializeChannel() failed with error code " << retVal;
@@ -545,7 +558,12 @@ TEST_F(GetStatus, GTEST_TESTCASE(IfInBusOffState, GTEST_ENABLED)) {
//
// @expected: CANERR_NOERROR but status bit 'warning_level' is set
//
-TEST_F(GetStatus, GTEST_TESTCASE(IfWarningLevelReached, GTEST_ENABLED)) {
+#if !defined(__APPLE__) || defined(__MAC_11_0)
+#define GTEST_TC09_9_ENABLED GTEST_ENABLED
+#else
+#define GTEST_TC09_9_ENABLED GTEST_DISABLED
+#endif
+TEST_F(GetStatus, GTEST_TESTCASE(IfWarningLevelReached, GTEST_TC09_9_ENABLED)) {
CCanDevice dut1 = CCanDevice(TEST_DEVICE(DUT1));
CCanDevice dut2 = CCanDevice(TEST_DEVICE(DUT2));
CANAPI_Bitrate_t newBtr1 = {}, oldBtr1 = {};
@@ -567,15 +585,23 @@ TEST_F(GetStatus, GTEST_TESTCASE(IfWarningLevelReached, GTEST_ENABLED)) {
trmMsg.esi = 0;
trmMsg.dlc = 0;
memset(trmMsg.data, 0, CANFD_MAX_LEN);
-#endif
-#if (TC09_9_ISSUE_PCBUSB_WARNING_LEVEL == WORKAROUND_ENABLED)
- ASSERT_TRUE(false) << "[ TC09.9 ] No warning level from device!";
#endif
// @
+ // @note: This test can be very fragile
+ if (g_Options.RunQuick())
+ GTEST_SKIP() << "This test can be very fragile!";
// @note: This test cannot run if there is another device on bus!
if (g_Options.Is3rdDevicePresent())
GTEST_SKIP() << "This test cannot run if there is another device on bus!";
// @pre:
+#if (TC09_9_ISSUE_PCBUSB_WARNING_LEVEL == WORKAROUND_ENABLED)
+ // @- issue(PCBUSB): no warning level from device -> abort test
+ ASSERT_TRUE(false) << "[ TC09.9 ] No warning level from device!";
+#endif
+#if (TC09_9_ISSUE_TOUCAN_STATUS == WORKAROUND_ENABLED)
+ // @- issue(MacCAN-TouCAN): issue #32 (no bus error states from device) -> run with ICA
+ EXPECT_TRUE(false) << "[ TC09.9 ] Issue #32 (no bus error states from device)";
+#endif
// @- initialize DUT1 with configured settings
retVal = dut1.InitializeChannel();
ASSERT_EQ(CCanApi::NoError, retVal) << "[ ERROR! ] dut1.InitializeChannel() failed with error code " << retVal;
@@ -728,10 +754,17 @@ TEST_F(GetStatus, GTEST_TESTCASE(IfErrorsOnBus, GTEST_TC09_10_ENABLED)) {
memset(trmMsg.data, 0, CANFD_MAX_LEN);
#endif
// @
+ // @note: This test can be very fragile
+ if (g_Options.RunQuick())
+ GTEST_SKIP() << "This test can be very fragile!";
// @note: This test cannot run if there is another device on bus!
if (g_Options.Is3rdDevicePresent())
GTEST_SKIP() << "This test cannot run if there is another device on bus!";
// @pre:
+#if (TC09_8_ISSUE_TOUCAN_STATUS == WORKAROUND_ENABLED)
+ // @- issue(MacCAN-TouCAN): issue #32 (no bus error states from device) -> abort test
+ ASSERT_TRUE(false) << "[ TC09.10 ] Issue #32 (no bus error states from device)";
+#endif
// @- initialize DUT1 with configured settings
retVal = dut1.InitializeChannel();
ASSERT_EQ(CCanApi::NoError, retVal) << "[ ERROR! ] dut1.InitializeChannel() failed with error code " << retVal;
@@ -1193,9 +1226,12 @@ TEST_F(GetStatus, GTEST_TESTCASE(IfReceiveQueueFull, GTEST_TC09_14_ENABLED)) {
#endif
// @test:
int32_t spam = (FEATURE_SIZE_RECEIVE_QUEUE + TEST_QRCVFULL);
-#if (TC04_8_ISSUE_QUEUE_SIZE == WORKAROUND_ENABLED)
+#if (TC04_8_ISSUE_PCBUSB_QUEUE_SIZE == WORKAROUND_ENABLED)
// @- issue(PCBUSB.TOS): last element of the receive queue is not accessible
- spam -= 1;
+ CANAPI_OpMode_t opCapa = { CANMODE_DEFAULT };
+ (void)dut1.GetOpCapabilities(opCapa);
+ if (!opCapa.fdoe) // note: PCAN-USB devices only!
+ spam -= 1;
#endif
CProgress progress = CProgress(spam);
// @- DUT2 spam the receive queue of DUT1 (with one message more than the queue can hold)
@@ -1318,4 +1354,4 @@ TEST_F(GetStatus, GTEST_TESTCASE(IfReceiveQueueFull, GTEST_TC09_14_ENABLED)) {
// @end.
}
-// $Id: TC09_GetStatus.cc 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin.
+// $Id: TC09_GetStatus.cc 1328 2024-05-29 18:49:38Z makemake $ Copyright (c) UV Software, Berlin.
diff --git a/Tests/CANAPI/Testcases/TC11_GetBitrate.cc b/Tests/CANAPI/Testcases/TC11_GetBitrate.cc
index d8f8522..88cbb00 100644
--- a/Tests/CANAPI/Testcases/TC11_GetBitrate.cc
+++ b/Tests/CANAPI/Testcases/TC11_GetBitrate.cc
@@ -170,10 +170,23 @@ TEST_F(GetBitrate, GTEST_TESTCASE(IfChannelNotInitialized, GTEST_ENABLED)) {
// @test:
// @- get bit-rate settings from DUT1
retVal = dut1.GetBitrate(bitrate);
+#if (TC11_5_ISSUE_BITRATE != WORKAROUND_ENABLED)
EXPECT_EQ(CCanApi::NotInitialized, retVal);
+#else
+ // @issue(Loader Library):
+ // @ The tester class overwrites GetBitrate by using the C function can_property.
+ // @ The underlying C function can_bitrate is tested anyway, but returns
+ // @ CANERR_NOTSUPP because can_property is called with handle -1.
+ EXPECT_EQ(CCanApi::NotSupported, retVal);
+#endif
// @- get transmission rate from DUT1
retVal = dut1.GetBusSpeed(speed);
+#if (TC11_5_ISSUE_BITRATE != WORKAROUND_ENABLED)
EXPECT_EQ(CCanApi::NotInitialized, retVal);
+#else
+ // @issue(Loader Library): see above
+ EXPECT_EQ(CCanApi::NotSupported, retVal);
+#endif
// @post
// @- initialize DUT1 with configured settings
retVal = dut1.InitializeChannel();
@@ -436,10 +449,23 @@ TEST_F(GetBitrate, GTEST_TESTCASE(IfChannelTornDown, GTEST_ENABLED)) {
// @test:
// @- get bit-rate settings from DUT1
retVal = dut1.GetBitrate(bitrate);
+#if (TC11_9_ISSUE_BITRATE != WORKAROUND_ENABLED)
EXPECT_EQ(CCanApi::NotInitialized, retVal);
+#else
+ // @issue(Loader Library):
+ // @ The tester class overwrites GetBitrate by using the C function can_property.
+ // @ The underlying C function can_bitrate is tested anyway, but returns
+ // @ CANERR_NOTSUPP because can_property is called with handle -1.
+ EXPECT_EQ(CCanApi::NotSupported, retVal);
+#endif
// @- get transmission rate from DUT1
retVal = dut1.GetBusSpeed(speed);
+#if (TC11_9_ISSUE_BITRATE != WORKAROUND_ENABLED)
EXPECT_EQ(CCanApi::NotInitialized, retVal);
+#else
+ // @issue(Loader Library): see above
+ EXPECT_EQ(CCanApi::NotSupported, retVal);
+#endif
// @end.
}
@@ -662,4 +688,4 @@ TEST_F(GetBitrate, GTEST_TESTCASE(WithVariousCanFdBitrateSettings, GTEST_ENABLED
}
#endif // (CAN_FD_SUPPORTED == FEATURE_SUPPORTED)
-// $Id: TC11_GetBitrate.cc 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin.
+// $Id: TC11_GetBitrate.cc 1314 2024-05-26 08:39:33Z quaoar $ Copyright (c) UV Software, Berlin.
diff --git a/Tests/CANAPI/Testcases/TCx1_CallSequences.cc b/Tests/CANAPI/Testcases/TCx1_CallSequences.cc
index 35b189c..97e9596 100644
--- a/Tests/CANAPI/Testcases/TCx1_CallSequences.cc
+++ b/Tests/CANAPI/Testcases/TCx1_CallSequences.cc
@@ -1042,11 +1042,11 @@ TEST_F(CallSequences, GTEST_TESTCASE(InitializeStartResetStartResetTeardownIniti
// @end.
}
-// @gtest TCx1.24: Call sequence 'Initialize-Start-Reset-Start-Teardown-Initialize-Start-Reset-Start-Reset-Teardown'
+// @gtest TCx1.24: Call sequence 'Initialize-Start-Reset-Start-Teardown-Initialize-Start-Reset-Reset-Start-Teardown'
//
// @expected: CANERR_NOERROR
//
-TEST_F(CallSequences, GTEST_TESTCASE(InitializeStartResetStartTeardownInitializeStartResetStartResetTeardown, GTEST_ENABLED)) {
+TEST_F(CallSequences, GTEST_TESTCASE(InitializeStartResetStartTeardownInitializeStartResetResetStartTeardown, GTEST_ENABLED)) {
CCanDevice dut = CCanDevice(TEST_DEVICE(DUT1));
CANAPI_Return_t retVal = CCanApi::FatalError;
CANAPI_Status_t status = { CANSTAT_RESET };
@@ -1089,7 +1089,7 @@ TEST_F(CallSequences, GTEST_TESTCASE(InitializeStartResetStartTeardownInitialize
EXPECT_EQ(CCanApi::NoError, dut.GetStatus(status));
EXPECT_TRUE(status.can_stopped);
// @- stop/reset DUT
- EXPECT_EQ(CCanApi::NoError, dut.ResetController());
+ EXPECT_NE(CCanApi::NoError, dut.ResetController());
EXPECT_EQ(CCanApi::NoError, dut.GetStatus(status));
EXPECT_TRUE(status.can_stopped);
// @- start DUT again with configured bit rate
@@ -1504,4 +1504,4 @@ TEST_F(CallSequences, GTEST_TESTCASE(ReadInitializeTeardown, GTEST_DISABLED)) {
// @end.
}
-// $Id: TCx1_CallSequences.cc 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin.
+// $Id: TCx1_CallSequences.cc 1336 2024-06-03 06:58:36Z makemake $ Copyright (c) UV Software, Berlin.
diff --git a/Tests/CANAPI/Testcases/TCxX_Summary.cc b/Tests/CANAPI/Testcases/TCxX_Summary.cc
new file mode 100644
index 0000000..4c0b905
--- /dev/null
+++ b/Tests/CANAPI/Testcases/TCxX_Summary.cc
@@ -0,0 +1,430 @@
+// SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-or-later
+//
+// CAN Interface API, Version 3 (Testing)
+//
+// Copyright (c) 2004-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com)
+// All rights reserved.
+//
+// This file is part of CAN API V3.
+//
+// CAN API V3 is dual-licensed under the BSD 2-Clause "Simplified" License
+// and under the GNU General Public License v3.0 (or any later version).
+// You can choose between one of them if you use this file.
+//
+// BSD 2-Clause "Simplified" License:
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+// 1. Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// CAN API V3 IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF CAN API V3, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// GNU General Public License v3.0 or later:
+// CAN API V3 is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// CAN API V3 is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with CAN API V3. If not, see .
+//
+#include "pch.h"
+
+#include
+
+class Summary : public testing::Test {
+ virtual void SetUp() {}
+ virtual void TearDown() {}
+protected:
+ // ...
+};
+
+// @gtest TCxX.1: Get library information
+//
+// @expected: CANERR_NOERROR
+//
+TEST_F(Summary, GTEST_TESTCASE(GetLibraryInformation, GTEST_ENABLED)) {
+ CCanDevice dut = CCanDevice(TEST_DEVICE(DUT1));
+ CANAPI_OpMode_t opMode = {};
+ CANAPI_Bitrate_t bitrate = {};
+ CANAPI_BusSpeed_t speed = {};
+ CANAPI_Return_t retVal;
+
+ uint8_t u8Val = 0U;
+ uint16_t u16Val = 0U;
+ uint32_t u32Val = 0U;
+ int32_t i32Val = 0U;
+ char string[CANPROP_MAX_BUFFER_SIZE + 1];
+ // @
+ // @note: This test is optional!
+ if (!g_Options.RunTestBitrateConverter())
+ GTEST_SKIP() << "This test is optional: '--run_all=YES'";
+ // @test:
+ // @- version of the wrapper specification
+ retVal = dut.GetProperty(CANPROP_GET_SPEC, (void*)&u16Val, sizeof(uint16_t));
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ if (CCanApi::NoError == retVal) {
+ snprintf(string, CANPROP_MAX_BUFFER_SIZE, "V%u.%u", (u16Val >> 8), (u16Val & 0xFFU));
+ string[CANPROP_MAX_BUFFER_SIZE] = '\0';
+ RecordProperty("CanApi", string);
+ }
+ // @- version number of the library
+ retVal = dut.GetProperty(CANPROP_GET_VERSION, (void*)&u16Val, sizeof(uint16_t));
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ if (CCanApi::NoError == retVal) {
+ snprintf(string, CANPROP_MAX_BUFFER_SIZE, "V%u.%u", (u16Val >> 8), (u16Val & 0xFFU));
+ string[CANPROP_MAX_BUFFER_SIZE] = '\0';
+ RecordProperty("Version", string);
+ }
+ // @- patch number of the library
+ retVal = dut.GetProperty(CANPROP_GET_PATCH_NO, (void*)&u8Val, sizeof(uint8_t));
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ if (CCanApi::NoError == retVal) {
+ snprintf(string, CANPROP_MAX_BUFFER_SIZE, "%u", u8Val);
+ string[CANPROP_MAX_BUFFER_SIZE] = '\0';
+ RecordProperty("PatchNo", string);
+ }
+ // @- build number of the library
+ retVal = dut.GetProperty(CANPROP_GET_BUILD_NO, (void*)&u32Val, sizeof(uint32_t));
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ if (CCanApi::NoError == retVal) {
+ snprintf(string, CANPROP_MAX_BUFFER_SIZE, "%07" PRIx32 "", u32Val);
+ string[CANPROP_MAX_BUFFER_SIZE] = '\0';
+ RecordProperty("BuildNo", string);
+ }
+ // @- library id of the library
+ retVal = dut.GetProperty(CANPROP_GET_LIBRARY_ID, (void*)&i32Val, sizeof(int32_t));
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ if (CCanApi::NoError == retVal) {
+ snprintf(string, CANPROP_MAX_BUFFER_SIZE, "%" PRIi32 "", i32Val);
+ string[CANPROP_MAX_BUFFER_SIZE] = '\0';
+ RecordProperty("LibraryId", string);
+ }
+ // @- file name of the library DLL
+ retVal = dut.GetProperty(CANPROP_GET_LIBRARY_DLLNAME, (void*)string, CANPROP_MAX_BUFFER_SIZE);
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ if (CCanApi::NoError == retVal) {
+ string[CANPROP_MAX_BUFFER_SIZE] = '\0';
+ RecordProperty("LibraryName", string);
+ }
+ // @- vendor name of the library
+ retVal = dut.GetProperty(CANPROP_GET_LIBRARY_VENDOR, (void*)string, CANPROP_MAX_BUFFER_SIZE);
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ if (CCanApi::NoError == retVal) {
+ string[CANPROP_MAX_BUFFER_SIZE] = '\0';
+ RecordProperty("LibraryVendor", string);
+ }
+ // @- requested operation mode
+ opMode = g_Options.GetOpMode(DUT1);
+#if (OPTION_CAN_2_0_ONLY == 0)
+ if (opMode.fdoe)
+ snprintf(string, CANPROP_MAX_BUFFER_SIZE, "CAN FD (FDOE=Yes BRSE=%s)", opMode.brse ? "Yes" : "No");
+ else
+ snprintf(string, CANPROP_MAX_BUFFER_SIZE, "CAN CC (2.0)");
+ string[CANPROP_MAX_BUFFER_SIZE] = '\0';
+ RecordProperty("OperationMode", string);
+#else
+ RecordProperty("OperationMode", "CAN CC (2.0)");
+#endif
+ // @ regested bit-rate settings
+ bitrate = g_Options.GetBitrate(DUT1);
+ if (CCanDevice::MapBitrate2Speed(bitrate, speed) == CCanApi::NoError) {
+#if (OPTION_CAN_2_0_ONLY == 0)
+ if (opMode.fdoe) {
+ snprintf(string, CANPROP_MAX_BUFFER_SIZE, "%.3f kbps (SP=%.2f%%, SJW=%u)\n",
+ speed.nominal.speed / 1000.f, speed.nominal.samplepoint * 100.f,
+ bitrate.btr.nominal.sjw);
+ string[CANPROP_MAX_BUFFER_SIZE] = '\0';
+ RecordProperty("BusSpeed.Nominal", string);
+ snprintf(string, CANPROP_MAX_BUFFER_SIZE, "%.3f kbps (SP=%.2f%%, SJW=%u)\n",
+ speed.data.speed / 1000.f, speed.data.samplepoint * 100.f,
+ bitrate.btr.data.sjw);
+ string[CANPROP_MAX_BUFFER_SIZE] = '\0';
+ RecordProperty("BusSpeed.DataPhase", string);
+ }
+ else {
+ snprintf(string, CANPROP_MAX_BUFFER_SIZE, "%.3f kbps (SP=%.2f%%, SJW=%u, SAM=%u)\n",
+ speed.nominal.speed / 1000.f, speed.nominal.samplepoint * 100.f,
+ bitrate.btr.nominal.sjw, bitrate.btr.nominal.sam);
+ string[CANPROP_MAX_BUFFER_SIZE] = '\0';
+ RecordProperty("BusSpeed.Nominal", string);
+ }
+#else
+ snprintf(string, CANPROP_MAX_BUFFER_SIZE, "%.3f kbps (SP=%.2f%%, SJW=%u, SAM=%u)\n",
+ speed.nominal.speed / 1000.f, speed.nominal.samplepoint * 100.f,
+ bitrate.btr.nominal.sjw, bitrate.btr.nominal.sam);
+ string[CANPROP_MAX_BUFFER_SIZE] = '\0';
+ RecordProperty("BusSpeed.Nominal", string);
+#endif
+ }
+ // @end.
+}
+
+// @gtest TCxX.2: Get information of DUT1
+//
+// @expected: CANERR_NOERROR
+//
+TEST_F(Summary, GTEST_TESTCASE(GetDevice1Information, GTEST_ENABLED)) {
+ CCanDevice dut = CCanDevice(TEST_DEVICE(DUT1));
+ CANAPI_OpMode_t opCapa = {};
+ CANAPI_Return_t retVal;
+
+ uint8_t u8Val = 0U;
+ uint16_t u16Val = 0U;
+ uint32_t u32Val = 0U;
+ int32_t i32Val = 0U;
+ char string[CANPROP_MAX_BUFFER_SIZE + 1];
+ // @
+ // @note: This test is optional!
+ if (!g_Options.RunTestBitrateConverter())
+ GTEST_SKIP() << "This test is optional: '--run_all=YES'";
+ // @test:
+ // @- initialize DUT1 with configured settings
+ retVal = dut.InitializeChannel();
+ ASSERT_EQ(CCanApi::NoError, retVal) << "[ ERROR! ] dut.InitializeChannel() failed with error code " << retVal;
+ // @- version of the wrapper specification
+ retVal = dut.GetProperty(CANPROP_GET_SPEC, (void*)&u16Val, sizeof(uint16_t));
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ if (CCanApi::NoError == retVal) {
+ snprintf(string, CANPROP_MAX_BUFFER_SIZE, "V%u.%u", (u16Val >> 8), (u16Val & 0xFFU));
+ string[CANPROP_MAX_BUFFER_SIZE] = '\0';
+ RecordProperty("CanApiVersion", string);
+ }
+ // @- version number of the library
+ retVal = dut.GetProperty(CANPROP_GET_VERSION, (void*)&u16Val, sizeof(uint16_t));
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ if (CCanApi::NoError == retVal) {
+ snprintf(string, CANPROP_MAX_BUFFER_SIZE, "V%u.%u", (u16Val >> 8), (u16Val & 0xFFU));
+ string[CANPROP_MAX_BUFFER_SIZE] = '\0';
+ RecordProperty("WrapperVersion", string);
+ }
+ // @- patch number of the library
+ retVal = dut.GetProperty(CANPROP_GET_PATCH_NO, (void*)&u8Val, sizeof(uint8_t));
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ if (CCanApi::NoError == retVal) {
+ snprintf(string, CANPROP_MAX_BUFFER_SIZE, "%u", u8Val);
+ string[CANPROP_MAX_BUFFER_SIZE] = '\0';
+ RecordProperty("WrapperPatchNo", string);
+ }
+ // @- build number of the library
+ retVal = dut.GetProperty(CANPROP_GET_BUILD_NO, (void*)&u32Val, sizeof(uint32_t));
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ if (CCanApi::NoError == retVal) {
+ snprintf(string, CANPROP_MAX_BUFFER_SIZE, "%07" PRIx32 "", u32Val);
+ string[CANPROP_MAX_BUFFER_SIZE] = '\0';
+ RecordProperty("WrapperBuildNo", string);
+ }
+ // @- library id of the library
+ retVal = dut.GetProperty(CANPROP_GET_LIBRARY_ID, (void*)&i32Val, sizeof(int32_t));
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ if (CCanApi::NoError == retVal) {
+ snprintf(string, CANPROP_MAX_BUFFER_SIZE, "%" PRIi32 "", i32Val);
+ string[CANPROP_MAX_BUFFER_SIZE] = '\0';
+ RecordProperty("WrapperLibraryId", string);
+ }
+ // @- file name of the library DLL
+ retVal = dut.GetProperty(CANPROP_GET_LIBRARY_DLLNAME, (void*)string, CANPROP_MAX_BUFFER_SIZE);
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ if (CCanApi::NoError == retVal) {
+ string[CANPROP_MAX_BUFFER_SIZE] = '\0';
+ RecordProperty("WrapperLibraryName", string);
+ }
+ // @- vendor name of the library
+ retVal = dut.GetProperty(CANPROP_GET_LIBRARY_VENDOR, (void*)string, CANPROP_MAX_BUFFER_SIZE);
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ if (CCanApi::NoError == retVal) {
+ string[CANPROP_MAX_BUFFER_SIZE] = '\0';
+ RecordProperty("WrapperLibraryVendor", string);
+ }
+ // @- channel id. of the interface
+ i32Val = dut.GetChannelNo();
+ if (0 <= i32Val) {
+ snprintf(string, CANPROP_MAX_BUFFER_SIZE, "%" PRIi32 "", i32Val);
+ string[CANPROP_MAX_BUFFER_SIZE] = '\0';
+ RecordProperty("DeviceChannelNo", string);
+ }
+ // @- channel name of the CAN interface
+ retVal = dut.GetProperty(CANPROP_GET_DEVICE_NAME, (void*)string, CANPROP_MAX_BUFFER_SIZE);
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ if (CCanApi::NoError == retVal) {
+ string[CANPROP_MAX_BUFFER_SIZE] = '\0';
+ RecordProperty("DeviceChannelName", string);
+ }
+ // @- file name of the CAN interface DLL
+ retVal = dut.GetProperty(CANPROP_GET_DEVICE_DLLNAME, (void*)string, CANPROP_MAX_BUFFER_SIZE);
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ if (CCanApi::NoError == retVal) {
+ string[CANPROP_MAX_BUFFER_SIZE] = '\0';
+ RecordProperty("DeviceLibraryName", string);
+ }
+ // @- vendor name of the CAN interface
+ retVal = dut.GetProperty(CANPROP_GET_DEVICE_VENDOR, (void*)string, CANPROP_MAX_BUFFER_SIZE);
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ if (CCanApi::NoError == retVal) {
+ string[CANPROP_MAX_BUFFER_SIZE] = '\0';
+ RecordProperty("DeviceLibraryVendor", string);
+ }
+ // @- supported operation capabilities
+ retVal = dut.GetOpCapabilities(opCapa);
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ if (CCanApi::NoError == retVal) {
+#if (OPTION_CAN_2_0_ONLY == 0)
+ RecordProperty("DeviceCapability.FDOE", opCapa.fdoe ? "Yes" : "No");
+ RecordProperty("DeviceCapability.BRSE", opCapa.brse ? "Yes" : "No");
+ RecordProperty("DeviceCapability.NISO", opCapa.niso ? "Yes" : "No");
+#endif
+ RecordProperty("DeviceCapability.SHRD", opCapa.shrd ? "Yes" : "No");
+ RecordProperty("DeviceCapability.NXTD", opCapa.nxtd ? "Yes" : "No");
+ RecordProperty("DeviceCapability.NRTR", opCapa.nrtr ? "Yes" : "No");
+ RecordProperty("DeviceCapability.ERR", opCapa.err ? "Yes" : "No");
+ RecordProperty("DeviceCapability.MON", opCapa.mon ? "Yes" : "No");
+ }
+ // @- tear down DUT1
+ retVal = dut.TeardownChannel();
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ // @end.
+}
+
+// @gtest TCxX.3: Get information of DUT2
+//
+// @expected: CANERR_NOERROR
+//
+TEST_F(Summary, GTEST_TESTCASE(GetDevice2Information, GTEST_ENABLED)) {
+ CCanDevice dut = CCanDevice(TEST_DEVICE(DUT2));
+ CANAPI_OpMode_t opCapa = {};
+ CANAPI_Return_t retVal;
+
+ uint8_t u8Val = 0U;
+ uint16_t u16Val = 0U;
+ uint32_t u32Val = 0U;
+ int32_t i32Val = 0U;
+ char string[CANPROP_MAX_BUFFER_SIZE + 1];
+ // @
+ // @note: This test is optional!
+ if (!g_Options.RunTestBitrateConverter())
+ GTEST_SKIP() << "This test is optional: '--run_all=YES'";
+ // @test:
+ // @- initialize DUT2 with configured settings
+ retVal = dut.InitializeChannel();
+ ASSERT_EQ(CCanApi::NoError, retVal) << "[ ERROR! ] dut.InitializeChannel() failed with error code " << retVal;
+ // @- version of the wrapper specification
+ retVal = dut.GetProperty(CANPROP_GET_SPEC, (void*)&u16Val, sizeof(uint16_t));
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ if (CCanApi::NoError == retVal) {
+ snprintf(string, CANPROP_MAX_BUFFER_SIZE, "V%u.%u", (u16Val >> 8), (u16Val & 0xFFU));
+ string[CANPROP_MAX_BUFFER_SIZE] = '\0';
+ RecordProperty("CanApiVersion", string);
+ }
+ // @- version number of the library
+ retVal = dut.GetProperty(CANPROP_GET_VERSION, (void*)&u16Val, sizeof(uint16_t));
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ if (CCanApi::NoError == retVal) {
+ snprintf(string, CANPROP_MAX_BUFFER_SIZE, "V%u.%u", (u16Val >> 8), (u16Val & 0xFFU));
+ string[CANPROP_MAX_BUFFER_SIZE] = '\0';
+ RecordProperty("WrapperVersion", string);
+ }
+ // @- patch number of the library
+ retVal = dut.GetProperty(CANPROP_GET_PATCH_NO, (void*)&u8Val, sizeof(uint8_t));
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ if (CCanApi::NoError == retVal) {
+ snprintf(string, CANPROP_MAX_BUFFER_SIZE, "%u", u8Val);
+ string[CANPROP_MAX_BUFFER_SIZE] = '\0';
+ RecordProperty("WrapperPatchNo", string);
+ }
+ // @- build number of the library
+ retVal = dut.GetProperty(CANPROP_GET_BUILD_NO, (void*)&u32Val, sizeof(uint32_t));
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ if (CCanApi::NoError == retVal) {
+ snprintf(string, CANPROP_MAX_BUFFER_SIZE, "%07" PRIx32 "", u32Val);
+ string[CANPROP_MAX_BUFFER_SIZE] = '\0';
+ RecordProperty("WrapperBuildNo", string);
+ }
+ // @- library id of the library
+ retVal = dut.GetProperty(CANPROP_GET_LIBRARY_ID, (void*)&i32Val, sizeof(int32_t));
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ if (CCanApi::NoError == retVal) {
+ snprintf(string, CANPROP_MAX_BUFFER_SIZE, "%" PRIi32 "", i32Val);
+ string[CANPROP_MAX_BUFFER_SIZE] = '\0';
+ RecordProperty("WrapperLibraryId", string);
+ }
+ // @- file name of the library DLL
+ retVal = dut.GetProperty(CANPROP_GET_LIBRARY_DLLNAME, (void*)string, CANPROP_MAX_BUFFER_SIZE);
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ if (CCanApi::NoError == retVal) {
+ string[CANPROP_MAX_BUFFER_SIZE] = '\0';
+ RecordProperty("WrapperLibraryName", string);
+ }
+ // @- vendor name of the library
+ retVal = dut.GetProperty(CANPROP_GET_LIBRARY_VENDOR, (void*)string, CANPROP_MAX_BUFFER_SIZE);
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ if (CCanApi::NoError == retVal) {
+ string[CANPROP_MAX_BUFFER_SIZE] = '\0';
+ RecordProperty("WrapperLibraryVendor", string);
+ }
+ // @- channel id. of the interface
+ i32Val = dut.GetChannelNo();
+ if (0 <= i32Val) {
+ snprintf(string, CANPROP_MAX_BUFFER_SIZE, "%" PRIi32 "", i32Val);
+ string[CANPROP_MAX_BUFFER_SIZE] = '\0';
+ RecordProperty("DeviceChannelNo", string);
+ }
+ // @- channel name of the CAN interface
+ retVal = dut.GetProperty(CANPROP_GET_DEVICE_NAME, (void*)string, CANPROP_MAX_BUFFER_SIZE);
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ if (CCanApi::NoError == retVal) {
+ string[CANPROP_MAX_BUFFER_SIZE] = '\0';
+ RecordProperty("DeviceChannelName", string);
+ }
+ // @- file name of the CAN interface DLL
+ retVal = dut.GetProperty(CANPROP_GET_DEVICE_DLLNAME, (void*)string, CANPROP_MAX_BUFFER_SIZE);
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ if (CCanApi::NoError == retVal) {
+ string[CANPROP_MAX_BUFFER_SIZE] = '\0';
+ RecordProperty("DeviceLibraryName", string);
+ }
+ // @- vendor name of the CAN interface
+ retVal = dut.GetProperty(CANPROP_GET_DEVICE_VENDOR, (void*)string, CANPROP_MAX_BUFFER_SIZE);
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ if (CCanApi::NoError == retVal) {
+ string[CANPROP_MAX_BUFFER_SIZE] = '\0';
+ RecordProperty("DeviceLibraryVendor", string);
+ }
+ // @- supported operation capabilities
+ retVal = dut.GetOpCapabilities(opCapa);
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ if (CCanApi::NoError == retVal) {
+#if (OPTION_CAN_2_0_ONLY == 0)
+ RecordProperty("DeviceCapability.FDOE", opCapa.fdoe ? "Yes" : "No");
+ RecordProperty("DeviceCapability.BRSE", opCapa.brse ? "Yes" : "No");
+ RecordProperty("DeviceCapability.NISO", opCapa.niso ? "Yes" : "No");
+#endif
+ RecordProperty("DeviceCapability.SHRD", opCapa.shrd ? "Yes" : "No");
+ RecordProperty("DeviceCapability.NXTD", opCapa.nxtd ? "Yes" : "No");
+ RecordProperty("DeviceCapability.NRTR", opCapa.nrtr ? "Yes" : "No");
+ RecordProperty("DeviceCapability.ERR", opCapa.err ? "Yes" : "No");
+ RecordProperty("DeviceCapability.MON", opCapa.mon ? "Yes" : "No");
+ }
+ // @- tear down DUT2
+ retVal = dut.TeardownChannel();
+ EXPECT_EQ(CCanApi::NoError, retVal);
+ // @end.
+}
+
+// $Id: TCxX_Summary.cc 1333 2024-06-01 22:18:12Z makemake $ Copyright (c) UV Software, Berlin.
diff --git a/Tests/CANAPI/Version.h b/Tests/CANAPI/Version.h
index d37c8c3..21370c1 100644
--- a/Tests/CANAPI/Version.h
+++ b/Tests/CANAPI/Version.h
@@ -47,8 +47,8 @@
//
#ifndef VERSION_H_INCLUDED
#define VERSION_H_INCLUDED
-// SVN revision number (update with each commit: XI)
-#define REVISION_NO "$Rev: 1273 $"
+// SVN revision number (update with each commit: XXIV)
+#define REVISION_NO "$Rev: 1336 $"
#endif // VERSION_H_INCLUDED
-// $Id: Version.h 1273 2024-04-18 16:59:22Z makemake $ Copyright (c) UV Software, Berlin //
+// $Id: Version.h 1336 2024-06-03 06:58:36Z makemake $ Copyright (c) UV Software, Berlin //
diff --git a/Tests/TestTools/scantest.py b/Tests/TestTools/scantest.py
index e41ff8d..4cfba58 100644
--- a/Tests/TestTools/scantest.py
+++ b/Tests/TestTools/scantest.py
@@ -68,9 +68,9 @@
// @workaround:
// @end
- $Author: makemake $
+ $Author: haumea $
- $Rev: 792 $
+ $Rev: 793 $
"""
# encoding: utf-8
from datetime import datetime
@@ -86,6 +86,7 @@
specpath = '.'
specext = '.txt'
xctest = False
+gtest = False
# output the test case subject
def write_test_subject(file, text, option):
@@ -172,12 +173,21 @@ def write_test_procedure(file, text, option, suite):
if line.startswith('// @xctest '):
write_test_subject(fp2, line.replace('// @xctest ', '', 1), testopts)
xctest = True
+ gtest = False
+ count += 1
+ total += 1
+ # - test case subject (gtest)
+ elif line.startswith('// @gtest '):
+ write_test_subject(fp2, line.replace('// @gtest ', '', 1), testopts)
+ xctest = False
+ gtest = True
count += 1
total += 1
# - test case subject (others)
elif line.startswith('// @testcase '):
- write_test_subject(fp2, line.replace('// @xctest ', '', 1), testopts)
+ write_test_subject(fp2, line.replace('// @testcase ', '', 1), testopts)
xctest = False
+ gtest = False
count += 1
total += 1
# - expected value
@@ -198,6 +208,8 @@ def write_test_procedure(file, text, option, suite):
elif line.startswith('- (void)test') and xctest is True:
write_test_procedure(fp2, line.replace('- (void)', '').replace(' {', ''), testopts, os.path.splitext(file)[0])
# google test/mock fixture
+ elif line.startswith('TEST_F') and gtest is True:
+ write_test_procedure(fp2, line.replace(' {', ''), testopts, "GoogleTest")
# TODO: insert coin here
if testopts['separator']:
fp2.write(scanner + '\n')
diff --git a/Tests/UnitTests/README.md b/Tests/UnitTests/README.md
index 3fcde2b..46fe889 100644
--- a/Tests/UnitTests/README.md
+++ b/Tests/UnitTests/README.md
@@ -1,7 +1,7 @@
-_Copyright © 2004-2022 Uwe Vogt, UV Software, Berlin (info@uv-software.com)_ \
+_Copyright © 2004-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com)_ \
_All rights reserved._
-Version $Rev: 1074 $
+Version $Rev: 1334 $
# A CAN Interface Wrapper Specification
diff --git a/Tests/UnitTests/test_can_bitrate.mm b/Tests/UnitTests/test_can_bitrate.mm
index 2d2cdcc..55833ea 100644
--- a/Tests/UnitTests/test_can_bitrate.mm
+++ b/Tests/UnitTests/test_can_bitrate.mm
@@ -362,7 +362,7 @@ - (void)testWhenInterfaceNotInitialized {
// @xctest TC11.6: Get CAN bit-rate settings when interface initialized (but CAN controller not started)
//
-// @expected CANERR_OFFLINE
+// @expected CANERR_NOERROR (even if the CAN controller has not been started)
//
- (void)testWhenInterfaceInitialized {
can_bitrate_t bitrate = { TEST_BTRINDEX };
@@ -382,7 +382,7 @@ - (void)testWhenInterfaceInitialized {
// @test:
// @- get bit-rate of DUT1
rc = can_bitrate(handle, &bitrate, NULL);
- XCTAssertEqual(CANERR_OFFLINE, rc);
+ XCTAssertEqual(CANERR_NOERROR, rc);
// @- get status of DUT1 and check to be in INIT state
rc = can_status(handle, &status.byte);
XCTAssertEqual(CANERR_NOERROR, rc);
@@ -473,7 +473,7 @@ - (void)testWhenInterfaceStarted {
// @xctest TC11.8: Get CAN bit-rate settings when CAN controller stopped
//
-// @expected CANERR_OFFLINE
+// @expected CANERR_NOERROR (even if the CAN controller has not been started)
//
- (void)testWhenInterfaceStopped {
can_bitrate_t bitrate = { TEST_BTRINDEX };
@@ -517,7 +517,7 @@ - (void)testWhenInterfaceStopped {
// @test:
// @- get bit-rate of DUT1
rc = can_bitrate(handle, &bitrate, NULL);
- XCTAssertEqual(CANERR_OFFLINE, rc);
+ XCTAssertEqual(CANERR_NOERROR, rc);
// @- get status of DUT1 and check to be in INIT state
rc = can_status(handle, &status.byte);
XCTAssertEqual(CANERR_NOERROR, rc);
@@ -808,4 +808,4 @@ - (void)testWithVariousCanFdBitrateSettings {
@end
-// $Id: test_can_bitrate.mm 1084 2022-07-25 13:39:18Z makemake $ Copyright (c) UV Software, Berlin //
+// $Id: test_can_bitrate.mm 1334 2024-06-02 10:00:20Z makemake $ Copyright (c) UV Software, Berlin //
diff --git a/Tests/UnitTests/test_can_busload.mm b/Tests/UnitTests/test_can_busload.mm
index d640d91..5d0fd34 100644
--- a/Tests/UnitTests/test_can_busload.mm
+++ b/Tests/UnitTests/test_can_busload.mm
@@ -2,7 +2,7 @@
//
// CAN Interface API, Version 3 (Testing)
//
-// Copyright (c) 2004-2022 Uwe Vogt, UV Software, Berlin (info@uv-software.com)
+// Copyright (c) 2004-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com)
// All rights reserved.
//
// This file is part of CAN API V3.
@@ -403,13 +403,9 @@ - (void)testWhenInterfaceInitialized {
// @test:
// @- get bus-load of DUT1 and check to be in INIT state
rc = can_busload(handle, &load, &status.byte);
-#ifndef OPTION_CANAPI_RETVALS
- XCTAssertEqual(CANERR_OFFLINE, rc);
-#else
- // note: can_busload shall return CANERR_NOERROR even when
- // the CAN controller has not been started
+ // @ note: can_busload shall return CANERR_NOERROR even when
+ // the CAN controller has not been started
XCTAssertEqual(CANERR_NOERROR, rc);
-#endif
XCTAssertTrue(status.can_stopped);
// @post:
@@ -544,13 +540,9 @@ - (void)testWhenInterfaceStopped {
// @test:
// @- get bus-load of DUT1 and check to be in INIT state
rc = can_busload(handle, &load, &status.byte);
-#ifndef OPTION_CANAPI_RETVALS
- XCTAssertEqual(CANERR_OFFLINE, rc);
-#else
- // note: can_busload shall return CANERR_NOERROR even when
- // the CAN controller has not been started
+ // @ note: can_busload shall return CANERR_NOERROR even when
+ // the CAN controller has not been started
XCTAssertEqual(CANERR_NOERROR, rc);
-#endif
XCTAssertTrue(status.can_stopped);
// @post:
@@ -684,4 +676,4 @@ - (void)testWhenInterfaceShutdown {
@end
-// $Id: test_can_busload.mm 1083 2022-07-25 12:40:16Z makemake $ Copyright (c) UV Software, Berlin //
+// $Id: test_can_busload.mm 1334 2024-06-02 10:00:20Z makemake $ Copyright (c) UV Software, Berlin //
diff --git a/Tests/UnitTests/test_can_reset.mm b/Tests/UnitTests/test_can_reset.mm
index 809b5bf..b0bfbfa 100644
--- a/Tests/UnitTests/test_can_reset.mm
+++ b/Tests/UnitTests/test_can_reset.mm
@@ -2,7 +2,7 @@
//
// CAN Interface API, Version 3 (Testing)
//
-// Copyright (c) 2004-2023 Uwe Vogt, UV Software, Berlin (info@uv-software.com)
+// Copyright (c) 2004-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com)
// All rights reserved.
//
// This file is part of CAN API V3.
@@ -221,13 +221,9 @@ - (void)testIfChannelInitialized {
// @test:
// @- try to stop/reset DUT1
rc = can_reset(handle);
-#ifndef OPTION_CANAPI_RETVALS
- XCTAssertEqual(CANERR_OFFLINE, rc);
-#else
- // note: can_reset shall return CANERR_NOERROR even when
- // the CAN controller has not been started
+ // @ note: can_reset shall return CANERR_NOERROR even when
+ // the CAN controller has not been started
XCTAssertEqual(CANERR_NOERROR, rc);
-#endif
// @- get status of DUT1 and check to be in INIT state
rc = can_status(handle, &status.byte);
XCTAssertEqual(CANERR_NOERROR, rc);
@@ -317,13 +313,9 @@ - (void)testIfControllerStopped {
// @test:
// @- try to stop/reset DUT1 again
rc = can_reset(handle);
-#ifndef OPTION_CANAPI_RETVALS
- XCTAssertEqual(CANERR_OFFLINE, rc);
-#else
- // note: can_reset shall return CANERR_NOERROR even when
- // the CAN controller has not been started
+ // @ note: can_reset shall return CANERR_NOERROR even when
+ // the CAN controller has not been started
XCTAssertEqual(CANERR_NOERROR, rc);
-#endif
// @- get status of DUT1 and check to be in INIT state
rc = can_status(handle, &status.byte);
XCTAssertEqual(CANERR_NOERROR, rc);
@@ -398,4 +390,4 @@ - (void)testIfChannelTornDown {
@end
-// $Id: test_can_reset.mm 1138 2023-08-10 18:25:16Z haumea $ Copyright (c) UV Software, Berlin //
+// $Id: test_can_reset.mm 1334 2024-06-02 10:00:20Z makemake $ Copyright (c) UV Software, Berlin //
diff --git a/Trial/Makefile b/Trial/Makefile
index 74b734f..e15a1e4 100644
--- a/Trial/Makefile
+++ b/Trial/Makefile
@@ -30,7 +30,7 @@ OBJECTS = $(OUTDIR)/main.o $(OUTDIR)/MacCAN_Debug.o $(OUTDIR)/MacCAN_Devices.o \
DEFINES = -DOPTION_CAN_2_0_ONLY=1 \
-DOPTION_CANAPI_DRIVER=1 \
- -DOPTION_CANAPI_RETVALS=1 \
+ -DOPTION_CANAPI_RETVALS=0 \
-DOPTION_CANAPI_COMPANIONS=1 \
-DOPTION_MACCAN_PIPE_INFO=0 \
-DOPTION_MACCAN_PIPE_TIMEOUT=1 \
diff --git a/Trial/TouCAN.xcodeproj/project.pbxproj b/Trial/TouCAN.xcodeproj/project.pbxproj
index 381691e..c82a275 100644
--- a/Trial/TouCAN.xcodeproj/project.pbxproj
+++ b/Trial/TouCAN.xcodeproj/project.pbxproj
@@ -431,7 +431,6 @@
"OPTION_CANAPI_DRIVER=1",
"OPTION_CANAPI_RETVALS=1",
"OPTION_CANAPI_COMPANIONS=1",
- "OPTION_CANBTR_PEAK_FREQUENCIES=0",
"OPTION_MACCAN_MULTICHANNEL=0",
"OPTION_MACCAN_PIPE_TIMEOUT=1",
);
@@ -496,17 +495,7 @@
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
- GCC_PREPROCESSOR_DEFINITIONS = (
- "OPTION_CAN_2_0_ONLY=0",
- "OPTION_CANAPI_DRIVER=1",
- "OPTION_CANAPI_RETVALS=0",
- "OPTION_CANAPI_COMPANIONS=1",
- "OPTION_MACCAN_LOGGER=0",
- "OPTION_MACCAN_MULTICHANNEL=0",
- "OPTION_MACCAN_PIPE_TIMEOUT=1",
- "OPTION_MACCAN_DEBUG_LEVEL=0",
- "OPTION_MACCAN_INSTRUMENTATION=0",
- );
+ GCC_PREPROCESSOR_DEFINITIONS = "";
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
diff --git a/Utilities/can_moni/Driver.h b/Utilities/can_moni/Driver.h
index 342e59b..1866700 100644
--- a/Utilities/can_moni/Driver.h
+++ b/Utilities/can_moni/Driver.h
@@ -33,8 +33,10 @@
#endif
#define BITRATE_800K_UNSUPPORTED 1 // set to zero if 800kbps is supported
-#define MONITOR_INTEFACE "Rusoku TouCAN USB Interfaces"
+#define MONITOR_INTERFACE "Rusoku TouCAN USB Interfaces"
#define MONITOR_COPYRIGHT "2007,2012-2024 by Uwe Vogt, UV Software, Berlin"
+#define MONITOR_PLATFORM "Darwin"
+#define MONITOR_ALIASNAME "TOU:"
#define BITRATE_1M(x) TOUCAN_BR_1M(x)
#define BITRATE_500K(x) TOUCAN_BR_500K(x)
diff --git a/Utilities/can_moni/Makefile b/Utilities/can_moni/Makefile
index 22a4628..c95a14b 100644
--- a/Utilities/can_moni/Makefile
+++ b/Utilities/can_moni/Makefile
@@ -1,7 +1,8 @@
#
# CAN Monitor for Rusoku TouCAN USB Interfaces (CAN API V3)
#
-# Copyright (c) 2007,2012-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com)
+# Copyright (c) 2007 by Uwe Vogt, UV Software, Friedrichshafen
+# Copyright (c) 2012-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -33,7 +34,8 @@ MAIN_DIR = ./Sources
DRIVER_DIR = $(PROJ_DIR)/Sources
CANAPI_DIR = $(PROJ_DIR)/Sources/CANAPI
-OBJECTS = $(OUTDIR)/main.o $(OUTDIR)/Timer.o $(OUTDIR)/Message.o $(OUTDIR)/can_msg.o
+OBJECTS = $(OUTDIR)/main.o $(OUTDIR)/Options.o $(OUTDIR)/Timer.o \
+ $(OUTDIR)/Message.o $(OUTDIR)/can_msg.o
DEFINES = -DOPTION_CANAPI_DRIVER=1 \
-DOPTION_CANAPI_COMPANIONS=1
@@ -114,6 +116,9 @@ install:
$(OUTDIR)/main.o: $(MAIN_DIR)/main.cpp
$(CXX) $(CXXFLAGS) -MMD -MF $*.d -o $@ -c $<
+$(OUTDIR)/Options.o: $(MAIN_DIR)/Options_p.cpp
+ $(CXX) $(CXXFLAGS) -MMD -MF $*.d -o $@ -c $<
+
$(OUTDIR)/Timer.o: $(MAIN_DIR)/Timer.cpp
$(CXX) $(CXXFLAGS) -MMD -MF $*.d -o $@ -c $<
@@ -127,5 +132,7 @@ $(OUTDIR)/can_msg.o: $(CANAPI_DIR)/can_msg.c
$(TARGET): $(OBJECTS)
$(LD) $(LDFLAGS) -o $@ $(OBJECTS) $(LIBRARIES)
$(CP) $(TARGET) $(BINDIR)
+ifeq ($(current_OS),Darwin)
@lipo -archs $@
+endif
@echo "\033[1mTarget '"$@"' successfully build\033[0m"
diff --git a/Utilities/can_moni/README.md b/Utilities/can_moni/README.md
index a92037c..d9431c5 100644
--- a/Utilities/can_moni/README.md
+++ b/Utilities/can_moni/README.md
@@ -1,4 +1,4 @@
-__CAN Monitor for Rusoku TouCAN USB Interfaces, Version 0.3__ \
+__CAN Monitor for Rusoku TouCAN USB Interfaces, Version 0.3.1__ \
Copyright © 2007,2012-2024 by Uwe Vogt, UV Software, Berlin
```
@@ -15,16 +15,17 @@ Options:
--xtd-mask= acceptance mask for 29-bit IDs (default=0x00000000)
-m, --mode=2.0 CAN operation mode: CAN 2.0
--shared shared CAN controller access (if supported)
- --listen-only monitor mode (listen-only, transmitter is off)
+ --listen-only monitor mode (listen-only mode)
--error-frames allow reception of error frames
--no-remote-frames suppress remote frames (RTR frames)
--no-extended-frames suppress extended frames (29-bit identifier)
-b, --baudrate= CAN bit-timing in kbps (default=250), or
- --bitrate= CAN bit-rate settings (as a string)
+ --bitrate= CAN bit-rate settings (as key/value list)
-v, --verbose show detailed bit-rate settings
--list-bitrates[=2.0] list standard bit-rate settings
-L, --list-boards list all supported CAN interfaces and exit
-T, --test-boards list all available CAN interfaces and exit
+ -J, --json= write configuration into JSON file and exit
-h, --help display this help screen and exit
--version show version information and exit
Arguments:
@@ -40,7 +41,7 @@ Arguments:
6 = 50 kbps
7 = 20 kbps
8 = 10 kbps
- comma-separated =-list:
+ comma-separated key/value list:
f_clock= frequency in Hz or
f_clock_mhz= frequency in MHz
nom_brp= bit-rate prescaler (nominal)
diff --git a/Utilities/can_moni/Sources/COPYING b/Utilities/can_moni/Sources/COPYING
new file mode 100644
index 0000000..f288702
--- /dev/null
+++ b/Utilities/can_moni/Sources/COPYING
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ Copyright (C)
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+.
diff --git a/Utilities/can_moni/Sources/Options.cpp b/Utilities/can_moni/Sources/Options.cpp
new file mode 100644
index 0000000..c75e1c7
--- /dev/null
+++ b/Utilities/can_moni/Sources/Options.cpp
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+//
+// CAN Monitor for generic Interfaces (CAN API V3)
+//
+// Copyright (c) 2007,2012-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+#if defined(_WIN32) || defined(_WIN64)
+// for Windows OS (x86 and x64)
+#include "Options_w.cpp"
+#else
+// for POSIX OS (Linux, Darwin)
+#include "Options_p.cpp"
+#endif
diff --git a/Utilities/can_moni/Sources/Options.h b/Utilities/can_moni/Sources/Options.h
new file mode 100644
index 0000000..fdcd8b5
--- /dev/null
+++ b/Utilities/can_moni/Sources/Options.h
@@ -0,0 +1,87 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+//
+// CAN Monitor for generic Interfaces (CAN API V3)
+//
+// Copyright (c) 2007,2012-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+#ifndef CAN_MONI_OPTIONS_H_INCLUDED
+#define CAN_MONI_OPTIONS_H_INCLUDED
+
+#include "Driver.h"
+#include "Version.h"
+
+#include
+#include
+
+#define CAN_MONI_APPLICATION "CAN Monitor for " MONITOR_INTERFACE ", Version " VERSION_STRING
+#define CAN_MONI_COPYRIGHT "Copyright (c) " MONITOR_COPYRIGHT
+#if !defined(_WIN32) && !defined(_WIN64)
+#define CAN_MONI_WARRANTY "This program comes with ABSOLUTELY NO WARRANTY!\n\n" \
+ "This is free software, and you are welcome to redistribute it\n" \
+ "under certain conditions; type `--version' for details.";
+#else
+#define CAN_MONI_WARRANTY "This program comes with ABSOLUTELY NO WARRANTY!\n\n" \
+ "This is free software, and you are welcome to redistribute it\n" \
+ "under certain conditions; type '/VERSION' for details.";
+#endif
+#define CAN_MONI_LICENSE "This program is free software: you can redistribute it and/or modify\n" \
+ "it under the terms of the GNU General Public License as published by\n" \
+ "the Free Software Foundation, either version 3 of the License, or\n" \
+ "(at your option) any later version.\n\n" \
+ "This program is distributed in the hope that it will be useful,\n" \
+ "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" \
+ "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" \
+ "GNU General Public License for more details.\n\n" \
+ "You should have received a copy of the GNU General Public License\n" \
+ "along with this program. If not, see ."
+#define CAN_MONI_PROGRAM "can_moni"
+
+struct SOptions {
+ // attributes
+ char* m_szBasename;
+ char* m_szInterface;
+#if (OPTION_CANAPI_LIBRARY != 0)
+ char* m_szSearchPath;
+#else
+ char* m_szJsonFilename;
+#endif
+ CANAPI_OpMode_t m_OpMode;
+ CANAPI_Bitrate_t m_Bitrate;
+ CANAPI_BusSpeed_t m_BusSpeed;
+ bool m_bHasDataPhase;
+ bool m_bHasNoSamp;
+ struct {
+ uint32_t m_u32Code;
+ uint32_t m_u32Mask;
+ } m_StdFilter, m_XtdFilter;
+ char* m_szExcludeList;
+ bool m_fListBitrates;
+ bool m_fListBoards;
+ bool m_fTestBoards;
+ bool m_fVerbose;
+ bool m_fExit;
+ // initializer
+ SOptions();
+ // operations
+ int ScanCommanline(int argc, const char* argv[], FILE* err = stderr, FILE* out = stdout);
+ void ShowGreetings(FILE* stream);
+ void ShowFarewell(FILE* stream);
+ void ShowVersion(FILE* stream);
+ void ShowHelp(FILE* stream);
+ void ShowUsage(FILE* stream, bool args = false);
+};
+
+#endif // CAN_MONI_OPTIONS_H_INCLUDED
diff --git a/Utilities/can_moni/Sources/Options_p.cpp b/Utilities/can_moni/Sources/Options_p.cpp
new file mode 100644
index 0000000..ed8b3cd
--- /dev/null
+++ b/Utilities/can_moni/Sources/Options_p.cpp
@@ -0,0 +1,814 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+//
+// CAN Monitor for generic Interfaces (CAN API V3)
+//
+// Copyright (c) 2007,2012-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+#include "Options.h"
+#include "Message.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#if defined(__linux__)
+#define PLATFORM "Linux"
+#elif defined(__APPLE__)
+#define PLATFORM "macOS"
+#elif defined(__CYGWIN__)
+#define PLATFORM "Cygwin"
+#else
+#error Platform not supported
+#endif
+#ifdef _MSC_VER
+//not #if defined(_WIN32) || defined(_WIN64) because we have strncasecmp in mingw
+#define strncasecmp _strnicmp
+#define strcasecmp _stricmp
+#endif
+#define USE_BASENAME 1
+
+#define DEFAULT_OP_MODE CANMODE_DEFAULT
+#define DEFAULT_BAUDRATE CANBTR_INDEX_250K
+
+static const char* c_szApplication = CAN_MONI_APPLICATION;
+static const char* c_szCopyright = CAN_MONI_COPYRIGHT;
+static const char* c_szWarranty = CAN_MONI_WARRANTY;
+static const char* c_szLicense = CAN_MONI_LICENSE;
+static const char* c_szBasename = CAN_MONI_PROGRAM;
+static const char* c_szInterface = "(unknown)";
+static const char* c_szExcludeList = "~0x00-0x7FF";
+
+SOptions::SOptions() {
+ // to have default bus speed from bit-timing index
+ (void)CCanDriver::MapIndex2Bitrate(DEFAULT_BAUDRATE, m_Bitrate);
+ (void)CCanDriver::MapBitrate2Speed(m_Bitrate, m_BusSpeed);
+ // initialization
+ m_szBasename = (char*)c_szBasename;
+ m_szInterface = (char*)c_szInterface;
+#if (OPTION_CANAPI_LIBRARY != 0)
+ m_szSearchPath = (char*)NULL;
+#else
+ m_szJsonFilename = (char*)NULL;
+#endif
+ m_OpMode.byte = DEFAULT_OP_MODE;
+ m_Bitrate.index = DEFAULT_BAUDRATE;
+ m_bHasDataPhase = false;
+ m_bHasNoSamp = false;
+ m_StdFilter.m_u32Code = CANACC_CODE_11BIT;
+ m_StdFilter.m_u32Mask = CANACC_MASK_11BIT;
+ m_XtdFilter.m_u32Code = CANACC_CODE_29BIT;
+ m_XtdFilter.m_u32Mask = CANACC_MASK_29BIT;
+ m_szExcludeList = (char*)c_szExcludeList;
+ m_fListBitrates = false;
+ m_fListBoards = false;
+ m_fTestBoards = false;
+ m_fVerbose = false;
+ m_fVerbose = false;
+ m_fExit = false;
+}
+
+int SOptions::ScanCommanline(int argc, const char* argv[], FILE* err, FILE* out) {
+ int opt;
+ int64_t intarg;
+
+ int optBitrate = 0;
+ int optVerbose = 0;
+ int optMode = 0;
+ int optShared = 0;
+ int optListenOnly = 0;
+ int optErrorFrames = 0;
+ int optExtendedFrames = 0;
+ int optRemoteFrames = 0;
+ int optStdCode = 0;
+ int optStdMask = 0;
+ int optXtdCode = 0;
+ int optXtdMask = 0;
+ int optFmtTime = 0;
+ int optFmtId = 0;
+ int optFmtData = 0;
+ int optFmtAscii = 0;
+#if (CAN_FD_SUPPORTED != 0)
+ int optFmtWrap = 0;
+#endif
+ int optExclude = 0;
+ int optListBitrates = 0;
+ int optListBoards = 0;
+ int optTestBoards = 0;
+#if (OPTION_CANAPI_LIBRARY != 0)
+ int optPath = 0;
+#else
+ int optJson = 0;
+#endif
+ // default format options
+ CCanMessage::EFormatTimestamp fmtModeTime = CCanMessage::OptionZero;
+ CCanMessage::EFormatNumber fmtModeId = CCanMessage::OptionHex;
+ CCanMessage::EFormatNumber fmtModeData = CCanMessage::OptionHex;
+ CCanMessage::EFormatOption fmtModeAscii = CCanMessage::OptionOn;
+ CCanMessage::EFormatWraparound fmtWraparound = CCanMessage::OptionWraparoundNo;
+ (void)CCanMessage::SetTimestampFormat(fmtModeTime);
+ (void)CCanMessage::SetIdentifierFormat(fmtModeId);
+ (void)CCanMessage::SetDataFormat(fmtModeData);
+ (void)CCanMessage::SetAsciiFormat(fmtModeAscii);
+ (void)CCanMessage::SetWraparound(fmtWraparound);
+
+ // command-line options
+ int show_version = 0;
+ struct option long_options[] = {
+ {"baudrate", required_argument, 0, 'b'},
+ {"bitrate", required_argument, 0, 'B'},
+ {"verbose", no_argument, 0, 'v'},
+ {"mode", required_argument, 0, 'm'},
+ {"shared", no_argument, 0, 'S'},
+ {"listen-only", no_argument, 0, 'M'},
+ {"error-frames", no_argument, 0, 'E'},
+ {"no-remote-frames", no_argument, 0, 'R'},
+ {"no-extended-frames", no_argument, 0, 'X'},
+ {"code", required_argument, 0, '1'},
+ {"mask", required_argument, 0, '2'},
+ {"xtd-code", required_argument, 0, '3'},
+ {"xtd-mask", required_argument, 0, '4'},
+ {"time", required_argument, 0, 't'},
+ {"id", required_argument, 0, 'i'},
+ {"data", required_argument, 0, 'd'},
+ {"ascii", required_argument, 0, 'a'},
+ {"wrap", required_argument, 0, 'w'},
+ {"wraparound", required_argument, 0, 'w'},
+ {"exclude", required_argument, 0, 'x'},
+ {"script", required_argument, 0, 's'},
+ {"list-bitrates", optional_argument, 0, 'l'},
+#if (OPTION_CANAPI_LIBRARY != 0)
+ {"list-boards", optional_argument, 0, 'L'},
+ {"test-boards", optional_argument, 0, 'T'},
+ {"path", required_argument, 0, 'p'},
+#else
+ {"list-boards", no_argument, 0, 'L'},
+ {"test-boards", no_argument, 0, 'T'},
+ {"json", required_argument, 0, 'j'},
+#endif
+ {"help", no_argument, 0, 'h'},
+ {"version", no_argument, &show_version, 1},
+ {0, 0, 0, 0}
+ };
+ // (0) sanity check
+ if ((argc <= 0) || (argv == NULL))
+ return (-1);
+ if ((err == NULL) || (out == NULL))
+ return (-1);
+ // (1) get basename from command-line
+#if (USE_BASENAME != 0)
+ m_szBasename = basename((char*)argv[0]);
+#endif
+ // (2) scan command-line for options
+#if (OPTION_CANAPI_LIBRARY != 0)
+ while ((opt = getopt_long(argc, (char * const *)argv, "b:vp:m:t:i:d:a:w:x:s:lLTh", long_options, NULL)) != -1) {
+#else
+ while ((opt = getopt_long(argc, (char * const *)argv, "b:vm:t:i:d:a:w:x:s:lLTj:h", long_options, NULL)) != -1) {
+#endif
+ switch (opt) {
+ /* option '--baudrate=' (-b) */
+ case 'b':
+ if (optBitrate++) {
+ fprintf(err, "%s: duplicated option `--baudrate' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ if (optarg == NULL) {
+ fprintf(err, "%s: missing argument for option `--baudrate' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ if (sscanf(optarg, "%" SCNi64, &intarg) != 1) {
+ fprintf(err, "%s: illegal argument for option `--baudrate' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ switch (intarg) {
+ case 0: case 1000: case 1000000: m_Bitrate.index = (int32_t)CANBTR_INDEX_1M; break;
+ case 1: case 800: case 800000: m_Bitrate.index = (int32_t)CANBTR_INDEX_800K; break;
+ case 2: case 500: case 500000: m_Bitrate.index = (int32_t)CANBTR_INDEX_500K; break;
+ case 3: case 250: case 250000: m_Bitrate.index = (int32_t)CANBTR_INDEX_250K; break;
+ case 4: case 125: case 125000: m_Bitrate.index = (int32_t)CANBTR_INDEX_125K; break;
+ case 5: case 100: case 100000: m_Bitrate.index = (int32_t)CANBTR_INDEX_100K; break;
+ case 6: case 50: case 50000: m_Bitrate.index = (int32_t)CANBTR_INDEX_50K; break;
+ case 7: case 20: case 20000: m_Bitrate.index = (int32_t)CANBTR_INDEX_20K; break;
+ case 8: case 10: case 10000: m_Bitrate.index = (int32_t)CANBTR_INDEX_10K; break;
+ default: m_Bitrate.index = (int32_t)-intarg; break;
+ }
+ CANAPI_Bitrate_t bitrate; // in order not to overwrite the index
+ if (CCanDriver::MapIndex2Bitrate(m_Bitrate.index, bitrate) != CCanApi::NoError) {
+ fprintf(err, "%s: illegal argument for option `--baudrate' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ if (CCanDriver::MapBitrate2Speed(bitrate, m_BusSpeed) != CCanApi::NoError) {
+ fprintf(err, "%s: illegal argument for option `--baudrate' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ break;
+ /* option '--bitrate=' as string */
+ case 'B':
+ if (optBitrate++) {
+ fprintf(err, "%s: duplicated option `--bitrate'\n", m_szBasename);
+ return 1;
+ }
+ if (optarg == NULL) {
+ fprintf(err, "%s: missing argument for option `--bitrate'\n", m_szBasename);
+ return 1;
+ }
+ if (CCanDriver::MapString2Bitrate(optarg, m_Bitrate, m_bHasDataPhase, m_bHasNoSamp) != CCanApi::NoError) {
+ fprintf(err, "%s: illegal argument for option `--bitrate'\n", m_szBasename);
+ return 1;
+ }
+ if (CCanDriver::MapBitrate2Speed(m_Bitrate, m_BusSpeed) != CCanApi::NoError) {
+ fprintf(err, "%s: illegal argument for option `--bitrate'\n", m_szBasename);
+ return 1;
+ }
+ break;
+ /* option '--verbose' (-v) */
+ case 'v':
+ if (optVerbose) {
+ fprintf(err, "%s: duplicated option `--verbose' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ if (optarg != NULL) {
+ fprintf(err, "%s: illegal argument for option `--verbose' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ m_fVerbose = true;
+ break;
+#if (OPTION_CANAPI_LIBRARY != 0)
+ /* option '--path=' (-p) */
+ case 'p':
+ if (optPath++) {
+ fprintf(err, "%s: duplicated option `--path' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ if (optarg == NULL) {
+ fprintf(err, "%s: missing argument for option `--path' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ m_szSearchPath = optarg;
+ break;
+#endif
+ /* option '--mode=(2.0|FDF[+BRS])' (-m) */
+ case 'm':
+ if (optMode++) {
+ fprintf(err, "%s: duplicated option `--mode' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ if (optarg == NULL) {
+ fprintf(err, "%s: missing argument for option `--mode' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ if (!strcasecmp(optarg, "DEFAULT") || !strcasecmp(optarg, "CLASSIC") || !strcasecmp(optarg, "CLASSICAL") ||
+ !strcasecmp(optarg, "CAN20") || !strcasecmp(optarg, "CAN2.0") || !strcasecmp(optarg, "2.0"))
+ m_OpMode.byte |= CANMODE_DEFAULT;
+#if (CAN_FD_SUPPORTED != 0)
+ else if (!strcasecmp(optarg, "CANFD") || !strcasecmp(optarg, "FD") || !strcasecmp(optarg, "FDF"))
+ m_OpMode.byte |= CANMODE_FDOE;
+ else if (!strcasecmp(optarg, "CANFD+BRS") || !strcasecmp(optarg, "FDF+BRS") || !strcasecmp(optarg, "FD+BRS"))
+ m_OpMode.byte |= CANMODE_FDOE | CANMODE_BRSE;
+#endif
+ else {
+ fprintf(err, "%s: illegal argument for option `--mode' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ break;
+ /* option '--shared' */
+ case 'S':
+ if (optShared++) {
+ fprintf(err, "%s: duplicated option `--shared'\n", m_szBasename);
+ return 1;
+ }
+ if (optarg != NULL) {
+ fprintf(err, "%s: illegal argument for option `--shared'\n", m_szBasename);
+ return 1;
+ }
+ m_OpMode.byte |= CANMODE_SHRD;
+ break;
+ /* option '--listen-only' */
+ case 'M':
+ if (optListenOnly++) {
+ fprintf(err, "%s: duplicated option `--listen-only'\n", m_szBasename);
+ return 1;
+ }
+ if (optarg != NULL) {
+ fprintf(err, "%s: illegal argument for option `--listen-only'\n", m_szBasename);
+ return 1;
+ }
+ m_OpMode.byte |= CANMODE_MON;
+ break;
+ /* option '--error-frames' */
+ case 'E':
+ if (optErrorFrames++) {
+ fprintf(err, "%s: duplicated option `--error-frames'\n", m_szBasename);
+ return 1;
+ }
+ if (optarg != NULL) {
+ fprintf(err, "%s: illegal argument for option `--error-frames'\n", m_szBasename);
+ return 1;
+ }
+ m_OpMode.byte |= CANMODE_ERR;
+
+ break;
+ /* option '--no-extended-frames' */
+ case 'X':
+ if (optExtendedFrames++) {
+ fprintf(err, "%s: duplicated option `--no-extended-frames'\n", m_szBasename);
+ return 1;
+ }
+ if (optarg != NULL) {
+ fprintf(err, "%s: illegal argument for option `--no-extended-frames'\n", m_szBasename);
+ return 1;
+ }
+ m_OpMode.byte |= CANMODE_NXTD;
+ break;
+ /* option '--no-remote-frames' */
+ case 'R':
+ if (optRemoteFrames++) {
+ fprintf(err, "%s: duplicated option `--no-remote-frames'\n", m_szBasename);
+ return 1;
+ }
+ if (optarg != NULL) {
+ fprintf(err, "%s: missing argument for option `--no-remote-frames'\n", m_szBasename);
+ return 1;
+ }
+ m_OpMode.byte |= CANMODE_NRTR;
+ break;
+ /* option '--code=<11-bit-code>' */
+ case '1':
+ if (optStdCode++) {
+ fprintf(err, "%s: duplicated option `--code'\n", m_szBasename);
+ return 1;
+ }
+ if (optarg == NULL) {
+ fprintf(err, "%s: missing argument for option `--code'\n", m_szBasename);
+ return 1;
+ }
+ if (sscanf(optarg, "%" SCNx64, &intarg) != 1) {
+ fprintf(err, "%s: illegal argument for option `--code'\n", m_szBasename);
+ return 1;
+ }
+ if ((intarg & ~CAN_MAX_STD_ID) != 0) {
+ fprintf(err, "%s: illegal argument for option --code'\n", m_szBasename);
+ return 1;
+ }
+ m_StdFilter.m_u32Code = (uint32_t)intarg;
+ break;
+ /* option '--mask=<11-bit-mask>' */
+ case '2':
+ if (optStdMask++) {
+ fprintf(err, "%s: duplicated option `--mask'\n", m_szBasename);
+ return 1;
+ }
+ if (optarg == NULL) {
+ fprintf(err, "%s: missing argument for option `--mask'\n", m_szBasename);
+ return 1;
+ }
+ if (sscanf(optarg, "%" SCNx64, &intarg) != 1) {
+ fprintf(err, "%s: illegal argument for option --mask'\n", m_szBasename);
+ return 1;
+ }
+ if ((intarg & ~CAN_MAX_STD_ID) != 0) {
+ fprintf(err, "%s: illegal argument for option --mask'\n", m_szBasename);
+ return 1;
+ }
+ m_StdFilter.m_u32Mask = (uint32_t)intarg;
+ break;
+ /* option '--xtd-code=<29-bit-code>' */
+ case '3':
+ if (optXtdCode++) {
+ fprintf(err, "%s: duplicated option `--xtd-code'\n", m_szBasename);
+ return 1;
+ }
+ if (optarg == NULL) {
+ fprintf(err, "%s: missing argument for option `--xtd-code'\n", m_szBasename);
+ return 1;
+ }
+ if (sscanf(optarg, "%" SCNx64, &intarg) != 1) {
+ fprintf(err, "%s: illegal argument for option --xtd-code'\n", m_szBasename);
+ return 1;
+ }
+ if ((intarg & ~CAN_MAX_XTD_ID) != 0) {
+ fprintf(err, "%s: illegal argument for option --xtd-code'\n", m_szBasename);
+ return 1;
+ }
+ m_XtdFilter.m_u32Code = (uint32_t)intarg;
+ break;
+ /* option '--xtd-mask=<29-bit-mask>' */
+ case '4':
+ if (optXtdMask++) {
+ fprintf(err, "%s: duplicated option `--xtd-mask'\n", m_szBasename);
+ return 1;
+ }
+ if (optarg == NULL) {
+ fprintf(err, "%s: missing argument for option `--xtd-mask'\n", m_szBasename);
+ return 1;
+ }
+ if (sscanf(optarg, "%" SCNx64, &intarg) != 1) {
+ fprintf(err, "%s: illegal argument for option --xtd-mask'\n", m_szBasename);
+ return 1;
+ }
+ if ((intarg & ~CAN_MAX_XTD_ID) != 0) {
+ fprintf(err, "%s: illegal argument for option --xtd-mask'\n", m_szBasename);
+ return 1;
+ }
+ m_XtdFilter.m_u32Mask = (uint32_t)intarg;
+ break;
+ /* option '--time=(ABS|REL|ZERO)' (-t) */
+ case 't':
+ if (optFmtTime++) {
+ fprintf(err, "%s: duplicated option `--time' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ if (optarg == NULL) {
+ fprintf(err, "%s: missing argument for option `--time' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ if (!strcasecmp(optarg, "ABSOLUTE") || !strcasecmp(optarg, "ABS") || !strcasecmp(optarg, "a"))
+ fmtModeTime = CCanMessage::OptionAbsolute;
+ else if (!strcasecmp(optarg, "RELATIVE") || !strcasecmp(optarg, "REL") || !strcasecmp(optarg, "r"))
+ fmtModeTime = CCanMessage::OptionRelative;
+ else if (!strcasecmp(optarg, "ZERO") || !strcasecmp(optarg, "0") || !strcasecmp(optarg, "z"))
+ fmtModeTime = CCanMessage::OptionZero;
+ else {
+ fprintf(err, "%s: illegal argument for option `--time' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ if (!CCanMessage::SetTimestampFormat(fmtModeTime)) {
+ fprintf(err, "%s: illegal argument for option `--time' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ break;
+ /* option '--id=(HEX|DEC|OCT)' (-i) */
+ case 'i':
+ if (optFmtId++) {
+ fprintf(err, "%s: duplicated option `--id' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ if (optarg == NULL) {
+ fprintf(err, "%s: missing argument for option `--id' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ if (!strcasecmp(optarg, "HEXADECIMAL") || !strcasecmp(optarg, "HEX") || !strcasecmp(optarg, "h") || !strcasecmp(optarg, "16"))
+ fmtModeId = CCanMessage::OptionHex;
+ else if (!strcasecmp(optarg, "DECIMAL") || !strcasecmp(optarg, "DEC") || !strcasecmp(optarg, "d") || !strcasecmp(optarg, "10"))
+ fmtModeId = CCanMessage::OptionDec;
+ else if (!strcasecmp(optarg, "OCTAL") || !strcasecmp(optarg, "OCT") || !strcasecmp(optarg, "o") || !strcasecmp(optarg, "8"))
+ fmtModeId = CCanMessage::OptionOct;
+ else {
+ fprintf(err, "%s: illegal argument for option `--id' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ if (!CCanMessage::SetIdentifierFormat(fmtModeId)) {
+ fprintf(err, "%s: illegal argument for option `--id' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ break;
+ /* option '--data=(HEX|DEC|OCT)' (-d) */
+ case 'd':
+ if (optFmtData++) {
+ fprintf(err, "%s: duplicated option `--data' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ if (optarg == NULL) {
+ fprintf(err, "%s: missing argument for option `--data' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ if (!strcasecmp(optarg, "HEXADECIMAL") || !strcasecmp(optarg, "HEX") || !strcasecmp(optarg, "h") || !strcasecmp(optarg, "16"))
+ fmtModeData = CCanMessage::OptionHex;
+ else if (!strcasecmp(optarg, "DECIMAL") || !strcasecmp(optarg, "DEC") || !strcasecmp(optarg, "d") || !strcasecmp(optarg, "10"))
+ fmtModeData = CCanMessage::OptionDec;
+ else if (!strcasecmp(optarg, "OCTAL") || !strcasecmp(optarg, "OCT") || !strcasecmp(optarg, "o") || !strcasecmp(optarg, "8"))
+ fmtModeData = CCanMessage::OptionOct;
+ else {
+ fprintf(err, "%s: illegal argument for option `--data' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ if (!CCanMessage::SetDataFormat(fmtModeData)) {
+ fprintf(err, "%s: illegal argument for option `--data' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ break;
+ /* option '--ascii=(ON|OFF)' (-a) */
+ case 'a':
+ if (optFmtAscii++) {
+ fprintf(err, "%s: duplicated option `--ascii' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ if (optarg == NULL) {
+ fprintf(err, "%s: missing argument for option `--ascii' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ if (!strcasecmp(optarg, "OFF") || !strcasecmp(optarg, "NO") || !strcasecmp(optarg, "n") || !strcasecmp(optarg, "0"))
+ fmtModeAscii = CCanMessage::OptionOff;
+ else if (!strcasecmp(optarg, "ON") || !strcasecmp(optarg, "YES") || !strcasecmp(optarg, "y") || !strcasecmp(optarg, "1"))
+ fmtModeAscii = CCanMessage::OptionOn;
+ else {
+ fprintf(err, "%s: illegal argument for option `--ascii' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ if (!CCanMessage::SetAsciiFormat(fmtModeAscii)) {
+ fprintf(err, "%s: illegal argument for option `--ascii' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ break;
+#if (CAN_FD_SUPPORTED != 0)
+ /* option '--wrap=(No|8|10|16|32|64)' (-w) */
+ case 'w':
+ if (optFmtWrap++) {
+ fprintf(err, "%s: duplicated option `--wrap' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ if (optarg == NULL) {
+ fprintf(err, "%s: missing argument for option `--wrap' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ if (!strcasecmp(optarg, "NO") || !strcasecmp(optarg, "n") || !strcasecmp(optarg, "0"))
+ fmtWraparound = CCanMessage::OptionWraparoundNo;
+ else if (!strcasecmp(optarg, "8"))
+ fmtWraparound = CCanMessage::OptionWraparound8;
+ else if (!strcasecmp(optarg, "10"))
+ fmtWraparound = CCanMessage::OptionWraparound10;
+ else if (!strcasecmp(optarg, "16"))
+ fmtWraparound = CCanMessage::OptionWraparound16;
+ else if (!strcasecmp(optarg, "32"))
+ fmtWraparound = CCanMessage::OptionWraparound32;
+ else if (!strcasecmp(optarg, "64"))
+ fmtWraparound = CCanMessage::OptionWraparound64;
+ else {
+ fprintf(err, "%s: illegal argument for option `--wrap' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ if (!CCanMessage::SetWraparound(fmtWraparound)) {
+ fprintf(err, "%s: illegal argument for option `--wrap' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ break;
+#endif
+ /* option '--exclude=[~]' (-x) */
+ case 'x':
+ if (optExclude++) {
+ fprintf(err, "%s: duplicated option `--exclude' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ if (optarg == NULL) {
+ fprintf(err, "%s: missing argument for option `--exclude' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ m_szExcludeList = optarg;
+ break;
+ /* option '--list-bitrates[=(2.0|FDF[+BRS])]' */
+ case 'l':
+ if (optListBitrates++) {
+ fprintf(err, "%s: duplicated option `--list-bitrates'\n", m_szBasename);
+ return 1;
+ }
+ if (optarg != NULL) {
+ if (optMode++) {
+ fprintf(err, "%s: option `--list-bitrates' - operation mode already set'\n", m_szBasename);
+ return 1;
+ }
+ if (!strcasecmp(optarg, "DEFAULT") || !strcasecmp(optarg, "CLASSIC") || !strcasecmp(optarg, "CLASSICAL") ||
+ !strcasecmp(optarg, "CAN20") || !strcasecmp(optarg, "CAN2.0") || !strcasecmp(optarg, "2.0"))
+ m_OpMode.byte |= CANMODE_DEFAULT;
+#if (CAN_FD_SUPPORTED != 0)
+ else if (!strcasecmp(optarg, "CANFD") || !strcasecmp(optarg, "FD") || !strcasecmp(optarg, "FDF"))
+ m_OpMode.byte |= CANMODE_FDOE;
+ else if (!strcasecmp(optarg, "CANFD+BRS") || !strcasecmp(optarg, "FDF+BRS") || !strcasecmp(optarg, "FD+BRS"))
+ m_OpMode.byte |= CANMODE_FDOE | CANMODE_BRSE;
+#endif
+ else {
+ fprintf(err, "%s: illegal argument for option `--list-bitrates'\n", m_szBasename);
+ return 1;
+ }
+ }
+ m_fListBitrates = true;
+ m_fExit = true;
+ break;
+ /* option '--list-boards' (-L) */
+ case 'L':
+ if (optListBoards++) {
+ fprintf(err, "%s: duplicated option `--list-boards' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+#if (OPTION_CANAPI_LIBRARY != 0)
+ if (optarg != NULL) {
+ if (optPath++) {
+ fprintf(err, "%s: option `--list-boards' - search path already set' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ m_szSearchPath = optarg; // option '--list-boards=' (-L)
+ }
+#else
+ if (optarg != NULL) {
+ fprintf(err, "%s: illegal argument for option `--list-boards' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+#endif
+ m_fListBoards = true;
+ m_fExit = true;
+ break;
+ /* option '--test-boards' (-T) */
+ case 'T':
+ if (optTestBoards++) {
+ fprintf(err, "%s: duplicated option `--test-boards' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+#if (OPTION_CANAPI_LIBRARY != 0)
+ if (optarg != NULL) {
+ if (optPath++) {
+ fprintf(err, "%s: option `--test-boards' - search path already set' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ m_szSearchPath = optarg; // option '--test-boards=' (-L)
+ }
+#else
+ if (optarg != NULL) {
+ fprintf(err, "%s: illegal argument for option `--test-boards' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+#endif
+ m_fTestBoards = true;
+ m_fExit = true;
+ break;
+#if (OPTION_CANAPI_LIBRARY == 0)
+ /* option '--json=' (-j) */
+ case 'j':
+ if (optJson++) {
+ fprintf(err, "%s: duplicated option `--json' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ if (optarg == NULL) {
+ fprintf(err, "%s: missing argument for option `--json' (%c)\n", m_szBasename, opt);
+ return 1;
+ }
+ m_szJsonFilename = optarg;
+ m_fExit = true;
+ break;
+#endif
+ /* option '--help' (-h) */
+ case 'h':
+ ShowHelp(out);
+ m_fExit = true;
+ return 1;
+ case '?':
+ if (!opterr)
+ ShowUsage(out);
+ m_fExit = true;
+ return 1;
+ default:
+ if (show_version)
+ ShowVersion(out);
+ else
+ ShowUsage(out);
+ m_fExit = true;
+ return 1;
+ }
+ }
+ // (3) scan command-line for argument
+ // - check if one and only one is given
+ if (optind + 1 != argc) {
+ if (optind != argc) {
+ fprintf(err, "%s: too many arguments given\n", m_szBasename);
+ return 1;
+ } else if (!m_fExit) {
+ fprintf(err, "%s: no interface given\n", m_szBasename);
+ return 1;
+ } else {
+ // no interface given, but --list-boards, --test-boards or --list-bitrates
+ return 0;
+ }
+ } else {
+ m_szInterface = (char*)argv[optind];
+ }
+ // (4) check for illegal combinations
+#if (CAN_FD_SUPPORTED != 0)
+ /* - check bit-timing index (n/a for CAN FD) */
+ if (m_OpMode.fdoe && (m_Bitrate.btr.frequency <= CANBTR_INDEX_1M) && !m_fExit) {
+ fprintf(err, "%s: illegal combination of options `--mode' (m) and `--bitrate'\n", m_szBasename);
+ return 1;
+ }
+#endif
+ return 0;
+}
+
+void SOptions::ShowGreetings(FILE* stream) {
+ if (!stream)
+ return;
+ fprintf(stream, "%s\n%s\n\n%s\n\n", c_szApplication, c_szCopyright, c_szWarranty);
+}
+
+void SOptions::ShowFarewell(FILE* stream) {
+ if (!stream)
+ return;
+ fprintf(stream, "%s\n", c_szCopyright);
+}
+
+void SOptions::ShowVersion(FILE* stream) {
+ if (!stream)
+ return;
+ fprintf(stream, "%s\n%s\n\n%s\n\n", c_szApplication, c_szCopyright, c_szLicense);
+ fprintf(stream, "Written by Uwe Vogt, UV Software, Berlin \n");
+}
+
+void SOptions::ShowUsage(FILE* stream, bool args) {
+ if(!stream)
+ return;
+ fprintf(stream, "Usage: %s [