From 4fde063892f53d18b3c317ad66c5187fe0557b1c Mon Sep 17 00:00:00 2001 From: Uwe Vogt Date: Mon, 8 Apr 2024 09:04:32 +0200 Subject: [PATCH 01/11] Plastic surgery Relates to [CANAPI-80] --- Trial/Sources/main.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Trial/Sources/main.cpp b/Trial/Sources/main.cpp index 395d6af..4ab7916 100644 --- a/Trial/Sources/main.cpp +++ b/Trial/Sources/main.cpp @@ -271,7 +271,7 @@ int main(int argc, const char * argv[]) { fprintf(stderr, "+++ error: myDriver.GetProperty(CANPROP_GET_PATCH_NO) returned %i\n", retVal); retVal = myDriver.GetProperty(CANPROP_GET_BUILD_NO, (void *)&u32Val, sizeof(uint32_t)); if (retVal == CCanApi::NoError) - fprintf(stdout, ">>> myDriver.GetProperty(CANPROP_GET_BUILD_NO): value = 0x%07" PRIx32 "\n", u32Val); + fprintf(stdout, ">>> myDriver.GetProperty(CANPROP_GET_BUILD_NO): value = %07" PRIx32 "\n", u32Val); else fprintf(stderr, "+++ error: myDriver.GetProperty(CANPROP_GET_BUILD_NO) returned %i\n", retVal); retVal = myDriver.GetProperty(CANPROP_GET_LIBRARY_ID, (void *)&i32Val, sizeof(int32_t)); @@ -344,7 +344,8 @@ int main(int argc, const char * argv[]) { bool result = CCanDriver::GetFirstChannel(info); while (result) { retVal = CCanDriver::ProbeChannel(info.m_nChannelNo, opMode, state); - fprintf(stdout, ">>> CCanAPI::ProbeChannel(%i): state = %s", info.m_nChannelNo, + fprintf(stdout, ">>> CCanAPI::ProbeChannel(%i): %s = %s", + info.m_nChannelNo, info.m_szDeviceName, (state == CCanApi::ChannelOccupied) ? "occupied" : (state == CCanApi::ChannelAvailable) ? "available" : (state == CCanApi::ChannelNotAvailable) ? "not available" : "not testable"); From 307c7c5902636729924b9e100bedac2e7ec57cfc Mon Sep 17 00:00:00 2001 From: Uwe Vogt Date: Mon, 8 Apr 2024 09:28:55 +0200 Subject: [PATCH 02/11] Update CAN API V3 sources to rev. 1268 Relates to [CANAPI-80] --- Sources/CANAPI/CANAPI.h | 15 +++++---------- Sources/CANAPI/README.md | 4 ++-- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/Sources/CANAPI/CANAPI.h b/Sources/CANAPI/CANAPI.h index c9b984c..4cfce01 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: haumea $ +/// \author $Author: quaoar $ // -/// \version $Rev: 1260 $ +/// \version $Rev: 1268 $ // /// \defgroup can_api CAN Interface API, Version 3 /// \{ @@ -227,21 +227,16 @@ class CANCPP CCanApi { static bool GetFirstChannel(SChannelInfo &info, void *param = NULL); #endif - /// \brief query channel information of the first CAN interface in the + /// \brief query channel information of the next 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 /// \param[out] info - the channel information of the next entry in the list /// \param[out] param - pointer to channel-specific parameters // /// \returns true if channel information have been successfully read, or /// false on error. // -#if (OPTION_CANAPI_LIBRARY != 0) - static bool GetNextChannel(int32_t library, SChannelInfo &info, void *param = NULL); -#else - static bool GetNextChannel(SChannelInfo &info, void *param = NULL); -#endif + static bool GetNextChannel(SChannelInfo &info, void *param = NULL); /// \brief probes if the CAN interface (hardware and driver) given by /// the argument [ 'library' and ] 'channel' is present, @@ -520,4 +515,4 @@ class CANCPP CCanApi { /// \} #endif // CANAPI_H_INCLUDED /// \} -// $Id: CANAPI.h 1260 2024-03-24 15:16:47Z haumea $ Copyright (c) UV Software // +// $Id: CANAPI.h 1268 2024-04-08 07:19:23Z quaoar $ Copyright (c) UV Software // diff --git a/Sources/CANAPI/README.md b/Sources/CANAPI/README.md index 5512ad9..efb0e4b 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: 1260 $ +Version $Rev: 1268 $ # A CAN Interface Wrapper Specification From 01f567e0caa9f16f5fdd74ffe21ce02bf0df8d8e Mon Sep 17 00:00:00 2001 From: Uwe Vogt Date: Wed, 10 Apr 2024 17:00:35 +0200 Subject: [PATCH 03/11] Fix compiler warnings with legacy CAN 2.0 frame format Relates to [CANAPI-80] --- Sources/CANAPI/can_btr.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Sources/CANAPI/can_btr.c b/Sources/CANAPI/can_btr.c index 79b1736..c31be4c 100644 --- a/Sources/CANAPI/can_btr.c +++ b/Sources/CANAPI/can_btr.c @@ -55,9 +55,9 @@ * | SJW | BRP |SAM| TSEG2 | TSEG1 |
* +-7-+-6-+-5-+---+---+---+---+-0-+-7-+-6-+---+-4-+-3-+---+---+-0-+
* - * @author $Author: haumea $ + * @author $Author: eris $ * - * @version $Rev: 1259 $ + * @version $Rev: 1269 $ * * @addtogroup can_btr * @{ @@ -166,6 +166,8 @@ int btr_check_bitrate(const btr_bitrate_t *bitrate, bool fdoe, bool brse) { if ((bitrate->btr.nominal.sjw < BTR_NOMINAL_SJW_MIN) || (BTR_NOMINAL_SJW_MAX < bitrate->btr.nominal.sjw)) return BTRERR_BAUDRATE; #if (OPTION_CAN_2_0_ONLY != OPTION_DISABLED) + (void)fdoe; (void)brse; // To avoid compiler warnings + if ((bitrate->btr.nominal.sam != BTR_NOMINAL_SAM_SINGLE) && (BTR_NOMINAL_SAM_TRIPLE != bitrate->btr.nominal.sam)) return BTRERR_BAUDRATE; #else @@ -278,6 +280,8 @@ int btr_compare_bitrates(const btr_bitrate_t *bitrate1, const btr_bitrate_t *bit if (cmp_sp && (data_sp1 != data_sp2)) return (data_sp1 < data_sp2) ? -4 : +4; } +#else + (void)fdoe; (void)brse; // To avoid compiler warnings #endif /* if the bit-rates are equal return 1*/ return 0; From 0870b6ffc7c63895a3dc2abb663cb1af9092ac1f Mon Sep 17 00:00:00 2001 From: Uwe Vogt Date: Wed, 10 Apr 2024 17:57:50 +0200 Subject: [PATCH 04/11] Fix a bug with 29-bit identifier filter Relates to [CANAPI-80] --- Trial/Sources/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Trial/Sources/main.cpp b/Trial/Sources/main.cpp index 4ab7916..aadfcb4 100644 --- a/Trial/Sources/main.cpp +++ b/Trial/Sources/main.cpp @@ -118,8 +118,8 @@ int main(int argc, const char * argv[]) { int32_t channel = (int32_t)CHANNEL; uint32_t accCode11 = CANACC_CODE_11BIT; uint32_t accMask11 = CANACC_MASK_11BIT; - uint16_t accCode29 = CANACC_CODE_29BIT; - uint16_t accMask29 = CANACC_MASK_29BIT; + uint32_t accCode29 = CANACC_CODE_29BIT; + uint32_t accMask29 = CANACC_MASK_29BIT; uint16_t rxTimeout = CANWAIT_INFINITE; uint16_t txTimeout = 0U; useconds_t txDelay = 0U; From 525201dd1908d2eceabb2f6bc5f6dba0712c9f3d Mon Sep 17 00:00:00 2001 From: Uwe Vogt Date: Wed, 24 Apr 2024 10:35:09 +0200 Subject: [PATCH 05/11] Update CAN API V3 sources to rev. 1270 Relates to [CANAPI-80] --- Sources/CANAPI/CANAPI.h | 10 +++++----- Sources/CANAPI/CANAPI_Defines.h | 8 ++++---- Sources/CANAPI/CANAPI_Types.h | 8 ++++---- Sources/CANAPI/CANBTR_Defaults.h | 8 ++++---- Sources/CANAPI/README.md | 4 ++-- Sources/CANAPI/can_api.h | 8 ++++---- Sources/CANAPI/can_btr.c | 6 +++--- Sources/CANAPI/can_btr.h | 8 ++++---- Sources/CANAPI/can_msg.c | 8 ++++---- Sources/CANAPI/can_msg.h | 8 ++++---- 10 files changed, 38 insertions(+), 38 deletions(-) diff --git a/Sources/CANAPI/CANAPI.h b/Sources/CANAPI/CANAPI.h index 4cfce01..2b16188 100644 --- a/Sources/CANAPI/CANAPI.h +++ b/Sources/CANAPI/CANAPI.h @@ -7,8 +7,8 @@ // // 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). +// 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: @@ -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: quaoar $ +/// \author $Author: eris $ // -/// \version $Rev: 1268 $ +/// \version $Rev: 1270 $ // /// \defgroup can_api CAN Interface API, Version 3 /// \{ @@ -515,4 +515,4 @@ class CANCPP CCanApi { /// \} #endif // CANAPI_H_INCLUDED /// \} -// $Id: CANAPI.h 1268 2024-04-08 07:19:23Z quaoar $ Copyright (c) UV Software // +// $Id: CANAPI.h 1270 2024-04-15 18:42:43Z eris $ Copyright (c) UV Software // diff --git a/Sources/CANAPI/CANAPI_Defines.h b/Sources/CANAPI/CANAPI_Defines.h index 0e24424..a0d0549 100644 --- a/Sources/CANAPI/CANAPI_Defines.h +++ b/Sources/CANAPI/CANAPI_Defines.h @@ -7,8 +7,8 @@ * * 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). + * 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: @@ -49,9 +49,9 @@ * * @brief CAN API V3 for generic CAN Interfaces - Definitions and Options * - * @author $Author: haumea $ + * @author $Author: eris $ * - * @version $Rev: 1259 $ + * @version $Rev: 1270 $ * * @addtogroup can_api * @{ diff --git a/Sources/CANAPI/CANAPI_Types.h b/Sources/CANAPI/CANAPI_Types.h index 880bb6e..0ae52f2 100644 --- a/Sources/CANAPI/CANAPI_Types.h +++ b/Sources/CANAPI/CANAPI_Types.h @@ -7,8 +7,8 @@ * * 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). + * 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: @@ -49,9 +49,9 @@ * * @brief CAN API V3 for generic CAN Interfaces - Data Types and Defines * - * @author $Author: haumea $ + * @author $Author: eris $ * - * @version $Rev: 1259 $ + * @version $Rev: 1270 $ * * @addtogroup can_api * @{ diff --git a/Sources/CANAPI/CANBTR_Defaults.h b/Sources/CANAPI/CANBTR_Defaults.h index 7cf5bd2..b9a6cd3 100644 --- a/Sources/CANAPI/CANBTR_Defaults.h +++ b/Sources/CANAPI/CANBTR_Defaults.h @@ -7,8 +7,8 @@ * * 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). + * 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: @@ -49,9 +49,9 @@ * * @brief CAN API V3 for generic CAN Interfaces - Definitions and Options * - * @author $Author: haumea $ + * @author $Author: eris $ * - * @version $Rev: 1259 $ + * @version $Rev: 1270 $ * * @addtogroup can_btr * @{ diff --git a/Sources/CANAPI/README.md b/Sources/CANAPI/README.md index efb0e4b..7a5adca 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: 1268 $ +Version $Rev: 1270 $ # A CAN Interface Wrapper Specification diff --git a/Sources/CANAPI/can_api.h b/Sources/CANAPI/can_api.h index ea72f83..64dc677 100644 --- a/Sources/CANAPI/can_api.h +++ b/Sources/CANAPI/can_api.h @@ -7,8 +7,8 @@ * * 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). + * 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: @@ -49,9 +49,9 @@ * * @brief CAN API V3 for generic CAN Interfaces * - * @author $Author: haumea $ + * @author $Author: eris $ * - * @version $Rev: 1260 $ + * @version $Rev: 1270 $ * * @defgroup can_api CAN Interface API, Version 3 * @{ diff --git a/Sources/CANAPI/can_btr.c b/Sources/CANAPI/can_btr.c index c31be4c..315ff75 100644 --- a/Sources/CANAPI/can_btr.c +++ b/Sources/CANAPI/can_btr.c @@ -7,8 +7,8 @@ * * 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). + * 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: @@ -57,7 +57,7 @@ * * @author $Author: eris $ * - * @version $Rev: 1269 $ + * @version $Rev: 1270 $ * * @addtogroup can_btr * @{ diff --git a/Sources/CANAPI/can_btr.h b/Sources/CANAPI/can_btr.h index cedf91c..e7ddeaa 100644 --- a/Sources/CANAPI/can_btr.h +++ b/Sources/CANAPI/can_btr.h @@ -7,8 +7,8 @@ * * 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). + * 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: @@ -49,9 +49,9 @@ * * @brief CAN API V3 for generic CAN Interfaces (Bit-rate Conversion) * - * @author $Author: haumea $ + * @author $Author: eris $ * - * @version $Rev: 1259 $ + * @version $Rev: 1270 $ * * @defgroup can_btr CAN Bit-rate Conversion * @{ diff --git a/Sources/CANAPI/can_msg.c b/Sources/CANAPI/can_msg.c index fe4f7ec..32dc54b 100644 --- a/Sources/CANAPI/can_msg.c +++ b/Sources/CANAPI/can_msg.c @@ -7,8 +7,8 @@ * * 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). + * 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: @@ -49,9 +49,9 @@ * * @brief CAN Message Formatter * - * @author $Author: haumea $ + * @author $Author: eris $ * - * @version $Rev: 1259 $ + * @version $Rev: 1270 $ * * @addtogroup can_msg * @{ diff --git a/Sources/CANAPI/can_msg.h b/Sources/CANAPI/can_msg.h index 1ba6693..badf12f 100644 --- a/Sources/CANAPI/can_msg.h +++ b/Sources/CANAPI/can_msg.h @@ -7,8 +7,8 @@ * * 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). + * 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: @@ -49,9 +49,9 @@ * * @brief CAN Message Formatter * - * @author $Author: haumea $ + * @author $Author: eris $ * - * @version $Rev: 1259 $ + * @version $Rev: 1270 $ * * @defgroup can_msg CAN Message Formatter * @{ From f2c0d59de8db4b7a8cbcb01cd13993f594200e8f Mon Sep 17 00:00:00 2001 From: Uwe Vogt Date: Wed, 24 Apr 2024 10:37:18 +0200 Subject: [PATCH 06/11] Update CAN API V3 testing sources to rev. 1273 Relates to [CANAPI-80] --- Tests/Driver.h | 19 +- Tests/README.md | 2 +- Tests/Sources/Bitrates.cpp | 10 +- Tests/Sources/Bitrates.h | 10 +- Tests/Sources/Config.h | 10 +- Tests/Sources/Device.cpp | 10 +- Tests/Sources/Device.h | 8 +- Tests/Sources/Options.cpp | 10 +- Tests/Sources/Options.h | 10 +- Tests/Sources/Progress.cpp | 12 +- Tests/Sources/Progress.h | 12 +- Tests/Sources/Properties.cpp | 8 +- Tests/Sources/Properties.h | 8 +- Tests/Sources/Settings.h | 10 +- Tests/Sources/Timer.cpp | 46 ++-- Tests/Sources/Timer.h | 28 +-- Tests/Sources/Timer64.cpp | 261 ---------------------- Tests/Sources/Timer64.h | 91 -------- Tests/Sources/main.cpp | 8 +- Tests/Sources/pch.h | 2 +- Tests/Testcases/TC00_SmokeTest.cc | 10 +- Tests/Testcases/TC01_ProbeChannel.cc | 10 +- Tests/Testcases/TC02_InitializeChannel.cc | 10 +- Tests/Testcases/TC03_StartController.cc | 10 +- Tests/Testcases/TC04_ReadMessage.cc | 10 +- Tests/Testcases/TC05_WriteMessage.cc | 10 +- Tests/Testcases/TC06_ResetController.cc | 10 +- Tests/Testcases/TC08_TeardownChannel.cc | 10 +- Tests/Testcases/TC09_GetStatus.cc | 10 +- Tests/Testcases/TC11_GetBitrate.cc | 10 +- Tests/Testcases/TC12_GetProperty.cc | 10 +- Tests/Testcases/TC21_GetBusSpeed.cc | 10 +- Tests/Testcases/TC23_SetFilter11Bit.cc | 9 +- Tests/Testcases/TC25_SetFilter29Bit.cc | 9 +- Tests/Testcases/TC27_ResetFilter.cc | 8 +- Tests/Testcases/TCx1_CallSequences.cc | 10 +- Tests/Testcases/TCx2_BitrateConverter.cc | 10 +- Tests/Version.h | 14 +- Tests/kvl_testing.vcxproj | 4 +- Tests/kvl_testing.vcxproj.filters | 4 +- 40 files changed, 216 insertions(+), 547 deletions(-) delete mode 100644 Tests/Sources/Timer64.cpp delete mode 100644 Tests/Sources/Timer64.h diff --git a/Tests/Driver.h b/Tests/Driver.h index f27f0c9..94de858 100644 --- a/Tests/Driver.h +++ b/Tests/Driver.h @@ -7,8 +7,8 @@ // // 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). +// 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: @@ -43,7 +43,7 @@ // 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 . +// along with CAN API V3. If not, see . // #ifndef DRIVER_H_INCLUDED #define DRIVER_H_INCLUDED @@ -79,6 +79,7 @@ typedef CKvaserCAN CCanDriver; // (§5) define macros for CAN Classic bit-rate settings // at least BITRATE_1M, BITRATE_500K, BITRATE_250K, BITRATE_125K, // BITRATE_100K, BITRATE_50K, BITRATE_20K, BITRATE_10K +#if (OPTION_KVASER_BIT_TIMING == 1) #define BITRATE_1M(x) KVASER_CAN_BR_1M(x) #define BITRATE_800K(x) KVASER_CAN_BR_800K(x) #define BITRATE_500K(x) KVASER_CAN_BR_500K(x) @@ -89,6 +90,18 @@ typedef CKvaserCAN CCanDriver; #define BITRATE_20K(x) KVASER_CAN_BR_20K(x) #define BITRATE_10K(x) KVASER_CAN_BR_10K(x) #define BITRATE_5K(x) KVASER_CAN_BR_5K(x) +#else +#define BITRATE_1M(x) DEFAULT_CAN_BR_1M(x) +#define BITRATE_800K(x) DEFAULT_CAN_BR_800K(x) +#define BITRATE_500K(x) DEFAULT_CAN_BR_500K(x) +#define BITRATE_250K(x) DEFAULT_CAN_BR_250K(x) +#define BITRATE_125K(x) DEFAULT_CAN_BR_125K(x) +#define BITRATE_100K(x) DEFAULT_CAN_BR_100K(x) +#define BITRATE_50K(x) DEFAULT_CAN_BR_50K(x) +#define BITRATE_20K(x) DEFAULT_CAN_BR_20K(x) +#define BITRATE_10K(x) DEFAULT_CAN_BR_10K(x) +#define BITRATE_5K(x) DEFAULT_CAN_BR_5K(x) +#endif // (§6) define macros for workarounds (e.g. TC01_3_ISSUE) #define TC09_8_ISSUE_BUS_OFF WORKAROUND_ENABLED // 2023-08-28: test hangs up diff --git a/Tests/README.md b/Tests/README.md index b72e23d..f2f6dfe 100644 --- a/Tests/README.md +++ b/Tests/README.md @@ -3,7 +3,7 @@ _Copyright © 2004-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com)_ \ _All rights reserved._ -Version $Rev: 1255 $ +Version $Rev: 1273 $ # CAN Interface Wrapper Specification diff --git a/Tests/Sources/Bitrates.cpp b/Tests/Sources/Bitrates.cpp index bfccbde..f79ddee 100644 --- a/Tests/Sources/Bitrates.cpp +++ b/Tests/Sources/Bitrates.cpp @@ -2,13 +2,13 @@ // // 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. // -// 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). +// 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: @@ -43,7 +43,7 @@ // 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 . +// along with CAN API V3. If not, see . // #include "pch.h" #include @@ -308,4 +308,4 @@ bool CBitrates::IsCanFdWithBrse() { (aBitrateString[m_nIndex].m_fCanFdWithBrse)) ? true : false; } -// $Id: Bitrates.cpp 1170 2023-08-23 14:01:13Z haumea $ Copyright (c) UV Software, Berlin // +// $Id: Bitrates.cpp 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin // diff --git a/Tests/Sources/Bitrates.h b/Tests/Sources/Bitrates.h index a4a43b5..b222cf4 100644 --- a/Tests/Sources/Bitrates.h +++ b/Tests/Sources/Bitrates.h @@ -2,13 +2,13 @@ // // 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. // -// 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). +// 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: @@ -43,7 +43,7 @@ // 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 . +// along with CAN API V3. If not, see . // #ifndef BITRATES_H_INCLUDED #define BITRATES_H_INCLUDED @@ -66,5 +66,5 @@ class CBitrates { }; #endif // BITRATES_H_INCLUDED -// $Id: Bitrates.h 1148 2023-08-15 16:20:55Z haumea $ Copyright (c) UV Software, Berlin // +// $Id: Bitrates.h 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin // diff --git a/Tests/Sources/Config.h b/Tests/Sources/Config.h index 44f8d9b..54f0d7a 100644 --- a/Tests/Sources/Config.h +++ b/Tests/Sources/Config.h @@ -2,13 +2,13 @@ // // 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. // -// 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). +// 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: @@ -43,7 +43,7 @@ // 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 . +// along with CAN API V3. If not, see . // #ifndef CONFIG_H_INCLUDED #define CONFIG_H_INCLUDED @@ -67,5 +67,5 @@ #define GTEST_DISABLED DISABLE_GTEST #endif // CONFIG_H_INCLUDED -// $Id: Config.h 1171 2023-08-23 15:08:43Z haumea $ Copyright (c) UV Software, Berlin. +// $Id: Config.h 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin. diff --git a/Tests/Sources/Device.cpp b/Tests/Sources/Device.cpp index a7fc5d4..31d084f 100644 --- a/Tests/Sources/Device.cpp +++ b/Tests/Sources/Device.cpp @@ -2,13 +2,13 @@ // // 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. // -// 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). +// 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: @@ -43,7 +43,7 @@ // 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 . +// along with CAN API V3. If not, see . // #include "pch.h" #include @@ -590,4 +590,4 @@ void CCanDevice::ShowChannelCapabilities(const char* prefix) { std::cout << std::endl; } -// $Id: Device.cpp 1217 2023-10-10 19:28:31Z haumea $ Copyright (c) UV Software, Berlin // +// $Id: Device.cpp 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin // diff --git a/Tests/Sources/Device.h b/Tests/Sources/Device.h index 8afb0e9..21aaa1a 100644 --- a/Tests/Sources/Device.h +++ b/Tests/Sources/Device.h @@ -7,8 +7,8 @@ // // 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). +// 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: @@ -43,7 +43,7 @@ // 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 . +// along with CAN API V3. If not, see . // #ifndef DEVICE_H_INCLUDED #define DEVICE_H_INCLUDED @@ -173,4 +173,4 @@ class CCanDevice : public CCanDriver { #endif // DEVICE_H_INCLUDED -// $Id: Device.h 1254 2024-03-10 20:41:16Z haumea $ Copyright (c) UV Software, Berlin. +// $Id: Device.h 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin. diff --git a/Tests/Sources/Options.cpp b/Tests/Sources/Options.cpp index d0e2ce1..1ca26f1 100644 --- a/Tests/Sources/Options.cpp +++ b/Tests/Sources/Options.cpp @@ -2,13 +2,13 @@ // // 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. // -// 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). +// 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: @@ -43,7 +43,7 @@ // 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 . +// along with CAN API V3. If not, see . // #ifdef _MSC_VER //no Microsoft extensions please! @@ -716,4 +716,4 @@ int COptions::ShowHelp() { return m_fShowHelp; } -// $Id: Options.cpp 1193 2023-09-06 10:21:35Z haumea $ Copyright (c) UV Software, Berlin // +// $Id: Options.cpp 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin // diff --git a/Tests/Sources/Options.h b/Tests/Sources/Options.h index 4062a6b..92cbeca 100644 --- a/Tests/Sources/Options.h +++ b/Tests/Sources/Options.h @@ -2,13 +2,13 @@ // // 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. // -// 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). +// 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: @@ -43,7 +43,7 @@ // 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 . +// along with CAN API V3. If not, see . // #ifndef OPTIONS_H_INCLUDED #define OPTIONS_H_INCLUDED @@ -139,4 +139,4 @@ extern COptions g_Options; // global access to testing options #endif // OPTIONS_H_INCLUDED -// $Id: Options.h 1193 2023-09-06 10:21:35Z haumea $ Copyright (c) UV Software, Berlin. +// $Id: Options.h 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin. diff --git a/Tests/Sources/Progress.cpp b/Tests/Sources/Progress.cpp index 650e6e5..9e6e809 100644 --- a/Tests/Sources/Progress.cpp +++ b/Tests/Sources/Progress.cpp @@ -2,11 +2,13 @@ // // Software for Industrial Communication, Motion Control and Automation // -// Copyright (c) 2002-2022 Uwe Vogt, UV Software, Berlin (info@uv-software.com) +// Copyright (c) 2002-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com) // All rights reserved. // -// This class is dual-licensed under the BSD 2-Clause "Simplified" License and -// under the GNU General Public License v3.0 (or any later version). +// Class CProgress +// +// This class 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 class. // // BSD 2-Clause "Simplified" License: @@ -41,7 +43,7 @@ // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License -// along with this class. If not, see . +// along with this class. If not, see . // #include "Progress.h" #include @@ -138,4 +140,4 @@ void CCounter::Increment() { #endif } -// $Id: Progress.cpp 798 2023-10-07 19:01:13Z makemake $ Copyright (c) UV Software, Berlin // +// $Id: Progress.cpp 811 2024-04-18 14:03:48Z quaoar $ Copyright (c) UV Software, Berlin // diff --git a/Tests/Sources/Progress.h b/Tests/Sources/Progress.h index 1c04a81..0b96d40 100644 --- a/Tests/Sources/Progress.h +++ b/Tests/Sources/Progress.h @@ -2,11 +2,13 @@ // // Software for Industrial Communication, Motion Control and Automation // -// Copyright (c) 2002-2022 Uwe Vogt, UV Software, Berlin (info@uv-software.com) +// Copyright (c) 2002-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com) // All rights reserved. // -// This class is dual-licensed under the BSD 2-Clause "Simplified" License and -// under the GNU General Public License v3.0 (or any later version). +// Class CProgress +// +// This class 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 class. // // BSD 2-Clause "Simplified" License: @@ -41,7 +43,7 @@ // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License -// along with this class. If not, see . +// along with this class. If not, see . // #ifndef PROGRESS_H_INCLUDED #define PROGRESS_H_INCLUDED @@ -80,4 +82,4 @@ class CCounter { #endif // PROGRESS_H_INCLUDED -// $Id: Progress.h 798 2023-10-07 19:01:13Z makemake $ Copyright (c) UV Software, Berlin // +// $Id: Progress.h 811 2024-04-18 14:03:48Z quaoar $ Copyright (c) UV Software, Berlin // diff --git a/Tests/Sources/Properties.cpp b/Tests/Sources/Properties.cpp index 2e6b824..981f9da 100644 --- a/Tests/Sources/Properties.cpp +++ b/Tests/Sources/Properties.cpp @@ -7,8 +7,8 @@ // // 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). +// 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: @@ -43,7 +43,7 @@ // 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 . +// along with CAN API V3. If not, see . // #include "pch.h" #include @@ -187,4 +187,4 @@ const char* CProperties::Description() { return aProperties[MAX_PROPERTIES].m_szDescription; } -// $Id: Properties.cpp 1253 2024-03-09 20:14:41Z haumea $ Copyright (c) UV Software, Berlin // +// $Id: Properties.cpp 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin // diff --git a/Tests/Sources/Properties.h b/Tests/Sources/Properties.h index 37f9382..b15add0 100644 --- a/Tests/Sources/Properties.h +++ b/Tests/Sources/Properties.h @@ -7,8 +7,8 @@ // // 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). +// 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: @@ -43,7 +43,7 @@ // 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 . +// along with CAN API V3. If not, see . // #ifndef PROPERTIES_H_INCLUDED #define PROPERTIES_H_INCLUDED @@ -74,5 +74,5 @@ class CProperties { }; #endif // PROPERTIES_H_INCLUDED -// $Id: Properties.h 1250 2024-03-04 18:33:06Z haumea $ Copyright (c) UV Software, Berlin // +// $Id: Properties.h 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin // diff --git a/Tests/Sources/Settings.h b/Tests/Sources/Settings.h index 869d0a8..dba564c 100644 --- a/Tests/Sources/Settings.h +++ b/Tests/Sources/Settings.h @@ -2,13 +2,13 @@ // // 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. // -// 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). +// 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: @@ -43,7 +43,7 @@ // 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 . +// along with CAN API V3. If not, see . // #ifndef SETTINGS_H_INCLUDED #define SETTINGS_H_INCLUDED @@ -158,4 +158,4 @@ #endif #endif // SETTINGS_H_INCLUDED -// $Id: Settings.h 1217 2023-10-10 19:28:31Z haumea $ Copyright (c) UV Software, Berlin. +// $Id: Settings.h 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin. diff --git a/Tests/Sources/Timer.cpp b/Tests/Sources/Timer.cpp index 42858d6..afc35ee 100644 --- a/Tests/Sources/Timer.cpp +++ b/Tests/Sources/Timer.cpp @@ -2,11 +2,13 @@ // // Software for Industrial Communication, Motion Control and Automation // -// Copyright (c) 2002-2023 Uwe Vogt, UV Software, Berlin (info@uv-software.com) +// Copyright (c) 2002-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com) // All rights reserved. // -// This class is dual-licensed under the BSD 2-Clause "Simplified" License and -// under the GNU General Public License v3.0 (or any later version). +// Class CTimer +// +// This class 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 class. // // BSD 2-Clause "Simplified" License: @@ -41,7 +43,7 @@ // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License -// along with this class. If not, see . +// along with this class. If not, see . // #ifdef _DEBUG #undef THIS_FILE @@ -58,48 +60,50 @@ static char THIS_FILE[]=__FILE__; #endif #define POSIX_DEPRECATED 0 /* set to non-zero value to use 'gettimeofday' and 'usleep'*/ -CTimer::CTimer(uint32_t u32Microseconds) { +CTimer::CTimer(uint64_t u64Microseconds) { #if !defined(_WIN32) && !defined(_WIN64) #if (POSIX_DEPRECATED != 0) struct timeval tv; gettimeofday(&tv, NULL); m_u64UntilStop = ((uint64_t)tv.tv_sec * (uint64_t)1000000) + (uint64_t)tv.tv_usec - + ((uint64_t)u32Microseconds); + + ((uint64_t)u64Microseconds); #else struct timespec now = { 0, 0 }; clock_gettime(CLOCK_MONOTONIC, &now); m_u64UntilStop = ((uint64_t)now.tv_sec * (uint64_t)1000000) + ((uint64_t)now.tv_nsec / (uint64_t)1000) - + ((uint64_t)u32Microseconds); + + ((uint64_t)u64Microseconds); #endif #else LARGE_INTEGER largeCounter; // high-resolution performance counter + m_llUntilStop = (LONGLONG)0; // counter value for the desired time-out + // retrieve the frequency of the high-resolution performance counter if(!QueryPerformanceFrequency(&m_largeFrequency)) return; // retrieve the current value of the high-resolution performance counter - if(!QueryPerformanceCounter(&largeCounter)) + if (!QueryPerformanceCounter(&largeCounter)) return; // calculate the counter value for the desired time-out - m_llUntilStop = largeCounter.QuadPart + ((m_largeFrequency.QuadPart * (LONGLONG)u32Microseconds) + m_llUntilStop = largeCounter.QuadPart + ((m_largeFrequency.QuadPart * (LONGLONG)u64Microseconds) / (LONGLONG)1000000); #endif } -bool CTimer::Restart(uint32_t u32Microseconds) { +bool CTimer::Restart(uint64_t u64Microseconds) { #if !defined(_WIN32) && !defined(_WIN64) #if (POSIX_DEPRECATED != 0) struct timeval tv; gettimeofday(&tv, NULL); m_u64UntilStop = ((uint64_t)tv.tv_sec * (uint64_t)1000000) + (uint64_t)tv.tv_usec - + ((uint64_t)u32Microseconds); + + ((uint64_t)u64Microseconds); #else struct timespec now = { 0, 0 }; clock_gettime(CLOCK_MONOTONIC, &now); m_u64UntilStop = ((uint64_t)now.tv_sec * (uint64_t)1000000) + ((uint64_t)now.tv_nsec / (uint64_t)1000) - + ((uint64_t)u32Microseconds); + + ((uint64_t)u64Microseconds); #endif return true; #else @@ -109,7 +113,7 @@ bool CTimer::Restart(uint32_t u32Microseconds) { if(!QueryPerformanceCounter(&largeCounter)) return false; // calculate the counter value for the desired time-out - m_llUntilStop = largeCounter.QuadPart + ((m_largeFrequency.QuadPart * (LONGLONG)u32Microseconds) + m_llUntilStop = largeCounter.QuadPart + ((m_largeFrequency.QuadPart * (LONGLONG)u64Microseconds) / (LONGLONG)1000000); return true; #endif @@ -146,15 +150,15 @@ bool CTimer::Timeout() { #endif } -bool CTimer::Delay(uint32_t u32Microseconds) { +bool CTimer::Delay(uint64_t u64Microseconds) { #if !defined(_WIN32) && !defined(_WIN64) #if (POSIX_DEPRECATED != 0) - return (usleep((useconds_t)u32Microseconds) != 0) ? false : true; + return (usleep((useconds_t)u64Microseconds) != 0) ? false : true; #else int rc; struct timespec delay; - delay.tv_sec = (time_t)(u32Microseconds / CTimer::SEC); - delay.tv_nsec = (long)((u32Microseconds % CTimer::SEC) * (uint32_t)1000); + delay.tv_sec = (time_t)(u64Microseconds / CTimer::SEC); + delay.tv_nsec = (long)((u64Microseconds % CTimer::SEC) * (uint32_t)1000); errno = 0; while ((rc = nanosleep(&delay, &delay))) { if (errno != EINTR) @@ -175,7 +179,7 @@ bool CTimer::Delay(uint32_t u32Microseconds) { if(!QueryPerformanceFrequency(&largeFrequency)) return false; // calculate the counter value for the desired delay - llUntilStop = largeCounter.QuadPart + ((largeFrequency.QuadPart * (LONGLONG)u32Microseconds) + llUntilStop = largeCounter.QuadPart + ((largeFrequency.QuadPart * (LONGLONG)u64Microseconds) / (LONGLONG)1000000); // wait until the counter overruns the delay time for(;;) @@ -189,9 +193,9 @@ bool CTimer::Delay(uint32_t u32Microseconds) { HANDLE timer; LARGE_INTEGER ft; - ft.QuadPart = -(10 * (LONGLONG)u32Microseconds); // Convert to 100 nanosecond interval, negative value indicates relative time + ft.QuadPart = -(10 * (LONGLONG)u64Microseconds); // Convert to 100 nanosecond interval, negative value indicates relative time - if(u32Microseconds >= 100) { // FIXME: Who made this decision? + if(u64Microseconds >= 100) { // FIXME: Who made this decision? if ((timer = CreateWaitableTimer(NULL, TRUE, NULL)) != NULL) { SetWaitableTimer(timer, &ft, 0, NULL, NULL, 0); WaitForSingleObject(timer, INFINITE); @@ -256,4 +260,4 @@ double CTimer::DiffTime(struct timespec start, struct timespec stop) { ((double)start.tv_sec + ((double)start.tv_nsec / 1000000000.f))); } -// $Id: Timer.cpp 1213 2023-10-07 19:43:58Z makemake $ Copyright (c) UV Software, Berlin // +// $Id: Timer.cpp 1273 2024-04-18 16:59:22Z makemake $ Copyright (c) UV Software, Berlin // diff --git a/Tests/Sources/Timer.h b/Tests/Sources/Timer.h index 5f0ebc5..3bb4460 100644 --- a/Tests/Sources/Timer.h +++ b/Tests/Sources/Timer.h @@ -2,11 +2,13 @@ // // Software for Industrial Communication, Motion Control and Automation // -// Copyright (c) 2002-2023 Uwe Vogt, UV Software, Berlin (info@uv-software.com) +// Copyright (c) 2002-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com) // All rights reserved. // -// This class is dual-licensed under the BSD 2-Clause "Simplified" License and -// under the GNU General Public License v3.0 (or any later version). +// Class CTimer +// +// This class 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 class. // // BSD 2-Clause "Simplified" License: @@ -41,7 +43,7 @@ // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License -// along with this class. If not, see . +// along with this class. If not, see . // #ifndef TIMER_H_INCLUDED #define TIMER_H_INCLUDED @@ -62,10 +64,10 @@ class CTimer { public: - static const uint32_t USEC = 1U; // 1 microsecond - static const uint32_t MSEC = 1000U; // 1 millisecond - static const uint32_t SEC = 1000000U; // 1 second - static const uint32_t MIN = 60000000U; // 1 minute + static const uint64_t USEC = 1U; // 1 microsecond + static const uint64_t MSEC = 1000U; // 1 millisecond + static const uint64_t SEC = 1000000U; // 1 second + static const uint64_t MIN = 60000000U; // 1 minute private: #if !defined(_WIN32) && !defined(_WIN64) uint64_t m_u64UntilStop; // counter value for the desired time-out @@ -74,13 +76,13 @@ class CTimer { LONGLONG m_llUntilStop; // counter value for the desired time-out #endif public: - CTimer(uint32_t u32Microseconds = 0); + CTimer(uint64_t u64Microseconds = 0); virtual ~CTimer() {}; - bool Restart(uint32_t u32Timeout); // restart the timer! - bool Timeout(); // time-out occurred? + bool Restart(uint64_t u64Microseconds); // restart the timer! + bool Timeout(); // time-out occurred? - static bool Delay(uint32_t u32Delay); // delay timer + static bool Delay(uint64_t u64Microseconds); // delay timer static struct timespec GetTime(); // time with nanosecond resolution static double DiffTime(struct timespec start, struct timespec stop); @@ -88,4 +90,4 @@ class CTimer { #endif // TIMER_H_INCLUDED -// $Id: Timer.h 799 2023-10-07 19:15:23Z makemake $ Copyright (c) UV Software, Berlin // +// $Id: Timer.h 810 2024-04-18 14:01:00Z quaoar $ Copyright (c) UV Software, Berlin // diff --git a/Tests/Sources/Timer64.cpp b/Tests/Sources/Timer64.cpp deleted file mode 100644 index 9e855de..0000000 --- a/Tests/Sources/Timer64.cpp +++ /dev/null @@ -1,261 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-or-later -// -// Software for Industrial Communication, Motion Control and Automation -// -// Copyright (c) 2002-2023 Uwe Vogt, UV Software, Berlin (info@uv-software.com) -// All rights reserved. -// -// This class 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 class. -// -// 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. -// -// THIS CLASS 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 THIS CLASS, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// GNU General Public License v3.0 or later: -// This class 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 class 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 class. If not, see . -// -#ifdef _DEBUG -#undef THIS_FILE -static char THIS_FILE[]=__FILE__; -#define new DEBUG_NEW -#endif - -#include "Timer64.h" - -#if !defined(_WIN32) && !defined(_WIN64) -#include -#include -#include -#endif -#define POSIX_DEPRECATED 0 /* set to non-zero value to use 'gettimeofday' and 'usleep'*/ - -CTimer::CTimer(uint64_t u64Microseconds) { -#if !defined(_WIN32) && !defined(_WIN64) -#if (POSIX_DEPRECATED != 0) - struct timeval tv; - gettimeofday(&tv, NULL); - m_u64UntilStop = ((uint64_t)tv.tv_sec * (uint64_t)1000000) + (uint64_t)tv.tv_usec - + ((uint64_t)u64Microseconds); -#else - struct timespec now = { 0, 0 }; - clock_gettime(CLOCK_MONOTONIC, &now); - m_u64UntilStop = ((uint64_t)now.tv_sec * (uint64_t)1000000) - + ((uint64_t)now.tv_nsec / (uint64_t)1000) - + ((uint64_t)u64Microseconds); -#endif -#else - LARGE_INTEGER largeCounter; // high-resolution performance counter - - m_llUntilStop = (LONGLONG)0; // counter value for the desired time-out - - // retrieve the frequency of the high-resolution performance counter - if(!QueryPerformanceFrequency(&m_largeFrequency)) - return; - // retrieve the current value of the high-resolution performance counter - if(!QueryPerformanceCounter(&largeCounter)) - return; - // calculate the counter value for the desired time-out - m_llUntilStop = largeCounter.QuadPart + ((m_largeFrequency.QuadPart * (LONGLONG)u64Microseconds) - / (LONGLONG)1000000); -#endif -} - -bool CTimer::Restart(uint64_t u64Microseconds) { -#if !defined(_WIN32) && !defined(_WIN64) -#if (POSIX_DEPRECATED != 0) - struct timeval tv; - gettimeofday(&tv, NULL); - m_u64UntilStop = ((uint64_t)tv.tv_sec * (uint64_t)1000000) + (uint64_t)tv.tv_usec - + ((uint64_t)u64Microseconds); -#else - struct timespec now = { 0, 0 }; - clock_gettime(CLOCK_MONOTONIC, &now); - m_u64UntilStop = ((uint64_t)now.tv_sec * (uint64_t)1000000) - + ((uint64_t)now.tv_nsec / (uint64_t)1000) - + ((uint64_t)u64Microseconds); -#endif - return true; -#else - LARGE_INTEGER largeCounter; // high-resolution performance counter - - // retrieve the current value of the high-resolution performance counter - if(!QueryPerformanceCounter(&largeCounter)) - return false; - // calculate the counter value for the desired time-out - m_llUntilStop = largeCounter.QuadPart + ((m_largeFrequency.QuadPart * (LONGLONG)u64Microseconds) - / (LONGLONG)1000000); - return true; -#endif -} - -bool CTimer::Timeout() { -#if !defined(_WIN32) && !defined(_WIN64) - uint64_t u64Now; -#if (POSIX_DEPRECATED != 0) - struct timeval tv; - gettimeofday(&tv, NULL); - u64Now = ((uint64_t)tv.tv_sec * (uint64_t)1000000) + (uint64_t)tv.tv_usec; -#else - struct timespec now = { 0, 0 }; - clock_gettime(CLOCK_MONOTONIC, &now); - u64Now = ((uint64_t)now.tv_sec * (uint64_t)1000000) - + ((uint64_t)now.tv_nsec / (uint64_t)1000); -#endif - if(u64Now < this->m_u64UntilStop) - return false; - else - return true; -#else - LARGE_INTEGER largeCounter; // high-resolution performance counter - - // retrieve the current value of the high-resolution performance counter - if(!QueryPerformanceCounter(&largeCounter)) - return false; - // a time-out occurred, if the counter overruns the time-out value - if(largeCounter.QuadPart < m_llUntilStop) - return false; - else - return true; -#endif -} - -bool CTimer::Delay(uint64_t u64Microseconds) { -#if !defined(_WIN32) && !defined(_WIN64) -#if (POSIX_DEPRECATED != 0) - return (usleep((useconds_t)u64Microseconds) != 0) ? false : true; -#else - int rc; - struct timespec delay; - delay.tv_sec = (time_t)(u64Microseconds / CTimer::SEC); - delay.tv_nsec = (long)((u64Microseconds % CTimer::SEC) * (uint32_t)1000); - errno = 0; - while ((rc = nanosleep(&delay, &delay))) { - if (errno != EINTR) - break; - } - return (rc != 0) ? false : true; -#endif -#else -# ifndef CTIMER_WAITABLE_TIMER - LARGE_INTEGER largeFrequency; // frequency in counts per second - LARGE_INTEGER largeCounter; // high-resolution performance counter - LONGLONG llUntilStop; // counter value for the desired delay - - // retrieve the current value of the high-resolution performance counter - if(!QueryPerformanceCounter(&largeCounter)) - return false; - // retrieve the frequency of the high-resolution performance counter - if(!QueryPerformanceFrequency(&largeFrequency)) - return false; - // calculate the counter value for the desired delay - llUntilStop = largeCounter.QuadPart + ((largeFrequency.QuadPart * (LONGLONG)u64Microseconds) - / (LONGLONG)1000000); - // wait until the counter overruns the delay time - for(;;) - { - if(!QueryPerformanceCounter(&largeCounter)) - return false; - if(largeCounter.QuadPart >= llUntilStop) - return true; - } -# else - HANDLE timer; - LARGE_INTEGER ft; - - ft.QuadPart = -(10 * (LONGLONG)u64Microseconds); // Convert to 100 nanosecond interval, negative value indicates relative time - - if(u64Microseconds >= 100) { // FIXME: Who made this decision? - if ((timer = CreateWaitableTimer(NULL, TRUE, NULL)) != NULL) { - SetWaitableTimer(timer, &ft, 0, NULL, NULL, 0); - WaitForSingleObject(timer, INFINITE); - CloseHandle(timer); - } - } - else { - // According to MSDN's documentation for Sleep: - // | A value of zero causes the thread to relinquish the remainder of its time slice to any other - // | thread that is ready to run.If there are no other threads ready to run, the function returns - // | immediately, and the thread continues execution. - Sleep(0); - } - return true; -# endif -#endif -} - -struct timespec CTimer::GetTime() { - struct timespec now = { 0, 0 }; -#if !defined(_WIN32) && !defined(_WIN64) - clock_gettime(CLOCK_REALTIME, &now); -#else - static bool fInitialied = false; // initialization flag - static struct timespec tsStartTime; // time at first call (UTC) - static LARGE_INTEGER largeFrequency; // frequency in counts per second - static LARGE_INTEGER largeStartCounter; // high-resolution performance counter - LARGE_INTEGER largeCurrentCounter; - - if (!fInitialied) { - // retrieve the frequency of the high-resolution performance counter - if (!QueryPerformanceFrequency(&largeFrequency)) - return now; - // retrieve the value of the high-resolution performance counter - if (!QueryPerformanceCounter(&largeStartCounter)) - return now; - // retrieve the time as struct timespec - if (!timespec_get(&tsStartTime, TIME_UTC)) - return now; - fInitialied = true; - } - // retrieve the current value of the high-resolution performance counter - if (!QueryPerformanceCounter(&largeCurrentCounter)) - return now; - // calculate the current time with nanosecond resolution - largeCurrentCounter.QuadPart -= largeStartCounter.QuadPart; - time_t sec = largeCurrentCounter.QuadPart / largeFrequency.QuadPart; - long nsec = (long)(((largeCurrentCounter.QuadPart - (sec * largeFrequency.QuadPart)) - * 1000000000UL) / largeFrequency.QuadPart); - now.tv_sec = tsStartTime.tv_sec + sec; - now.tv_nsec = tsStartTime.tv_nsec + nsec; - if (now.tv_nsec >= 1000000000UL) { - now.tv_sec += 1; - now.tv_nsec -= 1000000000UL; - } -#endif - return now; -} - -double CTimer::DiffTime(struct timespec start, struct timespec stop) { - return (((double)stop.tv_sec + ((double)stop.tv_nsec / 1000000000.f)) - - ((double)start.tv_sec + ((double)start.tv_nsec / 1000000000.f))); -} - -// $Id$ Copyright (c) UV Software, Berlin // diff --git a/Tests/Sources/Timer64.h b/Tests/Sources/Timer64.h deleted file mode 100644 index df83a6d..0000000 --- a/Tests/Sources/Timer64.h +++ /dev/null @@ -1,91 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-or-later -// -// Software for Industrial Communication, Motion Control and Automation -// -// Copyright (c) 2002-2023 Uwe Vogt, UV Software, Berlin (info@uv-software.com) -// All rights reserved. -// -// This class 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 class. -// -// 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. -// -// THIS CLASS 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 THIS CLASS, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// GNU General Public License v3.0 or later: -// This class 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 class 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 class. If not, see . -// -#ifndef TIMER_H_INCLUDED -#define TIMER_H_INCLUDED - -#if _MSC_VER > 1000 -#pragma once -#endif - -#include -#include -#if defined(_WIN32) || defined(_WIN64) -#include -#endif - -#if defined(_WIN32) || defined(_WIN64) -#define CTIMER_WAITABLE_TIMER // a Windows alternative for usleep() -#endif - -class CTimer { -public: - static const uint64_t USEC = 1U; // 1 microsecond - static const uint64_t MSEC = 1000U; // 1 millisecond - static const uint64_t SEC = 1000000U; // 1 second - static const uint64_t MIN = 60000000U; // 1 minute -private: -#if !defined(_WIN32) && !defined(_WIN64) - uint64_t m_u64UntilStop; // counter value for the desired time-out -#else - LARGE_INTEGER m_largeFrequency; // frequency in counts per second - LONGLONG m_llUntilStop; // counter value for the desired time-out -#endif -public: - CTimer(uint64_t u64Microseconds = 0); - virtual ~CTimer() {}; - - bool Restart(uint64_t u64Microseconds); // restart the timer! - bool Timeout(); // time-out occurred? - - static bool Delay(uint64_t u64Microseconds); // delay timer - - static struct timespec GetTime(); // time with nanosecond resolution - static double DiffTime(struct timespec start, struct timespec stop); -}; - -#endif // TIMER_H_INCLUDED - -// $Id$ Copyright (c) UV Software, Berlin // diff --git a/Tests/Sources/main.cpp b/Tests/Sources/main.cpp index 0486f03..1dd850c 100644 --- a/Tests/Sources/main.cpp +++ b/Tests/Sources/main.cpp @@ -7,8 +7,8 @@ // // 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). +// 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: @@ -43,7 +43,7 @@ // 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 . +// along with CAN API V3. If not, see . // #include #include @@ -80,4 +80,4 @@ GTEST_API_ int main(int argc, char **argv) { return RUN_ALL_TESTS(); } -// $Id: main.cpp 1253 2024-03-09 20:14:41Z haumea $ Copyright (c) UV Software, Berlin // +// $Id: main.cpp 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin // diff --git a/Tests/Sources/pch.h b/Tests/Sources/pch.h index 3216ecc..6614a7d 100644 --- a/Tests/Sources/pch.h +++ b/Tests/Sources/pch.h @@ -28,7 +28,7 @@ #include "Bitrates.h" #include "Properties.h" #include "Progress.h" -#include "Timer64.h" +#include "Timer.h" #include "Version.h" #endif // PRECOMPILED_HEADERS_INCLUDED diff --git a/Tests/Testcases/TC00_SmokeTest.cc b/Tests/Testcases/TC00_SmokeTest.cc index e7d13b4..4e0b0a5 100644 --- a/Tests/Testcases/TC00_SmokeTest.cc +++ b/Tests/Testcases/TC00_SmokeTest.cc @@ -2,13 +2,13 @@ // // 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. // -// 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). +// 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: @@ -43,7 +43,7 @@ // 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 . +// along with CAN API V3. If not, see . // #include "pch.h" @@ -300,4 +300,4 @@ TEST_F(SmokeTest, DefaultScenario) { // @end. } -// $Id: TC00_SmokeTest.cc 1217 2023-10-10 19:28:31Z haumea $ Copyright (c) UV Software, Berlin. +// $Id: TC00_SmokeTest.cc 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin. diff --git a/Tests/Testcases/TC01_ProbeChannel.cc b/Tests/Testcases/TC01_ProbeChannel.cc index 161275a..94b7589 100644 --- a/Tests/Testcases/TC01_ProbeChannel.cc +++ b/Tests/Testcases/TC01_ProbeChannel.cc @@ -2,13 +2,13 @@ // // 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. // -// 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). +// 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: @@ -43,7 +43,7 @@ // 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 . +// along with CAN API V3. If not, see . // #include "pch.h" @@ -1031,4 +1031,4 @@ TEST_F(ProbeChannel, GTEST_TESTCASE(WithInvalidLibraryId, GTEST_DISABLED)) { } #endif // (OPTION_CANAPI_LIBRARY != OPTION_DISBALED) -// $Id: TC01_ProbeChannel.cc 1217 2023-10-10 19:28:31Z haumea $ Copyright (c) UV Software, Berlin. +// $Id: TC01_ProbeChannel.cc 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin. diff --git a/Tests/Testcases/TC02_InitializeChannel.cc b/Tests/Testcases/TC02_InitializeChannel.cc index bb445a4..0a2d04d 100644 --- a/Tests/Testcases/TC02_InitializeChannel.cc +++ b/Tests/Testcases/TC02_InitializeChannel.cc @@ -2,13 +2,13 @@ // // 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. // -// 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). +// 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: @@ -43,7 +43,7 @@ // 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 . +// along with CAN API V3. If not, see . // #include "pch.h" @@ -913,4 +913,4 @@ TEST_F(InitializeChannel, GTEST_TESTCASE(WithInvalidLibraryId, GTEST_DISABLED)) } #endif // (OPTION_CANAPI_LIBRARY != OPTION_DISBALED) -// $Id: TC02_InitializeChannel.cc 1188 2023-09-01 18:21:43Z haumea $ Copyright (c) UV Software, Berlin. +// $Id: TC02_InitializeChannel.cc 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin. diff --git a/Tests/Testcases/TC03_StartController.cc b/Tests/Testcases/TC03_StartController.cc index 9d75f80..4980552 100644 --- a/Tests/Testcases/TC03_StartController.cc +++ b/Tests/Testcases/TC03_StartController.cc @@ -2,13 +2,13 @@ // // 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. // -// 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). +// 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: @@ -43,7 +43,7 @@ // 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 . +// along with CAN API V3. If not, see . // #include "pch.h" @@ -2313,4 +2313,4 @@ TEST_F(StartController, GTEST_TESTCASE(WithCanFdBitrateSettingsInCan20Mode, GTES } #endif // (CAN_FD_SUPPORTED == FEATURE_SUPPORTED) -// $Id: TC03_StartController.cc 1218 2023-10-14 12:18:19Z makemake $ Copyright (c) UV Software, Berlin. +// $Id: TC03_StartController.cc 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin. diff --git a/Tests/Testcases/TC04_ReadMessage.cc b/Tests/Testcases/TC04_ReadMessage.cc index 7ebb399..89e493a 100644 --- a/Tests/Testcases/TC04_ReadMessage.cc +++ b/Tests/Testcases/TC04_ReadMessage.cc @@ -2,13 +2,13 @@ // // 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. // -// 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). +// 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: @@ -43,7 +43,7 @@ // 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 . +// along with CAN API V3. If not, see . // #include "pch.h" @@ -1978,4 +1978,4 @@ TEST_F(ReadMessage, GTEST_TESTCASE(WithDifferentTimeoutValues, GTEST_ENABLED)) { // @todo: (1) blocking read // @todo: (2) test reentrancy -// $Id: TC04_ReadMessage.cc 1218 2023-10-14 12:18:19Z makemake $ Copyright (c) UV Software, Berlin. +// $Id: TC04_ReadMessage.cc 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin. diff --git a/Tests/Testcases/TC05_WriteMessage.cc b/Tests/Testcases/TC05_WriteMessage.cc index cad28a0..f11538b 100644 --- a/Tests/Testcases/TC05_WriteMessage.cc +++ b/Tests/Testcases/TC05_WriteMessage.cc @@ -2,13 +2,13 @@ // // 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. // -// 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). +// 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: @@ -43,7 +43,7 @@ // 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 . +// along with CAN API V3. If not, see . // #include "pch.h" @@ -2211,4 +2211,4 @@ TEST_F(WriteMessage, GTEST_TESTCASE(WithFlagEsi, GTEST_ENABLED)) { // @todo: (1) blocking write // @todo: (2) test reentrancy -// $Id: TC05_WriteMessage.cc 1255 2024-03-12 16:53:58Z quaoar $ Copyright (c) UV Software, Berlin. +// $Id: TC05_WriteMessage.cc 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin. diff --git a/Tests/Testcases/TC06_ResetController.cc b/Tests/Testcases/TC06_ResetController.cc index f217841..70f3f1d 100644 --- a/Tests/Testcases/TC06_ResetController.cc +++ b/Tests/Testcases/TC06_ResetController.cc @@ -2,13 +2,13 @@ // // 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. // -// 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). +// 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: @@ -43,7 +43,7 @@ // 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 . +// along with CAN API V3. If not, see . // #include "pch.h" @@ -481,4 +481,4 @@ TEST_F(ResetController, GTEST_TESTCASE(CheckStatisticalCounters, GTEST_ENABLED)) // @end. } -// $Id: TC06_ResetController.cc 1165 2023-08-22 06:57:25Z haumea $ Copyright (c) UV Software, Berlin. +// $Id: TC06_ResetController.cc 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin. diff --git a/Tests/Testcases/TC08_TeardownChannel.cc b/Tests/Testcases/TC08_TeardownChannel.cc index e5a4af1..55b2eee 100644 --- a/Tests/Testcases/TC08_TeardownChannel.cc +++ b/Tests/Testcases/TC08_TeardownChannel.cc @@ -2,13 +2,13 @@ // // 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. // -// 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). +// 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: @@ -43,7 +43,7 @@ // 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 . +// along with CAN API V3. If not, see . // #include "pch.h" @@ -333,4 +333,4 @@ TEST_F(TeardownChannel, GTEST_TESTCASE(IfChannelTornDown, GTEST_ENABLED)) { // @note: shuting down all channels is not possible with the C++ API! -// $Id: TC08_TeardownChannel.cc 1165 2023-08-22 06:57:25Z haumea $ Copyright (c) UV Software, Berlin. +// $Id: TC08_TeardownChannel.cc 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin. diff --git a/Tests/Testcases/TC09_GetStatus.cc b/Tests/Testcases/TC09_GetStatus.cc index 03516c1..de61569 100644 --- a/Tests/Testcases/TC09_GetStatus.cc +++ b/Tests/Testcases/TC09_GetStatus.cc @@ -2,13 +2,13 @@ // // 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. // -// 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). +// 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: @@ -43,7 +43,7 @@ // 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 . +// along with CAN API V3. If not, see . // #include "pch.h" @@ -1318,4 +1318,4 @@ TEST_F(GetStatus, GTEST_TESTCASE(IfReceiveQueueFull, GTEST_TC09_14_ENABLED)) { // @end. } -// $Id: TC09_GetStatus.cc 1218 2023-10-14 12:18:19Z makemake $ Copyright (c) UV Software, Berlin. +// $Id: TC09_GetStatus.cc 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin. diff --git a/Tests/Testcases/TC11_GetBitrate.cc b/Tests/Testcases/TC11_GetBitrate.cc index 3f95c90..bef57ac 100644 --- a/Tests/Testcases/TC11_GetBitrate.cc +++ b/Tests/Testcases/TC11_GetBitrate.cc @@ -2,13 +2,13 @@ // // 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. // -// 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). +// 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: @@ -43,7 +43,7 @@ // 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 . +// along with CAN API V3. If not, see . // #include "pch.h" @@ -662,4 +662,4 @@ TEST_F(GetBitrate, GTEST_TESTCASE(WithVariousCanFdBitrateSettings, GTEST_ENABLED } #endif // (CAN_FD_SUPPORTED == FEATURE_SUPPORTED) -// $Id: TC11_GetBitrate.cc 1204 2023-09-24 15:26:57Z makemake $ Copyright (c) UV Software, Berlin. +// $Id: TC11_GetBitrate.cc 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin. diff --git a/Tests/Testcases/TC12_GetProperty.cc b/Tests/Testcases/TC12_GetProperty.cc index e8ecdeb..558c1da 100644 --- a/Tests/Testcases/TC12_GetProperty.cc +++ b/Tests/Testcases/TC12_GetProperty.cc @@ -2,13 +2,13 @@ // // 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. // -// 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). +// 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: @@ -43,7 +43,7 @@ // 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 . +// along with CAN API V3. If not, see . // #include "pch.h" @@ -711,4 +711,4 @@ TEST_F(GetProperty, GTEST_TESTCASE(IfChannelTornDown, GTEST_ENABLED)) { } -// $Id: TC12_GetProperty.cc 1250 2024-03-04 18:33:06Z haumea $ Copyright (c) UV Software, Berlin. +// $Id: TC12_GetProperty.cc 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin. diff --git a/Tests/Testcases/TC21_GetBusSpeed.cc b/Tests/Testcases/TC21_GetBusSpeed.cc index bd955bb..08ed69d 100644 --- a/Tests/Testcases/TC21_GetBusSpeed.cc +++ b/Tests/Testcases/TC21_GetBusSpeed.cc @@ -2,13 +2,13 @@ // // 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. // -// 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). +// 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: @@ -43,7 +43,7 @@ // 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 . +// along with CAN API V3. If not, see . // #include "pch.h" @@ -663,4 +663,4 @@ TEST_F(GetBusSpeed, GTEST_TESTCASE(WithVariousCanFdBitrateSettings, GTEST_DISABL } #endif // (CAN_FD_SUPPORTED == FEATURE_SUPPORTED) -// $Id: TC21_GetBusSpeed.cc 1158 2023-08-18 17:05:41Z haumea $ Copyright (c) UV Software, Berlin. +// $Id: TC21_GetBusSpeed.cc 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin. diff --git a/Tests/Testcases/TC23_SetFilter11Bit.cc b/Tests/Testcases/TC23_SetFilter11Bit.cc index 1780834..a15ea92 100644 --- a/Tests/Testcases/TC23_SetFilter11Bit.cc +++ b/Tests/Testcases/TC23_SetFilter11Bit.cc @@ -7,8 +7,8 @@ // // 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). +// 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: @@ -43,7 +43,7 @@ // 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 . +// along with CAN API V3. If not, see . // #include "pch.h" @@ -69,7 +69,6 @@ class SetFilter11Bit : public testing::Test { CCanDevice dut2 = CCanDevice(TEST_DEVICE(DUT2)); CANAPI_Message_t trmMsg = {}; CANAPI_Message_t rcvMsg = {}; - CANAPI_Status_t status = {}; CANAPI_Return_t retVal; // CAN message trmMsg.id = 0U; @@ -770,4 +769,4 @@ TEST_F(SetFilter11Bit, GTEST_TESTCASE(WithInvalidValues, GTEST_ENABLED)) { #endif // FEATURE_FILTERING != FEATURE_UNSUPPORTED -// $Id: TC23_SetFilter11Bit.cc 1254 2024-03-10 20:41:16Z haumea $ Copyright (c) UV Software, Berlin. +// $Id: TC23_SetFilter11Bit.cc 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin. diff --git a/Tests/Testcases/TC25_SetFilter29Bit.cc b/Tests/Testcases/TC25_SetFilter29Bit.cc index 26af112..fcf9ff7 100644 --- a/Tests/Testcases/TC25_SetFilter29Bit.cc +++ b/Tests/Testcases/TC25_SetFilter29Bit.cc @@ -7,8 +7,8 @@ // // 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). +// 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: @@ -43,7 +43,7 @@ // 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 . +// along with CAN API V3. If not, see . // #include "pch.h" @@ -69,7 +69,6 @@ class SetFilter29Bit : public testing::Test { CCanDevice dut2 = CCanDevice(TEST_DEVICE(DUT2)); CANAPI_Message_t trmMsg = {}; CANAPI_Message_t rcvMsg = {}; - CANAPI_Status_t status = {}; CANAPI_Return_t retVal; // CAN message trmMsg.id = 0U; @@ -839,4 +838,4 @@ TEST_F(SetFilter29Bit, GTEST_TESTCASE(IfXtdFramesSuppressed, GTEST_ENABLED)) { #endif // FEATURE_FILTERING != FEATURE_UNSUPPORTED -// $Id: TC25_SetFilter29Bit.cc 1254 2024-03-10 20:41:16Z haumea $ Copyright (c) UV Software, Berlin. +// $Id: TC25_SetFilter29Bit.cc 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin. diff --git a/Tests/Testcases/TC27_ResetFilter.cc b/Tests/Testcases/TC27_ResetFilter.cc index 592c885..bed5e87 100644 --- a/Tests/Testcases/TC27_ResetFilter.cc +++ b/Tests/Testcases/TC27_ResetFilter.cc @@ -7,8 +7,8 @@ // // 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). +// 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: @@ -43,7 +43,7 @@ // 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 . +// along with CAN API V3. If not, see . // #include "pch.h" @@ -598,4 +598,4 @@ TEST_F(ResetFilter, GTEST_TESTCASE(IfChannelTornDown, GTEST_ENABLED)) { #endif // FEATURE_FILTERING != FEATURE_UNSUPPORTED -// $Id: TC27_ResetFilter.cc 1251 2024-03-09 18:46:18Z haumea $ Copyright (c) UV Software, Berlin. +// $Id: TC27_ResetFilter.cc 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin. diff --git a/Tests/Testcases/TCx1_CallSequences.cc b/Tests/Testcases/TCx1_CallSequences.cc index 621e81a..aebcdde 100644 --- a/Tests/Testcases/TCx1_CallSequences.cc +++ b/Tests/Testcases/TCx1_CallSequences.cc @@ -2,13 +2,13 @@ // // 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. // -// 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). +// 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: @@ -43,7 +43,7 @@ // 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 . +// along with CAN API V3. If not, see . // #include "pch.h" @@ -1504,4 +1504,4 @@ TEST_F(CallSequences, GTEST_TESTCASE(ReadInitializeTeardown, GTEST_DISABLED)) { // @end. } -// $Id: TCx1_CallSequences.cc 1134 2023-08-06 17:58:59Z haumea $ Copyright (c) UV Software, Berlin. +// $Id: TCx1_CallSequences.cc 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin. diff --git a/Tests/Testcases/TCx2_BitrateConverter.cc b/Tests/Testcases/TCx2_BitrateConverter.cc index bea3b22..10a2ae8 100644 --- a/Tests/Testcases/TCx2_BitrateConverter.cc +++ b/Tests/Testcases/TCx2_BitrateConverter.cc @@ -2,13 +2,13 @@ // // 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. // -// 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). +// 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: @@ -43,7 +43,7 @@ // 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 . +// along with CAN API V3. If not, see . // #include "pch.h" #include @@ -1603,4 +1603,4 @@ TEST_F(BitrateConverter, GTEST_TESTCASE(BitrateToStringWithNullPointerForString, // // @note: passing a pointer for 'btr0btr1' is not possible with the C++ API! -// $Id: TCx2_BitrateConverter.cc 1218 2023-10-14 12:18:19Z makemake $ Copyright (c) UV Software, Berlin. +// $Id: TCx2_BitrateConverter.cc 1272 2024-04-16 19:55:27Z makemake $ Copyright (c) UV Software, Berlin. diff --git a/Tests/Version.h b/Tests/Version.h index 498eb55..72b1cb7 100644 --- a/Tests/Version.h +++ b/Tests/Version.h @@ -2,13 +2,13 @@ // // 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. // -// 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). +// 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: @@ -43,12 +43,12 @@ // 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 . +// along with CAN API V3. If not, see . // #ifndef VERSION_H_INCLUDED #define VERSION_H_INCLUDED -// SVN revision number (update with each commit: X) -#define REVISION_NO "$Rev: 1255 $" +// SVN revision number (update with each commit: XI) +#define REVISION_NO "$Rev: 1273 $" #endif // VERSION_H_INCLUDED -// $Id: Version.h 1255 2024-03-12 16:53:58Z quaoar $ Copyright (c) UV Software, Berlin // +// $Id: Version.h 1273 2024-04-18 16:59:22Z makemake $ Copyright (c) UV Software, Berlin // diff --git a/Tests/kvl_testing.vcxproj b/Tests/kvl_testing.vcxproj index be8717d..4287686 100644 --- a/Tests/kvl_testing.vcxproj +++ b/Tests/kvl_testing.vcxproj @@ -90,7 +90,7 @@ NotUsing - + NotUsing NotUsing @@ -128,7 +128,7 @@ - + diff --git a/Tests/kvl_testing.vcxproj.filters b/Tests/kvl_testing.vcxproj.filters index 87494ef..275163a 100644 --- a/Tests/kvl_testing.vcxproj.filters +++ b/Tests/kvl_testing.vcxproj.filters @@ -75,7 +75,7 @@ Header Files - + Header Files @@ -140,7 +140,7 @@ Source Files\Testcases - + Source Files From f1bb39142d3aa5a1cd0eae709692b295d6e3219a Mon Sep 17 00:00:00 2001 From: Uwe Vogt Date: Wed, 24 Apr 2024 10:41:11 +0200 Subject: [PATCH 07/11] Correct findings from walkthrough Relates to [CANAPI-80] --- Libraries/CANAPI/uvcankvl.rc | Bin 4750 -> 4746 bytes Libraries/KvaserCAN/KvaserCAN.rc | Bin 4750 -> 4746 bytes Sources/KvaserCAN.cpp | 50 +++---- Sources/KvaserCAN.h | 2 +- Sources/KvaserCAN_Defaults.h | 26 +++- Sources/KvaserCAN_Defines.h | 12 +- Sources/Version.h | 60 ++++++++ Sources/Wrapper/can_api.c | 187 ++++++++++++------------- Sources/Wrapper/can_defs.h | 6 +- Trial/Sources/main.cpp | 14 +- Utilities/can_moni/Driver.h | 52 +++---- Utilities/can_moni/README.md | 72 +++++----- Utilities/can_moni/Sources/Message.cpp | 8 +- Utilities/can_moni/Sources/Message.h | 8 +- Utilities/can_moni/Sources/Timer.cpp | 46 +++--- Utilities/can_moni/Sources/Timer.h | 28 ++-- Utilities/can_moni/Sources/main.cpp | 59 ++++---- Utilities/can_test/Driver.h | 56 +++----- Utilities/can_test/README.md | 86 ++++++------ Utilities/can_test/Sources/Timer.cpp | 46 +++--- Utilities/can_test/Sources/Timer.h | 28 ++-- Utilities/can_test/Sources/main.cpp | 69 +++++---- build_no.bat | 114 +++++++-------- 23 files changed, 552 insertions(+), 477 deletions(-) create mode 100644 Sources/Version.h diff --git a/Libraries/CANAPI/uvcankvl.rc b/Libraries/CANAPI/uvcankvl.rc index c6b443c8f825eb5c30ea908c48e53223209cc50a..71c2316695125eb1036bbc28b92bf55234bb51ed 100644 GIT binary patch delta 14 VcmeBE?NZ%vfroMB=BqqASph7)1?vC+ delta 18 ZcmeBD?Ni-wfrnLt!I?pG^F^MWtN=MV1=aun diff --git a/Libraries/KvaserCAN/KvaserCAN.rc b/Libraries/KvaserCAN/KvaserCAN.rc index c6b443c8f825eb5c30ea908c48e53223209cc50a..71c2316695125eb1036bbc28b92bf55234bb51ed 100644 GIT binary patch delta 14 VcmeBE?NZ%vfroMB=BqqASph7)1?vC+ delta 18 ZcmeBD?Ni-wfrnLt!I?pG^F^MWtN=MV1=aun diff --git a/Sources/KvaserCAN.cpp b/Sources/KvaserCAN.cpp index b6e50a4..9453d64 100644 --- a/Sources/KvaserCAN.cpp +++ b/Sources/KvaserCAN.cpp @@ -43,23 +43,8 @@ // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License -// along with KvaserCAN-Wrapper. If not, see . +// along with KvaserCAN-Wrapper. If not, see . // -#include "build_no.h" -#define VERSION_MAJOR 0 -#define VERSION_MINOR 3 -#define VERSION_PATCH 0 -#define VERSION_BUILD BUILD_NO -#define VERSION_STRING TOSTRING(VERSION_MAJOR) "." TOSTRING(VERSION_MINOR) "." TOSTRING(VERSION_PATCH) " (" TOSTRING(BUILD_NO) ")" -#if defined(_WIN64) -#define PLATFORM "x64" -#elif defined(_WIN32) -#define PLATFORM "x86" -#else -#error Platform not supported -#endif -static const char version[] = "CAN API V3 for Kvaser CAN Interfaces, Version " VERSION_STRING; - #ifdef _MSC_VER //no Microsoft extensions please! #ifndef _CRT_SECURE_NO_WARNINGS @@ -67,6 +52,8 @@ static const char version[] = "CAN API V3 for Kvaser CAN Interfaces, Version " V #endif #endif #include "KvaserCAN.h" +#include "Version.h" + #include "can_defs.h" #include "can_api.h" #include "can_btr.h" @@ -77,6 +64,25 @@ static const char version[] = "CAN API V3 for Kvaser CAN Interfaces, Version " V #include #include +#if defined(_WIN64) +#define PLATFORM "x64" +#elif defined(_WIN32) +#define PLATFORM "x86" +#else +#error Platform not supported +#endif +#ifndef _MSC_VER +#define STRCPY_S(dest,size,src) strcpy(dest,src) +#define STRNCPY_S(dest,size,src,len) strncpy(dest,src,len) +#define SSCANF_S(buf,format,...) sscanf(buf,format,__VA_ARGS__) +#define SPRINTF_S(buf,size,format,...) snprintf(buf,size,format,__VA_ARGS__) +#else +#define STRCPY_S(dest,size,src) strcpy_s(dest,size,src) +#define STRNCPY_S(dest,size,src,len) strncpy_s(dest,size,src,len) +#define SSCANF_S(buf,format,...) sscanf_s(buf,format,__VA_ARGS__) +#define SPRINTF_S(buf,size,format,...) sprintf_s(buf,size,format,__VA_ARGS__) +#endif + #if (OPTION_KvaserCAN_DYLIB != 0) __attribute__((constructor)) static void _initializer() { @@ -91,17 +97,7 @@ static void _finalizer() { #define EXPORT #endif -#ifndef _MSC_VER -#define STRCPY_S(dest,size,src) strcpy(dest,src) -#define STRNCPY_S(dest,size,src,len) strncpy(dest,src,len) -#define SSCANF_S(buf,format,...) sscanf(buf,format,__VA_ARGS__) -#define SPRINTF_S(buf,size,format,...) snprintf(buf,size,format,__VA_ARGS__) -#else -#define STRCPY_S(dest,size,src) strcpy_s(dest,size,src) -#define STRNCPY_S(dest,size,src,len) strncpy_s(dest,size,src,len) -#define SSCANF_S(buf,format,...) sscanf_s(buf,format,__VA_ARGS__) -#define SPRINTF_S(buf,size,format,...) sprintf_s(buf,size,format,__VA_ARGS__) -#endif +static const char version[] = "CAN API V3 for Kvaser CAN Interfaces, Version " VERSION_STRING; EXPORT CKvaserCAN::CKvaserCAN() { diff --git a/Sources/KvaserCAN.h b/Sources/KvaserCAN.h index 92ee4ec..48e07db 100644 --- a/Sources/KvaserCAN.h +++ b/Sources/KvaserCAN.h @@ -43,7 +43,7 @@ // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License -// along with KvaserCAN-Wrapper. If not, see . +// along with KvaserCAN-Wrapper. If not, see . // #ifndef KVASERCAN_H_INCLUDED #define KVASERCAN_H_INCLUDED diff --git a/Sources/KvaserCAN_Defaults.h b/Sources/KvaserCAN_Defaults.h index cbe0183..3d54a65 100644 --- a/Sources/KvaserCAN_Defaults.h +++ b/Sources/KvaserCAN_Defaults.h @@ -2,7 +2,7 @@ /* * CAN Interface API, Version 3 (for Kvaser CAN Interfaces) * - * Copyright (c) 2017-2023 Uwe Vogt, UV Software, Berlin (info@uv-software.com) + * Copyright (c) 2017-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com) * All rights reserved. * * This file is part of KvaserCAN-Wrapper. @@ -43,7 +43,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with KvaserCAN-Wrapper. If not, see . + * along with KvaserCAN-Wrapper. If not, see . */ /** @addtogroup can_btr * @{ @@ -64,6 +64,26 @@ extern "C" { /* ----------- options ------------------------------------------------ */ +/** @name Compiler Switches + * @brief Options for conditional compilation. + * @{ */ +/** @note Set define OPTION_KVASER_BIT_TIMING to a non-zero value to compile + * with non CiA bit-timing (e.g. in the build environment). + */ +#ifndef OPTION_DISABLED +#define OPTION_DISABLED 0 /**< if a define is not defined, it is automatically set to 0 */ +#endif +#ifndef OPTION_PCAN_BIT_TIMING +#define OPTION_PCAN_BIT_TIMING OPTION_DISABLED +#endif +#if (OPTION_KVASER_BIT_TIMING != OPTION_DISABLED) +#ifdef _MSC_VER +#pragma message ( "Compilation with non CiA bit-timming!" ) +#else +#warning Compilation with non CiA bit-timming! +#endif +#endif +/** @} */ /* ----------- defines ------------------------------------------------ */ @@ -120,5 +140,5 @@ extern "C" { /* ---------------------------------------------------------------------- * Uwe Vogt, UV Software, Chausseestrasse 33 A, 10115 Berlin, Germany * Tel.: +49-30-46799872, Fax: +49-30-46799873, Mobile: +49-170-3801903 - * E-Mail: uwe.vogt@uv-software.de, Homepage: http://www.uv-software.de/ + * E-Mail: uwe.vogt@uv-software.de, Homepage: https://www.uv-software.de/ */ diff --git a/Sources/KvaserCAN_Defines.h b/Sources/KvaserCAN_Defines.h index dd9e531..1afe649 100644 --- a/Sources/KvaserCAN_Defines.h +++ b/Sources/KvaserCAN_Defines.h @@ -2,7 +2,7 @@ /* * CAN Interface API, Version 3 (for Kvaser CAN Interfaces) * - * Copyright (c) 2017-2023 Uwe Vogt, UV Software, Berlin (info@uv-software.com) + * Copyright (c) 2017-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com) * All rights reserved. * * This file is part of KvaserCAN-Wrapper. @@ -43,7 +43,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with KvaserCAN-Wrapper. If not, see . + * along with KvaserCAN-Wrapper. If not, see . */ /** @addtogroup can_api * @{ @@ -124,7 +124,7 @@ extern "C" { #define KVASER_DRIVER_VERSION (CANPROP_DRIVER_SPECIFIC + 22U) #define KVASER_DRIVER_NAME (CANPROP_DRIVER_SPECIFIC + 27U) //#define KVASER_IO_SERIAL_NUMBER (CANPROP_DRIVER_SPECIFIC + 7U) - // TODO: define more or all parameters +// TODO: define more or all parameters // ... #define KVASERCAN_MAX_BUFFER_SIZE 256U /**< max. buffer size for GetProperty/SetProperty */ /** @} */ @@ -134,7 +134,7 @@ extern "C" { * @{ */ #define KVASER_LIB_ID 600 /**< library ID (CAN/COP API V1 compatible) */ #if defined(_WIN32) || defined (_WIN64) - #define KVASER_LIB_CANLIB "canLib32.DLL" + #define KVASER_LIB_CANLIB "canLib32.dll" #define KVASER_LIB_WRAPPER "u3cankvl.dll" #elif defined(__APPLE__) #define KVASER_LIB_CANLIB "(n/a)" @@ -146,7 +146,7 @@ extern "C" { /** @name Miscellaneous * @brief More or less useful stuff - * @{ */ // TODO: to be moved or removed + * @{ */ #define KVASER_LIB_VENDOR "Kvaser AB, Sweden" #define KVASER_LIB_WEBSITE "https://www.kvaser.com/" #define KVASER_LIB_HAZARD_NOTE "If you connect your CAN device to a real CAN network when using this library,\n" \ @@ -162,5 +162,5 @@ extern "C" { /* ---------------------------------------------------------------------- * Uwe Vogt, UV Software, Chausseestrasse 33 A, 10115 Berlin, Germany * Tel.: +49-30-46799872, Fax: +49-30-46799873, Mobile: +49-170-3801903 - * E-Mail: uwe.vogt@uv-software.de, Homepage: http://www.uv-software.de/ + * E-Mail: uwe.vogt@uv-software.de, Homepage: https://www.uv-software.de/ */ diff --git a/Sources/Version.h b/Sources/Version.h new file mode 100644 index 0000000..198d46c --- /dev/null +++ b/Sources/Version.h @@ -0,0 +1,60 @@ +/* SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-or-later */ +/* + * CAN Interface API, Version 3 (for Kvaser CAN Interfaces) + * + * Copyright (c) 2017-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.de) + * All rights reserved. + * + * This file is part of KvaserCAN-Wrapper. + * + * KvaserCAN-Wrapper 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 KvaserCAN-Wrapper in whole or in part. + * + * 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. + * + * KvaserCAN-Wrapper 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 KvaserCAN-Wrapper, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * GNU General Public License v3.0 or later: + * KvaserCAN-Wrapper 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. + * + * KvaserCAN-Wrapper 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 KvaserCAN-Wrapper. If not, see . + */ +#ifndef VERSION_H_INCLUDED +#define VERSION_H_INCLUDED +#include "build_no.h" +#define VERSION_MAJOR 0 +#define VERSION_MINOR 3 +#define VERSION_PATCH 0 +#define VERSION_BUILD BUILD_NO +#if (VERSION_PATCH == 0) +#define VERSION_STRING TOSTRING(VERSION_MAJOR) "." TOSTRING(VERSION_MINOR) " (" TOSTRING(BUILD_NO) ")" +#else +#define VERSION_STRING TOSTRING(VERSION_MAJOR) "." TOSTRING(VERSION_MINOR) "." TOSTRING(VERSION_PATCH) " (" TOSTRING(BUILD_NO) ")" +#endif +#endif diff --git a/Sources/Wrapper/can_api.c b/Sources/Wrapper/can_api.c index e6bba0d..39819ea 100644 --- a/Sources/Wrapper/can_api.c +++ b/Sources/Wrapper/can_api.c @@ -43,52 +43,44 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with KvaserCAN-Wrapper. If not, see . + * along with KvaserCAN-Wrapper. If not, see . */ /** @addtogroup can_api * @{ */ -#include "build_no.h" -#define VERSION_MAJOR 0 -#define VERSION_MINOR 3 -#define VERSION_PATCH 0 -#define VERSION_BUILD BUILD_NO -#define VERSION_STRING TOSTRING(VERSION_MAJOR) "." TOSTRING(VERSION_MINOR) "." TOSTRING(VERSION_PATCH) " (" TOSTRING(BUILD_NO) ")" +#ifdef _MSC_VER +//no Microsoft extensions please! +#ifndef _CRT_SECURE_NO_WARNINGS +#define _CRT_SECURE_NO_WARNINGS 1 +#endif +#endif #if defined(_WIN64) #define PLATFORM "x64" #elif defined(_WIN32) #define PLATFORM "x86" #else -#error Unsupported architecture +#error Platform not supported #endif -static const char version[] = "CAN API V3 for Kvaser CAN Interfaces, Version " VERSION_STRING; - /* ----------- includes ----------------------------------------------- */ -#ifdef _MSC_VER -//no Microsoft extensions please! -#ifndef _CRT_SECURE_NO_WARNINGS -#define _CRT_SECURE_NO_WARNINGS 1 -#endif -#endif #include "can_defs.h" #include "can_api.h" #include "can_btr.h" -#include -#include -#include #include #include "canlib.h" #include "canstat.h" +#include "Version.h" +#include +#include +#include /* ----------- options ------------------------------------------------ */ - #if (OPTION_CAN_2_0_ONLY != 0) #error Compilation with legacy CAN 2.0 frame format! #endif @@ -96,9 +88,23 @@ static const char version[] = "CAN API V3 for Kvaser CAN Interfaces, Version " V /* ----------- defines ------------------------------------------------ */ -#define KVASER_FREQ_DEFAULT (80000000) -#define KVASER_CHANNEL_DEFAULT (0) - +#ifndef KVASER_MAX_HANDLES +#define KVASER_MAX_HANDLES (8) // maximum number of open handles +#endif +#define INVALID_HANDLE (-1) +#define IS_HANDLE_VALID(hnd) ((0 <= (hnd)) && ((hnd) < KVASER_MAX_HANDLES)) +#ifndef DLC2LEN +#define DLC2LEN(x) dlc_table[((x) < 16) ? (x) : 15] +#endif +#ifndef LEN2DLC +#define LEN2DLC(x) ((x) > 48) ? 0xF : \ + ((x) > 32) ? 0xE : \ + ((x) > 24) ? 0xD : \ + ((x) > 20) ? 0xC : \ + ((x) > 16) ? 0xB : \ + ((x) > 12) ? 0xA : \ + ((x) > 8) ? 0x9 : (x) +#endif #if (OPTION_KVASER_BIT_TIMING != OPTION_DISABLED) #define KVASER_BDR_1000(btr) do{ btr.bitRate=canBITRATE_1M; } while(0) #define KVASER_BDR_500(btr) do{ btr.bitRate=canBITRATE_500K; } while(0) @@ -119,28 +125,20 @@ static const char version[] = "CAN API V3 for Kvaser CAN Interfaces, Version " V #define KVASER_BDR_20(btr) do{ btr.bitRate=20000, btr.tseg1=13; btr.tseg2=2; btr.sjw=2; btr.noSamp=1; btr.syncmode=0; } while(0) #define KVASER_BDR_10(btr) do{ btr.bitRate=10000; btr.tseg1=13; btr.tseg2=2; btr.sjw=2; btr.noSamp=1; btr.syncmode=0; } while(0) #endif -#ifndef KVASER_MAX_HANDLES -#define KVASER_MAX_HANDLES (8) // maximum number of open handles -#endif -#define INVALID_HANDLE (-1) -#define IS_HANDLE_VALID(hnd) ((0 <= (hnd)) && ((hnd) < KVASER_MAX_HANDLES)) -#ifndef DLC2LEN -#define DLC2LEN(x) dlc_table[((x) < 16) ? (x) : 15] -#endif -#ifndef LEN2DLC -#define LEN2DLC(x) ((x) > 48) ? 0xF : \ - ((x) > 32) ? 0xE : \ - ((x) > 24) ? 0xD : \ - ((x) > 20) ? 0xC : \ - ((x) > 16) ? 0xB : \ - ((x) > 12) ? 0xA : \ - ((x) > 8) ? 0x9 : (x) -#endif +#define KVASER_FREQ_DEFAULT (80000000) +#define KVASER_CHANNEL_DEFAULT (0) + #define FILTER_STD_CODE (uint32_t)(0x000) #define FILTER_STD_MASK (uint32_t)(0x000) #define FILTER_XTD_CODE (uint32_t)(0x00000000) #define FILTER_XTD_MASK (uint32_t)(0x00000000) +#define LIB_ID KVASER_LIB_ID +#define LIB_DLLNAME KVASER_LIB_WRAPPER +#define DEV_VENDOR KVASER_LIB_VENDOR +#define DEV_DLLNAME KVASER_LIB_CANLIB +#define NUM_CHANNELS KVASER_BOARDS + /* ----------- types -------------------------------------------------- */ @@ -184,7 +182,7 @@ typedef struct { // Kvaser CAN interface: int channel; // channel number of the CAN board long frequency; // frequency of the CAN controller can_mode_t mode; // operation mode of the CAN channel - can_filter_t filter; // message filter settings + can_filter_t filter; // message filtering settings can_status_t status; // 8-bit status register can_error_t error; // error code capture can_counter_t counters; // statistical counters @@ -193,6 +191,7 @@ typedef struct { // Kvaser CAN interface: /* ----------- prototypes --------------------------------------------- */ +static void var_init(void); // initialize variables static int kvaser_error(canStatus); // Kvaser specific errors static canStatus kvaser_capability(int channel, can_mode_t *capability); @@ -208,11 +207,9 @@ static int map_paramsFd2bitrate(const btr_data_t *busParams, long canClock, can_ static int lib_parameter(uint16_t param, void *value, size_t nbyte); static int drv_parameter(int handle, uint16_t param, void *value, size_t nbyte); -static void var_init(void); // initialize variables - - /* ----------- variables ---------------------------------------------- */ +static const char version[] = "CAN API V3 for Kvaser CAN Interfaces, Version " VERSION_STRING; can_board_t can_boards[KVASER_BOARDS+1] = // list of CAN Interface channels: { @@ -232,7 +229,6 @@ static const uint8_t dlc_table[16] = { // DLC to length static can_interface_t can[KVASER_MAX_HANDLES]; // interface handles static int init = 0; // initialization flag - /* ----------- functions ---------------------------------------------- */ @@ -823,6 +819,7 @@ int can_bitrate(int handle, can_bitrate_t *bitrate, can_speed_t *speed) int can_property(int handle, uint16_t param, void *value, uint32_t nbyte) { if (!init || !IS_HANDLE_VALID(handle)) { + // note: library properties can be queried w/o a handle return lib_parameter(param, value, (size_t)nbyte); } if (!init) // must be initialized @@ -831,7 +828,7 @@ int can_property(int handle, uint16_t param, void *value, uint32_t nbyte) return CANERR_HANDLE; if (can[handle].handle == canINVALID_HANDLE) // must be an opened handle return CANERR_HANDLE; - + // note: device properties must be queried with a valid handle return drv_parameter(handle, param, value, (size_t)nbyte); } @@ -886,6 +883,29 @@ char *can_firmware(int handle) /* ----------- local functions ---------------------------------------- */ +static void var_init(void) +{ + int i; + + for (i = 0; i < KVASER_MAX_HANDLES; i++) { + can[i].handle = canINVALID_HANDLE; + can[i].channel = KVASER_CHANNEL_DEFAULT; + can[i].frequency = KVASER_FREQ_DEFAULT; + can[i].mode.byte = CANMODE_DEFAULT; + can[i].status.byte = CANSTAT_RESET; + can[i].filter.std.code = FILTER_STD_CODE; + 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; + } +} + static int kvaser_error(canStatus status) { @@ -1126,7 +1146,7 @@ static int lib_parameter(uint16_t param, void *value, size_t nbyte) break; case CANPROP_GET_LIBRARY_ID: // library id of the library (int32_t) if (nbyte >= sizeof(int32_t)) { - *(int32_t*)value = (int32_t)KVASER_LIB_ID; + *(int32_t*)value = (int32_t)LIB_ID; rc = CANERR_NOERROR; } break; @@ -1137,20 +1157,20 @@ static int lib_parameter(uint16_t param, void *value, size_t nbyte) } break; case CANPROP_GET_LIBRARY_DLLNAME: // file name of the library (char[256]) - if ((nbyte > strlen(KVASER_LIB_WRAPPER)) && (nbyte <= CANPROP_MAX_BUFFER_SIZE)) { - strcpy((char*)value, KVASER_LIB_WRAPPER); + if ((nbyte > strlen(LIB_DLLNAME)) && (nbyte <= CANPROP_MAX_BUFFER_SIZE)) { + strcpy((char*)value, LIB_DLLNAME); rc = CANERR_NOERROR; } break; case CANPROP_GET_DEVICE_VENDOR: // vendor name of the CAN interface (char[256]) - if ((nbyte > strlen(KVASER_LIB_VENDOR)) && (nbyte <= CANPROP_MAX_BUFFER_SIZE)) { - strcpy((char*)value, KVASER_LIB_VENDOR); + if ((nbyte > strlen(DEV_VENDOR)) && (nbyte <= CANPROP_MAX_BUFFER_SIZE)) { + strcpy((char*)value, DEV_VENDOR); rc = CANERR_NOERROR; } break; case CANPROP_GET_DEVICE_DLLNAME: // file name of the CAN interface DLL (char[256]) - if ((nbyte > strlen(KVASER_LIB_CANLIB)) && (nbyte <= CANPROP_MAX_BUFFER_SIZE)) { - strcpy((char*)value, KVASER_LIB_CANLIB); + if ((nbyte > strlen(DEV_DLLNAME)) && (nbyte <= CANPROP_MAX_BUFFER_SIZE)) { + strcpy((char*)value, DEV_DLLNAME); rc = CANERR_NOERROR; } break; @@ -1159,7 +1179,7 @@ static int lib_parameter(uint16_t param, void *value, size_t nbyte) rc = (can_boards[idx_board].type != EOF) ? CANERR_NOERROR : CANERR_RESOURCE; break; case CANPROP_SET_NEXT_CHANNEL: // set index to the next entry in the interface list (NULL) - if ((0 <= idx_board) && (idx_board < KVASER_BOARDS)) { + if ((0 <= idx_board) && (idx_board < NUM_CHANNELS)) { if (can_boards[idx_board].type != EOF) idx_board++; rc = (can_boards[idx_board].type != EOF) ? CANERR_NOERROR : CANERR_RESOURCE; @@ -1169,7 +1189,7 @@ static int lib_parameter(uint16_t param, void *value, size_t nbyte) break; case CANPROP_GET_CHANNEL_NO: // get channel no. at actual index in the interface list (int32_t) if (nbyte >= sizeof(int32_t)) { - if ((0 <= idx_board) && (idx_board < KVASER_BOARDS) && + if ((0 <= idx_board) && (idx_board < NUM_CHANNELS) && (can_boards[idx_board].type != EOF)) { *(int32_t*)value = (int32_t)can_boards[idx_board].type; rc = CANERR_NOERROR; @@ -1180,7 +1200,7 @@ static int lib_parameter(uint16_t param, void *value, size_t nbyte) 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)) { - if ((0 <= idx_board) && (idx_board < KVASER_BOARDS) && + if ((0 <= idx_board) && (idx_board < NUM_CHANNELS) && (can_boards[idx_board].type != EOF)) { strncpy((char*)value, can_boards[idx_board].name, nbyte); ((char*)value)[(nbyte - 1)] = '\0'; @@ -1192,9 +1212,9 @@ static int lib_parameter(uint16_t param, void *value, size_t nbyte) 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)) { - if ((0 <= idx_board) && (idx_board < KVASER_BOARDS) && + if ((0 <= idx_board) && (idx_board < NUM_CHANNELS) && (can_boards[idx_board].type != EOF)) { - strncpy((char*)value, KVASER_LIB_CANLIB, nbyte); + strncpy((char*)value, DEV_DLLNAME, nbyte); ((char*)value)[(nbyte - 1)] = '\0'; rc = CANERR_NOERROR; } @@ -1204,9 +1224,9 @@ static int lib_parameter(uint16_t param, void *value, size_t nbyte) break; case CANPROP_GET_CHANNEL_VENDOR_ID: // get library id at actual index in the interface list (int32_t) if (nbyte >= sizeof(int32_t)) { - if ((0 <= idx_board) && (idx_board < KVASER_BOARDS) && + if ((0 <= idx_board) && (idx_board < NUM_CHANNELS) && (can_boards[idx_board].type != EOF)) { - *(int32_t*)value = (int32_t)KVASER_LIB_ID; + *(int32_t*)value = (int32_t)LIB_ID; rc = CANERR_NOERROR; } else @@ -1215,9 +1235,9 @@ static int lib_parameter(uint16_t param, void *value, size_t nbyte) 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)) { - if ((0 <= idx_board) && (idx_board < KVASER_BOARDS) && + if ((0 <= idx_board) && (idx_board < NUM_CHANNELS) && (can_boards[idx_board].type != EOF)) { - strncpy((char*)value, KVASER_LIB_VENDOR, nbyte); + strncpy((char*)value, DEV_VENDOR, nbyte); ((char*)value)[(nbyte - 1)] = '\0'; rc = CANERR_NOERROR; } @@ -1305,14 +1325,14 @@ static int drv_parameter(int handle, uint16_t param, void *value, size_t nbyte) } break; case CANPROP_GET_DEVICE_VENDOR: // vendor name of the CAN interface (char[256]) - if ((nbyte > strlen(KVASER_LIB_VENDOR)) && (nbyte <= CANPROP_MAX_BUFFER_SIZE)) { - strcpy((char*)value, KVASER_LIB_VENDOR); + if ((nbyte > strlen(DEV_VENDOR)) && (nbyte <= CANPROP_MAX_BUFFER_SIZE)) { + strcpy((char*)value, DEV_VENDOR); rc = CANERR_NOERROR; } break; case CANPROP_GET_DEVICE_DLLNAME: // file name of the CAN interface DLL (char[256]) - if ((nbyte > strlen(KVASER_LIB_CANLIB)) && (nbyte <= CANPROP_MAX_BUFFER_SIZE)) { - strcpy((char*)value, KVASER_LIB_CANLIB); + if ((nbyte > strlen(DEV_DLLNAME)) && (nbyte <= CANPROP_MAX_BUFFER_SIZE)) { + strcpy((char*)value, DEV_DLLNAME); rc = CANERR_NOERROR; } break; @@ -1412,7 +1432,7 @@ static int drv_parameter(int handle, uint16_t param, void *value, size_t nbyte) break; case CANPROP_SET_FILTER_11BIT: // set value for acceptance filter code and mask for 11-bit identifier (uint64_t) if (nbyte >= sizeof(uint64_t)) { - if (!(*(uint64_t*)value & 0xFFFFF800FFFFF800ULL)) { + if (!(*(uint64_t*)value & 0xFFFFF800FFFFF800ULL)) { // TODO: replace by a define // note: code and mask must not exceed 11-bit identifier if (can[handle].status.can_stopped) { // note: set filter only if the CAN controller is in INIT mode @@ -1430,8 +1450,10 @@ static int drv_parameter(int handle, uint16_t param, void *value, size_t nbyte) break; case CANPROP_SET_FILTER_29BIT: // set value for acceptance filter code and mask for 29-bit identifier (uint64_t) if (nbyte >= sizeof(uint64_t)) { - if (!(*(uint64_t*)value & 0xE0000000E0000000ULL) && !can[handle].mode.nxtd) { - // note: code and mask must not exceed 29-bit identifier and 29-bit mode must not be suppressed + if (!(*(uint64_t*)value & 0xE0000000E0000000ULL) && // TODO: replace by a define + !can[handle].mode.nxtd) { + // note: code and mask must not exceed 29-bit identifier and + // extended frame format mode must not be suppressed if (can[handle].status.can_stopped) { // note: set filter only if the CAN controller is in INIT mode if ((sts = kvaser_set_filter(handle, *(uint64_t*)value, 1)) == canOK) @@ -1497,33 +1519,10 @@ static int drv_parameter(int handle, uint16_t param, void *value, size_t nbyte) return rc; } -static void var_init(void) -{ - int i; - - for (i = 0; i < KVASER_MAX_HANDLES; i++) { - can[i].handle = canINVALID_HANDLE; - can[i].channel = KVASER_CHANNEL_DEFAULT; - can[i].frequency = KVASER_FREQ_DEFAULT; - can[i].mode.byte = CANMODE_DEFAULT; - can[i].status.byte = CANSTAT_RESET; - can[i].filter.std.code = FILTER_STD_CODE; - 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; - } -} - /* ----------- revision control --------------------------------------- */ -char* can_version(void) +char *can_version(void) { return (char*)version; } @@ -1532,5 +1531,5 @@ char* can_version(void) /* ---------------------------------------------------------------------- * Uwe Vogt, UV Software, Chausseestrasse 33 A, 10115 Berlin, Germany * Tel.: +49-30-46799872, Fax: +49-30-46799873, Mobile: +49-170-3801903 - * E-Mail: uwe.vogt@uv-software.de, Homepage: http://www.uv-software.de/ + * E-Mail: uwe.vogt@uv-software.de, Homepage: https://www.uv-software.de/ */ diff --git a/Sources/Wrapper/can_defs.h b/Sources/Wrapper/can_defs.h index 34e7a69..85897aa 100644 --- a/Sources/Wrapper/can_defs.h +++ b/Sources/Wrapper/can_defs.h @@ -2,7 +2,7 @@ /* * CAN Interface API, Version 3 (for Kvaser CAN Interfaces) * - * Copyright (c) 2017-2023 Uwe Vogt, UV Software, Berlin (info@uv-software.com) + * Copyright (c) 2017-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com) * All rights reserved. * * This file is part of KvaserCAN-Wrapper. @@ -43,7 +43,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with KvaserCAN-Wrapper. If not, see . + * along with KvaserCAN-Wrapper. If not, see . */ /** @addtogroup can_api * @{ @@ -82,5 +82,5 @@ /* ---------------------------------------------------------------------- * Uwe Vogt, UV Software, Chausseestrasse 33 A, 10115 Berlin, Germany * Tel.: +49-30-46799872, Fax: +49-30-46799873, Mobile: +49-170-3801903 - * E-Mail: uwe.vogt@uv-software.de, Homepage: http://www.uv-software.de/ + * E-Mail: uwe.vogt@uv-software.de, Homepage: https://www.uv-software.de/ */ diff --git a/Trial/Sources/main.cpp b/Trial/Sources/main.cpp index aadfcb4..f1a5be6 100644 --- a/Trial/Sources/main.cpp +++ b/Trial/Sources/main.cpp @@ -22,7 +22,7 @@ //#define SECOND_CHANNEL #define ISSUE_198 (0) -#if (1) +#if (OPTION_KVASER_BIT_TIMING == 1) #define BITRATE_1M(x) KVASER_CAN_BR_1M(x) #define BITRATE_800K(x) KVASER_CAN_BR_800K(x) #define BITRATE_500K(x) KVASER_CAN_BR_500K(x) @@ -45,7 +45,6 @@ #define BITRATE_10K(x) DEFAULT_CAN_BR_10K(x) #define BITRATE_5K(x) DEFAULT_CAN_BR_5K(x) #endif -#if (1) #define BITRATE_FD_1M(x) KVASER_CAN_FD_BR_1M(x) #define BITRATE_FD_500K(x) KVASER_CAN_FD_BR_500K(x) #define BITRATE_FD_250K(x) KVASER_CAN_FD_BR_250K(x) @@ -54,16 +53,7 @@ #define BITRATE_FD_500K4M(x) KVASER_CAN_FD_BR_500K4M(x) #define BITRATE_FD_250K2M(x) KVASER_CAN_FD_BR_250K2M(x) #define BITRATE_FD_125K1M(x) KVASER_CAN_FD_BR_125K1M(x) -#else -#define BITRATE_FD_1M(x) DEFAULT_CAN_FD_BR_1M(x) -#define BITRATE_FD_500K(x) DEFAULT_CAN_FD_BR_500K(x) -#define BITRATE_FD_250K(x) DEFAULT_CAN_FD_BR_250K(x) -#define BITRATE_FD_125K(x) DEFAULT_CAN_FD_BR_125K(x) -#define BITRATE_FD_1M8M(x) DEFAULT_CAN_FD_BR_1M8M(x) -#define BITRATE_FD_500K4M(x) DEFAULT_CAN_FD_BR_500K4M(x) -#define BITRATE_FD_250K2M(x) DEFAULT_CAN_FD_BR_250K2M(x) -#define BITRATE_FD_125K1M(x) DEFAULT_CAN_FD_BR_125K1M(x) -#endif + #define OPTION_NO (0) #define OPTION_YES (1) diff --git a/Utilities/can_moni/Driver.h b/Utilities/can_moni/Driver.h index 4a79ec3..f98838d 100644 --- a/Utilities/can_moni/Driver.h +++ b/Utilities/can_moni/Driver.h @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later // -// CAN Monitor for Kvaser CAN Interfaces +// CAN Monitor for Kvaser CAN Interfaces (CAN API V3) // // Copyright (c) 2007,2012-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com) // @@ -19,41 +19,18 @@ // #ifndef DRIVER_H_INCLUDED #define DRIVER_H_INCLUDED -#include "build_no.h" -#define VERSION_MAJOR 0 -#define VERSION_MINOR 3 -#define VERSION_PATCH 0 -#define VERSION_BUILD BUILD_NO -#define VERSION_STRING TOSTRING(VERSION_MAJOR) "." TOSTRING(VERSION_MINOR) "." TOSTRING(VERSION_PATCH) " (" TOSTRING(BUILD_NO) ")" -#if defined(_WIN64) -#define PLATFORM "x64" -#elif defined(_WIN32) -#define PLATFORM "x86" -#elif defined(__linux__) -#define PLATFORM "Linux" -#elif defined(__APPLE__) -#define PLATFORM "macOS" -#elif defined(__CYGWIN__) -#define PLATFORM "Cygwin" -#else -#error Platform not supported -#endif + +#include "KvaserCAN.h" + #if (OPTION_CAN_2_0_ONLY != 0) -#ifdef _MSC_VER -#pragma message ( "Compilation with legacy CAN 2.0 frame format!" ) -#else -#warning Compilation with legacy CAN 2.0 frame format! -#endif +#error Compilation with legacy CAN 2.0 frame format! #else -#define CAN_FD_SUPPORTED 1 // don't touch that dial! +#define CAN_FD_SUPPORTED 1 // don't touch that dial #endif #define MONITOR_INTEFACE "Kvaser CAN Interfaces" #define MONITOR_COPYRIGHT "2007,2012-2024 by Uwe Vogt, UV Software, Berlin" -#include "KvaserCAN.h" - -typedef CKvaserCAN CCanDriver; - +#if (OPTION_KVASER_BIT_TIMING == 1) #define BITRATE_1M(x) KVASER_CAN_BR_1M(x) #define BITRATE_800K(x) KVASER_CAN_BR_800K(x) #define BITRATE_500K(x) KVASER_CAN_BR_500K(x) @@ -63,7 +40,18 @@ typedef CKvaserCAN CCanDriver; #define BITRATE_50K(x) KVASER_CAN_BR_50K(x) #define BITRATE_20K(x) KVASER_CAN_BR_20K(x) #define BITRATE_10K(x) KVASER_CAN_BR_10K(x) - +#else +#define BITRATE_1M(x) DEFAULT_CAN_BR_1M(x) +#define BITRATE_800K(x) DEFAULT_CAN_BR_800K(x) +#define BITRATE_500K(x) DEFAULT_CAN_BR_500K(x) +#define BITRATE_250K(x) DEFAULT_CAN_BR_250K(x) +#define BITRATE_125K(x) DEFAULT_CAN_BR_125K(x) +#define BITRATE_100K(x) DEFAULT_CAN_BR_100K(x) +#define BITRATE_50K(x) DEFAULT_CAN_BR_50K(x) +#define BITRATE_20K(x) DEFAULT_CAN_BR_20K(x) +#define BITRATE_10K(x) DEFAULT_CAN_BR_10K(x) +#define BITRATE_5K(x) DEFAULT_CAN_BR_5K(x) +#endif #if (CAN_FD_SUPPORTED != 0) #define BITRATE_FD_1M(x) KVASER_CAN_FD_BR_1M(x) #define BITRATE_FD_500K(x) KVASER_CAN_FD_BR_500K(x) @@ -75,4 +63,6 @@ typedef CKvaserCAN CCanDriver; #define BITRATE_FD_125K1M(x) KVASER_CAN_FD_BR_125K1M(x) #endif +typedef CKvaserCAN CCanDriver; + #endif // DRIVER_H_INCLUDED diff --git a/Utilities/can_moni/README.md b/Utilities/can_moni/README.md index f2905bd..b09720b 100644 --- a/Utilities/can_moni/README.md +++ b/Utilities/can_moni/README.md @@ -1,33 +1,33 @@ __CAN Monitor for Kvaser CAN Interfaces, Version 0.3.0__ \ -Copyright © 2007,2017-2024 by Uwe Vogt, UV Software, Berlin +Copyright © 2007,2012-2024 by Uwe Vogt, UV Software, Berlin ``` Usage: can_moni [