Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release candidate 1 for version 0.5.1 #21

Merged
merged 13 commits into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Deployment.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### CAN API V3 Wrapper Library for Peak-System PCAN® Interfaces (Windows®)
### CAN API V3 Wrapper Library for PEAK-System PCAN® Interfaces (Windows®)

_Copyright © 2005-2024 Uwe Vogt, UV Software, Berlin ([email protected])_ \
_All rights reserved._
Expand Down
2 changes: 1 addition & 1 deletion Doxygen/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ PROJECT_NUMBER = v0.5
# for a project that appears at the top of each page and should give viewer a
# quick idea about the purpose of the project. Keep the description short.

PROJECT_BRIEF = "CAN API V3 Wrapper Library for Peak-System PCAN Interfaces (Windows)"
PROJECT_BRIEF = "CAN API V3 Wrapper Library for PEAK-System PCAN Interfaces (Windows)"

# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
# in the documentation. The maximum height of the logo should not exceed 55
Expand Down
Binary file modified Libraries/CANAPI/uvcanpcb.rc
Binary file not shown.
Binary file modified Libraries/PeakCAN/PeakCAN.rc
Binary file not shown.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### CAN API V3 Wrapper Library for Peak-System PCAN® Interfaces (Windows®)
### CAN API V3 Wrapper Library for PEAK-System PCAN® Interfaces (Windows®)

_Copyright © 2005-2024 Uwe Vogt, UV Software, Berlin ([email protected])_

Expand All @@ -10,14 +10,14 @@ CAN API V3 is a wrapper specification to have a uniform CAN Interface API for va

## PCANBasic-Wrapper

This repo contains the source code for a CAN API V3 compatible wrapper library under Windows for PCAN Interfaces from Peak-System Technik GmbH.
This repo contains the source code for a CAN API V3 compatible wrapper library under Windows for PCAN Interfaces from PEAK-System Technik GmbH.
The wrapper library is build upon Peak´s PCANBasic DLL.

### CAN Interface API, Version 3

```C++
/// \name PeakCAN API
/// \brief CAN API V3 driver for Peak-System PCAN interfaces
/// \brief CAN API V3 driver for PEAK-System PCAN interfaces
/// \note See CCanApi for a description of the overridden methods
/// \{
class CPeakCAN : public CCanApi {
Expand Down Expand Up @@ -146,7 +146,7 @@ For a list of known bugs and caveats see tab [Issues](https://github.com/uv-soft

### PCANBasic DLL for Windows®

The PCANBasic DLL can be downloaded form [Peak-System](https://www.peak-system.com/) website. \
The PCANBasic DLL can be downloaded form [PEAK-System](https://www.peak-system.com/) website. \
Please note the copyright and license agreements.

### Wrapper Library for macOS® and Linux®
Expand All @@ -168,7 +168,7 @@ You can choose between one of them if you use these portions of this work in who
### Trademarks

Windows is a registered trademark of Microsoft Corporation in the United States and/or other countries. \
PCAN is a registered trademark of Peak-System Technik GmbH, Darmstadt, Germany. \
PCAN is a registered trademark of PEAK-System Technik GmbH, Darmstadt, Germany. \
Mac and macOS are trademarks of Apple Inc., registered in the U.S. and other countries. \
Linux is a registered trademark of Linus Torvalds. \
All other company, product and service names mentioned herein may be trademarks, registered trademarks, or service marks of their respective owners.
Expand Down
4 changes: 4 additions & 0 deletions Sources/CANAPI/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
# we don't use the JSON files yet
can_dev.?
vanilla.?
# other blacklisted files
SerialCAN_Defines.h
SocketCAN_Defines.h
RocketCAN_Defines.h
16 changes: 12 additions & 4 deletions Sources/CANAPI/CANAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
///
/// \author $Author: quaoar $
//
/// \version $Rev: 1286 $
/// \version $Rev: 1294 $
//
/// \defgroup can_api CAN Interface API, Version 3
/// \{
Expand Down Expand Up @@ -477,8 +477,16 @@ class CANCPP CCanApi {
//
virtual char *GetFirmwareVersion() = 0; // deprecated

/// \brief retrieves version information of the CAN API V3 driver
/// as a zero-terminated string.
#if (OPTION_CANAPI_LIBRARY != 0)
/// \brief retrieves version information of the CAN API V3 wrapper
/// library as a zero-terminated string.
//
/// \returns pointer to a zero-terminated string, or NULL on error.
//
virtual char *GetSoftwareVersion() = 0; // deprecated
#endif
/// \brief retrieves version information of the CAN API V3 wrapper
/// (or loader) library as a zero-terminated string.
//
/// \returns pointer to a zero-terminated string, or NULL on error.
//
Expand Down Expand Up @@ -528,4 +536,4 @@ class CANCPP CCanApi {
/// \}
#endif // CANAPI_H_INCLUDED
/// \}
// $Id: CANAPI.h 1286 2024-05-10 17:03:31Z quaoar $ Copyright (c) UV Software //
// $Id: CANAPI.h 1294 2024-05-16 19:50:25Z quaoar $ Copyright (c) UV Software //
20 changes: 11 additions & 9 deletions Sources/CANAPI/CANAPI_Defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
*
* @brief CAN API V3 for generic CAN Interfaces - Definitions and Options
*
* @author $Author: eris $
* @author $Author: quaoar $
*
* @version $Rev: 1270 $
* @version $Rev: 1293 $
*
* @addtogroup can_api
* @{
Expand Down Expand Up @@ -79,23 +79,25 @@ extern "C" {

/** @name Library IDs
* @brief Unique IDs to identify a CAN API library (CAN API V1 compatible)
* @note These defines are still valid, but IDs are taken from JSON files.
* @{ */
#define CANLIB_IXXAT_VCI 100 /**< IXXAT Virtual CAN interfaces */
#define CANLIB_IXXAT_CAC 800 /**< IXXAT canAnalyzer/32 Client */
#define CANLIB_PEAK_PCAN 200 /**< PEAK PCAN interfaces */
#define CANLIB_PEAK_PCAN 200 /**< PEAK PCAN-Light interfaces */
#define CANLIB_VECTOR_XL 300 /**< Vector XL-Driver library */
#define CANLIB_PCANBASIC 400 /**< PEAK PCAN-Basic interfaces */
#define CANLIB_RUSOKU_LT 500 /**< Rusuko TouCAN interfaces */
#define CANLIB_RUSOKU_LT 500 /**< Rusoku TouCAN interfaces */
#define CANLIB_KVASER_32 600 /**< Kvaser CANLIB (canlib32) */
#define CANLIB_ROCKETCAN 700 /**< CAN-over-IP (RocketCAN) */
#define CANLIB_SERIALCAN 900 /**< Serial-Line (SerialCAN) */
#define CANLIB_SOCKETCAN 1000 /**< Linux CAN (SocketCAN) */
#define CANLIB_SOCKETCAN 1000 /**< Linux-CAN (SocketCAN) */
#define CANLIB_CANAPILIB (-1) /**< CAN API Main Library */
/** @note Peak's PCAN-Light DLL is outdated, so the library ID can be reused.
/** @note PCAN-Light is outdated, its ID is reused by macCAN-PeakCAN.
* @} */

/** @name Library Names
* @brief Filenames of the CAN API libraries (depending on the platform)
* @note Theses defines are outdated. DLL names are taken from JSON files.
* @{ */
#if defined(__linux__)
#define CANAPI_PLATFORM "Linux"
Expand Down Expand Up @@ -154,9 +156,9 @@ extern "C" {
#define CAN_API_WEBSITE "www.uv-software.com"
#define CAN_API_CONTACT "[email protected]"
#define CAN_API_LICENSE "BSD-2-Clause OR GPL-3.0-or-later"
#define CAN_API_COPYRIGHT "Copyright (c) 2005-20%02u, UV Software, Berlin"
#define CAN_API_HAZARD_NOTE "Do not connect your CAN device to a real CAN network when using this program.\n" \
"This can damage your application."
#define CAN_API_COPYRIGHT "Copyright (c) 2004-20%02u, UV Software, Berlin"
#define CAN_API_HAZARD_NOTE "If you connect your CAN device to a real CAN network when using this library,\n" \
"you might damage your application."
/** @} */


Expand Down
2 changes: 1 addition & 1 deletion Sources/CANAPI/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
_Copyright &copy; 2004-2024 Uwe Vogt, UV Software, Berlin ([email protected])_ \
_All rights reserved._

Version $Rev: 1289 $
Version $Rev: 1312 $

# A CAN Interface Wrapper Specification

Expand Down
1 change: 0 additions & 1 deletion Sources/PeakCAN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
#endif
#endif
#include "PeakCAN.h"
#include "Version.h"

#include "can_defs.h"
#include "can_api.h"
Expand Down
2 changes: 1 addition & 1 deletion Sources/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
#else
#define VERSION_MAJOR 0
#define VERSION_MINOR 2
#define VERSION_PATCH 8
#define VERSION_PATCH 9
#endif
#define VERSION_BUILD BUILD_NO
#if (VERSION_PATCH == 0)
Expand Down
65 changes: 33 additions & 32 deletions Sources/Wrapper/can_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,15 @@
#endif
#endif
#if defined(_WIN64)
#define PLATFORM "x64"
#define PLATFORM "x64"
#elif defined(_WIN32)
#define PLATFORM "x86"
#define PLATFORM "x86"
#elif defined(__linux__)
#define PLATFORM "Linux"
#define PLATFORM "Linux"
#elif defined(__APPLE__)
#define PLATFORM "macOS"
mac-can marked this conversation as resolved.
Show resolved Hide resolved
#define PLATFORM "macOS"
#elif defined(__CYGWIN__)
mac-can marked this conversation as resolved.
Show resolved Hide resolved
#define PLATFORM "Cygwin"
#else
#error Platform not supported
#endif
Expand All @@ -85,7 +87,6 @@
#include "PCANBasic.h"
#endif
#endif
#include "Version.h"

#include <stdio.h>
#include <string.h>
Expand Down Expand Up @@ -1357,26 +1358,26 @@ static int lib_parameter(uint16_t param, void *value, size_t nbyte)
rc = CANERR_NOERROR;
}
break;
case CANPROP_GET_LIBRARY_VENDOR: // vendor name of the library (char[256])
if ((nbyte > strlen(CAN_API_VENDOR)) && (nbyte <= CANPROP_MAX_BUFFER_SIZE)) {
case CANPROP_GET_LIBRARY_VENDOR: // vendor name of the library (char[])
if (nbyte > strlen(CAN_API_VENDOR)) {
strcpy((char*)value, CAN_API_VENDOR);
rc = CANERR_NOERROR;
}
break;
case CANPROP_GET_LIBRARY_DLLNAME: // file name of the library (char[256])
if ((nbyte > strlen(LIB_DLLNAME)) && (nbyte <= CANPROP_MAX_BUFFER_SIZE)) {
case CANPROP_GET_LIBRARY_DLLNAME: // file name of the library (char[])
if (nbyte > strlen(LIB_DLLNAME)) {
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(DEV_VENDOR)) && (nbyte <= CANPROP_MAX_BUFFER_SIZE)) {
case CANPROP_GET_DEVICE_VENDOR: // vendor name of the CAN interface (char[])
if (nbyte > strlen(DEV_VENDOR)) {
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(DEV_DLLNAME)) && (nbyte <= CANPROP_MAX_BUFFER_SIZE)) {
case CANPROP_GET_DEVICE_DLLNAME: // file name of the CAN interface DLL (char[])
if (nbyte > strlen(DEV_DLLNAME)) {
strcpy((char*)value, DEV_DLLNAME);
rc = CANERR_NOERROR;
}
Expand Down Expand Up @@ -1405,8 +1406,8 @@ static int lib_parameter(uint16_t param, void *value, size_t nbyte)
rc = CANERR_RESOURCE;
}
break;
case CANPROP_GET_CHANNEL_NAME: // get channel name at actual index in the interface list (char[256])
if ((0U < nbyte) && (nbyte <= CANPROP_MAX_BUFFER_SIZE)) {
case CANPROP_GET_CHANNEL_NAME: // get channel name at actual index in the interface list (char[])
if (nbyte >= 1U) {
if ((0 <= idx_board) && (idx_board < NUM_CHANNELS) &&
(can_boards[idx_board].type != EOF)) {
strncpy((char*)value, can_boards[idx_board].name, nbyte);
Expand All @@ -1417,8 +1418,8 @@ static int lib_parameter(uint16_t param, void *value, size_t nbyte)
rc = CANERR_RESOURCE;
}
break;
case CANPROP_GET_CHANNEL_DLLNAME: // get file name of the DLL at actual index in the interface list (char[256])
if ((0U < nbyte) && (nbyte <= CANPROP_MAX_BUFFER_SIZE)) {
case CANPROP_GET_CHANNEL_DLLNAME: // get file name of the DLL at actual index in the interface list (char[])
if (nbyte >= 1U) {
if ((0 <= idx_board) && (idx_board < NUM_CHANNELS) &&
(can_boards[idx_board].type != EOF)) {
strncpy((char*)value, DEV_DLLNAME, nbyte);
Expand All @@ -1440,8 +1441,8 @@ static int lib_parameter(uint16_t param, void *value, size_t nbyte)
rc = CANERR_RESOURCE;
}
break;
case CANPROP_GET_CHANNEL_VENDOR_NAME: // get vendor name at actual index in the interface list (char[256])
if ((0U < nbyte) && (nbyte <= CANPROP_MAX_BUFFER_SIZE)) {
case CANPROP_GET_CHANNEL_VENDOR_NAME: // get vendor name at actual index in the interface list (char[])
if (nbyte >= 1U) {
if ((0 <= idx_board) && (idx_board < NUM_CHANNELS) &&
(can_boards[idx_board].type != EOF)) {
strncpy((char*)value, DEV_VENDOR, nbyte);
Expand All @@ -1453,7 +1454,7 @@ static int lib_parameter(uint16_t param, void *value, size_t nbyte)
}
break;
case CANPROP_GET_DEVICE_TYPE: // device type of the CAN interface (int32_t)
case CANPROP_GET_DEVICE_NAME: // device name of the CAN interface (char[256])
case CANPROP_GET_DEVICE_NAME: // device name of the CAN interface (char[])
case CANPROP_GET_OP_CAPABILITY: // supported operation modes of the CAN controller (uint8_t)
case CANPROP_GET_OP_MODE: // active operation mode of the CAN controller (uint8_t)
case CANPROP_GET_BITRATE: // active bit-rate of the CAN controller (can_bitrate_t)
Expand Down Expand Up @@ -1531,32 +1532,32 @@ static int drv_parameter(int handle, uint16_t param, void *value, size_t nbyte)
rc = CANERR_NOERROR;
}
break;
case CANPROP_GET_DEVICE_NAME: // device name of the CAN interface (char[256])
if ((nbyte >= MAX_LENGTH_HARDWARE_NAME) && (nbyte <= CANPROP_MAX_BUFFER_SIZE)) {
case CANPROP_GET_DEVICE_NAME: // device name of the CAN interface (char[])
if (nbyte >= MAX_LENGTH_HARDWARE_NAME) {
if ((sts = CAN_GetValue(can[handle].board, (BYTE)PCAN_HARDWARE_NAME,
(void*)value, (DWORD)MAX_LENGTH_HARDWARE_NAME)) == PCAN_ERROR_OK)
rc = CANERR_NOERROR;
else
rc = pcan_error(sts);
}
break;
case CANPROP_GET_DEVICE_VENDOR: // vendor name of the CAN interface (char[256])
if ((nbyte > strlen(DEV_VENDOR)) && (nbyte <= CANPROP_MAX_BUFFER_SIZE)) {
case CANPROP_GET_DEVICE_VENDOR: // vendor name of the CAN interface (char[])
if (nbyte > strlen(DEV_VENDOR)) {
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(DEV_DLLNAME)) && (nbyte <= CANPROP_MAX_BUFFER_SIZE)) {
case CANPROP_GET_DEVICE_DLLNAME: // file name of the CAN interface DLL (char[])
if (nbyte > strlen(DEV_DLLNAME)) {
strcpy((char*)value, DEV_DLLNAME);
rc = CANERR_NOERROR;
}
break;
case CANPROP_GET_DEVICE_PARAM: // device parameter of the CAN interface (char[256])
if (nbyte >= sizeof(struct _pcan_param)) {
((struct _pcan_param*)value)->type = (uint8_t)can[handle].brd_type;
((struct _pcan_param*)value)->port = (uint32_t)can[handle].brd_port;
((struct _pcan_param*)value)->irq = (uint16_t)can[handle].brd_irq;
case CANPROP_GET_DEVICE_PARAM: // device parameter of the CAN interface (can_pcan_param_t)
if (nbyte >= sizeof(can_pcan_param_t)) {
((can_pcan_param_t*)value)->type = (uint8_t)can[handle].brd_type;
((can_pcan_param_t*)value)->port = (uint32_t)can[handle].brd_port;
((can_pcan_param_t*)value)->irq = (uint16_t)can[handle].brd_irq;
rc = CANERR_NOERROR;
}
break;
Expand Down Expand Up @@ -1689,7 +1690,7 @@ static int drv_parameter(int handle, uint16_t param, void *value, size_t nbyte)
if (nbyte >= sizeof(uint64_t)) {
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
// 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
Expand Down
1 change: 1 addition & 0 deletions Sources/Wrapper/can_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
/* ----------- includes ------------------------------------------------
*/

#include "Version.h"
#include "CANAPI_Defines.h"
#include "PeakCAN_Defines.h"

Expand Down
4 changes: 4 additions & 0 deletions Tests/Driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ typedef CPeakCAN CCanDriver;
#endif

// (§6) define macros for workarounds (e.g. TC01_3_ISSUE)
#if (OPTION_REGRESSION_TEST == 0)
#define TC09_8_ISSUE_BUS_OFF WORKAROUND_ENABLED // 2023-08-25: no bus off from device (investigation required)
#endif
// (§6.1) old PCANBasic issues (see macros in 'Settings.h')
#define PCBUSB_INIT_DELAY_WORKAROUND WORKAROUND_ENABLED
#define PCBUSB_QXMTFULL_WORKAROUND WORKAROUND_ENABLED
Expand Down Expand Up @@ -148,7 +150,9 @@ typedef CPeakCAN CCanDriver;
#endif

// (§11) define macros for workarounds for CAN FD operation mode (e.g. TC01_3_ISSUE_FD)
#if (OPTION_REGRESSION_TEST == 0)
//#define TC0x_y_ISSUE_FD_ WORKAROUND_ENABLED
#endif

// (§12) define macros for CAN FD bit-rate settings to be used in the tests, if supported
#define CAN_BITRATE_FD_DEFAULT BITRATE_FD_250K2M
Expand Down
2 changes: 1 addition & 1 deletion Tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
_Copyright &copy; 2004-2024 Uwe Vogt, UV Software, Berlin ([email protected])_ \
_All rights reserved._

Version $Rev: 1273 $
Version $Rev: 1316 $

# CAN Interface Wrapper Specification

Expand Down
Loading
Loading