Skip to content

Commit 7ffb5a3

Browse files
authored
Merge pull request #5 from uv-software/development
Release candidate 1 for version 0.4.3
2 parents cede7f7 + ae7361b commit 7ffb5a3

File tree

17 files changed

+458
-251
lines changed

17 files changed

+458
-251
lines changed

Libraries/CANAPI/Resource.rc

0 Bytes
Binary file not shown.

Libraries/PeakCAN/Resource.rc

0 Bytes
Binary file not shown.

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ public:
2727
~CPeakCAN();
2828

2929
// CCanApi overrides
30+
static bool GetFirstChannel(SChannelInfo &info, void *param = NULL);
31+
static bool GetNextChannel(SChannelInfo &info, void *param = NULL);
32+
3033
static CANAPI_Return_t ProbeChannel(int32_t channel, const CANAPI_OpMode_t &opMode, const void *param, EChannelState &state);
3134
static CANAPI_Return_t ProbeChannel(int32_t channel, const CANAPI_OpMode_t &opMode, EChannelState &state);
3235

@@ -119,7 +122,7 @@ Type `can_test /?` to display all program options.
119122
120123
### Required PCANBasic DLL
121124
122-
- Version 4.6 or later _(Latest is Greatest!)_
125+
- Version 4.5 or later _(Latest is Greatest!)_
123126
124127
## Known Bugs and Caveats
125128

Sources/CANAPI/CANAPI.h

Lines changed: 81 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// CAN Interface API, Version 3 (Interface Definition)
44
//
5-
// Copyright (c) 2004-2021 Uwe Vogt, UV Software, Berlin ([email protected])
5+
// Copyright (c) 2004-2022 Uwe Vogt, UV Software, Berlin ([email protected])
66
// All rights reserved.
77
//
88
// This file is part of CAN API V3.
@@ -73,9 +73,9 @@
7373
/// zero to compile your program with the CAN API source files or to
7474
/// link your program with the static library at compile-time.
7575
///
76-
/// \author $Author: eris $
76+
/// \author $Author: makemake $
7777
//
78-
/// \version $Rev: 1013 $
78+
/// \version $Rev: 1033 $
7979
//
8080
/// \defgroup can_api CAN Interface API, Version 3
8181
/// \{
@@ -144,13 +144,6 @@ typedef int CANAPI_Return_t;
144144
/// \{
145145
class CANCPP CCanApi {
146146
public:
147-
/// \brief CAN channel states
148-
enum EChannelState {
149-
ChannelOccupied = CANBRD_OCCUPIED, ///< channel is available, but occupied
150-
ChannelAvailable = CANBRD_PRESENT, ///< channel is available and can be used
151-
ChannelNotAvailable = CANBRD_NOT_PRESENT, ///< channel is not available
152-
ChannelNotTestable = CANBRD_NOT_TESTABLE ///< channel is not testable
153-
};
154147
/// \brief Common error codes (CAN API V3 compatible)
155148
enum EErrorCodes {
156149
NoError = CANERR_NOERROR, ///< no error!
@@ -176,6 +169,80 @@ class CANCPP CCanApi {
176169
FatalError = CANERR_FATAL, ///< fatal error
177170
VendorSpecific = CANERR_VENDOR ///< offset for vendor-specific error code
178171
};
172+
/// \brief CAN channel states
173+
enum EChannelState {
174+
ChannelOccupied = CANBRD_OCCUPIED, ///< channel is available, but occupied
175+
ChannelAvailable = CANBRD_PRESENT, ///< channel is available and can be used
176+
ChannelNotAvailable = CANBRD_NOT_PRESENT, ///< channel is not available
177+
ChannelNotTestable = CANBRD_NOT_TESTABLE ///< channel is not testable
178+
};
179+
/// \brief CAN channel information
180+
struct SChannelInfo {
181+
int32_t m_nChannelNo; ///< channel no. at actual index in the interface list
182+
char m_szDeviceName[CANPROP_MAX_BUFFER_SIZE]; ///< device name at actual index in the interface list
183+
char m_szDeviceDllName[CANPROP_MAX_BUFFER_SIZE]; ///< file name of the DLL at actual index in the interface list
184+
int32_t m_nLibraryId; ///< library id at actual index in the interface list
185+
char m_szVendorName[CANPROP_MAX_BUFFER_SIZE]; ///< vendor name at actual index in the interface list
186+
};
187+
#if (OPTION_CANAPI_LIBRARY != 0)
188+
/// \brief CAN API library information
189+
struct SLibraryInfo {
190+
int32_t m_nLibraryId; ///< library id at actual index in the vendor list
191+
char m_szVendorName[CANPROP_MAX_BUFFER_SIZE]; ///< vendor name at actual index in the vendor list
192+
char m_szVendorDllName[CANPROP_MAX_BUFFER_SIZE]; ///< file name of the DLL at actual index in the vendor list
193+
};
194+
/// \brief query library information of the first CAN API library in the
195+
/// list of vendors, if any.
196+
//
197+
/// \param[out] info - the library information of the first entry in the list
198+
//
199+
/// \returns true if library information have been successfully read, or
200+
/// false on error.
201+
//
202+
static bool GetFirstLibrary(SLibraryInfo &info);
203+
204+
/// \brief query library information of the next CAN API library in the
205+
/// list of vendors, if any.
206+
//
207+
/// \param[out] info - the library information of the next entry in the list
208+
//
209+
/// \returns true if library information have been successfully read, or
210+
/// false on error.
211+
//
212+
static bool GetNextLibrary(SLibraryInfo &info);
213+
#endif
214+
/// \brief query channel information of the first CAN interface in the
215+
/// list of CAN interfaces, if any.
216+
//
217+
/// \param[in] library - library id of the CAN interface list, or -1 for all vendors
218+
/// \param[out] info - the channel information of the first entry in the list
219+
/// \param[out] param - pointer to channel-specific parameters
220+
//
221+
/// \returns true if channel information have been successfully read, or
222+
/// false on error.
223+
//
224+
#if (OPTION_CANAPI_LIBRARY != 0)
225+
static bool GetFirstChannel(int32_t library, SChannelInfo &info, void *param = NULL);
226+
#else
227+
static bool GetFirstChannel(SChannelInfo &info, void *param = NULL);
228+
#endif
229+
230+
/// \brief query channel information of the first CAN interface in the
231+
/// list of CAN interfaces, if any.
232+
//
233+
/// \param[in] library - library id of the CAN interface list, or -1 for all vendors
234+
/// \param[out] info - the channel information of the next entry in the list
235+
/// \param[out] param - pointer to channel-specific parameters
236+
//
237+
/// \returns true if channel information have been successfully read, or
238+
/// false on error.
239+
//
240+
#if (OPTION_CANAPI_LIBRARY != 0)
241+
static bool GetNextChannel(int32_t library, SChannelInfo &info, void *param = NULL);
242+
#else
243+
static bool GetNextChannel(SChannelInfo &info, void *param = NULL);
244+
#endif
245+
179246
/// \brief probes if the CAN interface (hardware and driver) given by
180247
/// the argument [ 'library' and ] 'channel' is present,
181248
/// and if the requested operation mode is supported by the
@@ -306,7 +373,7 @@ class CANCPP CCanApi {
306373
//
307374
/// \returns 0 if successful, or a negative value on error.
308375
//
309-
virtual CANAPI_Return_t GetBusLoad(uint8_t &load) = 0;
376+
virtual CANAPI_Return_t GetBusLoad(uint8_t &load) = 0; // deprecated
310377

311378
/// \brief retrieves the bit-rate setting of the CAN interface. The
312379
/// CAN controller must be in operation state 'running'.
@@ -351,14 +418,14 @@ class CANCPP CCanApi {
351418
//
352419
/// \returns pointer to a zero-terminated string, or NULL on error.
353420
//
354-
virtual char *GetHardwareVersion() = 0;
421+
virtual char *GetHardwareVersion() = 0; // deprecated
355422

356423
/// \brief retrieves the firmware version of the CAN controller
357424
/// board as a zero-terminated string.
358425
//
359426
/// \returns pointer to a zero-terminated string, or NULL on error.
360427
//
361-
virtual char *GetFirmwareVersion() = 0;
428+
virtual char *GetFirmwareVersion() = 0; // deprecated
362429

363430
/// \brief retrieves version information of the CAN API V3 driver
364431
/// as a zero-terminated string.
@@ -411,4 +478,4 @@ class CANCPP CCanApi {
411478
/// \}
412479
#endif // CANAPI_H_INCLUDED
413480
/// \}
414-
// $Id: CANAPI.h 1013 2021-12-13 21:34:15Z eris $ Copyright (c) UV Software //
481+
// $Id: CANAPI.h 1033 2022-01-11 19:58:04Z makemake $ Copyright (c) UV Software //

Sources/CANAPI/CANAPI_Types.h

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*
33
* CAN Interface API, Version 3 (Data Types and Defines)
44
*
5-
* Copyright (c) 2004-2021 Uwe Vogt, UV Software, Berlin ([email protected])
5+
* Copyright (c) 2004-2022 Uwe Vogt, UV Software, Berlin ([email protected])
66
* All rights reserved.
77
*
88
* This file is part of CAN API V3.
@@ -49,9 +49,9 @@
4949
*
5050
* @brief CAN API V3 for generic CAN Interfaces - Data Types and Defines
5151
*
52-
* @author $Author: makemake $
52+
* @author $Author: haumea $
5353
*
54-
* @version $Rev: 1017 $
54+
* @version $Rev: 1036 $
5555
*
5656
* @addtogroup can_api
5757
* @{
@@ -292,7 +292,7 @@ extern "C" {
292292
#define CANPROP_GET_LIBRARY_ID 4U /**< library id of the library (int32_t) */
293293
#define CANPROP_GET_LIBRARY_VENDOR 5U /**< vendor name of the library (char[256]) */
294294
#define CANPROP_GET_LIBRARY_DLLNAME 6U /**< file name of the library DLL (char[256]) */
295-
#define CANPROP_GET_DEVICE_CHANNEL 10U /**< device type of the CAN interface (int32_t) */
295+
#define CANPROP_GET_DEVICE_TYPE 10U /**< device type of the CAN interface (int32_t) */
296296
#define CANPROP_GET_DEVICE_NAME 11U /**< device name of the CAN interface (char[256]) */
297297
#define CANPROP_GET_DEVICE_VENDOR 12U /**< vendor name of the CAN interface (char[256]) */
298298
#define CANPROP_GET_DEVICE_DLLNAME 13U /**< file name of the CAN interface DLL (char[256]) */
@@ -302,24 +302,23 @@ extern "C" {
302302
#define CANPROP_GET_BITRATE 17U /**< active bit-rate of the CAN controller (can_bitrate_t) */
303303
#define CANPROP_GET_SPEED 18U /**< active bus speed of the CAN controller (can_speed_t) */
304304
#define CANPROP_GET_STATUS 19U /**< current status register of the CAN controller (uint8_t) */
305-
#define CANPROP_GET_BUSLOAD 20U /**< current bus load of the CAN controller (uint8_t) */
305+
#define CANPROP_GET_BUSLOAD 20U /**< current bus load of the CAN controller (uint16_t) */
306306
#define CANPROP_GET_NUM_CHANNELS 21U /**< numbers of CAN channels on the CAN interface (uint8_t) */
307307
#define CANPROP_GET_CAN_CHANNEL 22U /**< active CAN channel on the CAN interface (uint8_t) */
308-
#define CANPROP_GET_CAN_CLOCKS 23U /**< supported CAN clocks (in [Hz]) (int32_t[64]) */
309308
#define CANPROP_GET_TX_COUNTER 24U /**< total number of sent messages (uint64_t) */
310-
#define CANPROP_GET_RX_COUNTER 25U /**< total number of reveiced messages (uint64_t) */
311-
#define CANPROP_GET_ERR_COUNTER 26U /**< total number of reveiced error frames (uint64_t) */
309+
#define CANPROP_GET_RX_COUNTER 25U /**< total number of received messages (uint64_t) */
310+
#define CANPROP_GET_ERR_COUNTER 26U /**< total number of received error frames (uint64_t) */
312311
#define CANPROP_GET_RCV_QUEUE_SIZE 27U /**< maximum number of message the receive queue can hold (uint32_t) */
313312
#define CANPROP_GET_RCV_QUEUE_HIGH 28U /**< maximum number of message the receive queue has hold (uint32_t) */
314313
#define CANPROP_GET_RCV_QUEUE_OVFL 29U /**< overflow counter of the receive queue (uint64_t) */
315-
#define CANPROP_GET_FLT_11BIT_CODE 32U /**< accecptance filter code of 11-bit identifier (int32_t) */
316-
#define CANPROP_GET_FLT_11BIT_MASK 33U /**< accecptance filter mask of 11-bit identifier (int32_t) */
317-
#define CANPROP_GET_FLT_29BIT_CODE 34U /**< accecptance filter code of 29-bit identifier (int32_t) */
318-
#define CANPROP_GET_FLT_29BIT_MASK 35U /**< accecptance filter mask of 29-bit identifier (int32_t) */
319-
#define CANPROP_SET_FLT_11BIT_CODE 36U /**< set value for accecptance filter code of 11-bit identifier (int32_t) */
320-
#define CANPROP_SET_FLT_11BIT_MASK 37U /**< set value for accecptance filter mask of 11-bit identifier (int32_t) */
321-
#define CANPROP_SET_FLT_29BIT_CODE 38U /**< set value for accecptance filter code of 29-bit identifier (int32_t) */
322-
#define CANPROP_SET_FLT_29BIT_MASK 39U /**< set value for accecptance filter mask of 29-bit identifier (int32_t) */
314+
#define CANPROP_GET_FLT_11BIT_CODE 32U /**< acceptance filter code of 11-bit identifier (int32_t) */
315+
#define CANPROP_GET_FLT_11BIT_MASK 33U /**< acceptance filter mask of 11-bit identifier (int32_t) */
316+
#define CANPROP_GET_FLT_29BIT_CODE 34U /**< acceptance filter code of 29-bit identifier (int32_t) */
317+
#define CANPROP_GET_FLT_29BIT_MASK 35U /**< acceptance filter mask of 29-bit identifier (int32_t) */
318+
#define CANPROP_SET_FLT_11BIT_CODE 36U /**< set value for acceptance filter code of 11-bit identifier (int32_t) */
319+
#define CANPROP_SET_FLT_11BIT_MASK 37U /**< set value for acceptance filter mask of 11-bit identifier (int32_t) */
320+
#define CANPROP_SET_FLT_29BIT_CODE 38U /**< set value for acceptance filter code of 29-bit identifier (int32_t) */
321+
#define CANPROP_SET_FLT_29BIT_MASK 39U /**< set value for acceptance filter mask of 29-bit identifier (int32_t) */
323322
#if (OPTION_CANAPI_LIBRARY != 0)
324323
/* - - build-in bit-rate conversion - - - - - - - - - - - - - - - - - */
325324
#define CANPROP_GET_BTR_INDEX 64U /**< bit-rate as CiA index (int32_t) */
@@ -369,25 +368,26 @@ extern "C" {
369368
#define CANPROP_GET_VENDOR_NAME 227U /**< get vendor name at actual index in the vendor list (char[256]) */
370369
#define CANPROP_GET_VENDOR_DLLNAME 228U /**< get file name of the DLL at actual index in the vendor list (char[256]) */
371370
#endif
372-
#define CANPROP_SET_FIRST_CHANNEL 240U /**< set index to the first entry in the interface list (int32_t) */
371+
#define CANPROP_SET_FIRST_CHANNEL 240U /**< set index to the first entry in the interface list (int32_t or NULL) */
373372
#define CANPROP_SET_NEXT_CHANNEL 241U /**< set index to the next entry in the interface list (NULL) */
374373
#define CANPROP_GET_CHANNEL_NO 242U /**< get channel no. at actual index in the interface list (int32_t) */
375374
#define CANPROP_GET_CHANNEL_NAME 243U /**< get channel name at actual index in the interface list (char[256]) */
376375
#define CANPROP_GET_CHANNEL_DLLNAME 244U /**< get file name of the DLL at actual index in the interface list (char[256]) */
377376
#define CANPROP_GET_CHANNEL_VENDOR_ID 245U /**< get library id at actual index in the interface list (int32_t) */
378377
#define CANPROP_GET_CHANNEL_VENDOR_NAME 246U /**< get vendor name at actual index in the interface list (char[256]) */
379378
/* - - search path for JSON files (for C++ wrapper classes) - - - - - */
379+
#if (OPTION_CANAPI_LIBRARY != 0)
380380
#define CANPROP_SET_SEARCH_PATH 253U /**< set search path for interface configuration files (char[256]) */
381+
#endif
381382
/* - - access to device handle (for C++ wrapper classes) - - - - - - - */
382383
#define CANPROP_GET_CPP_BACKDOOR 255U /**< get device handle (int32_t) */
383384
/* - - access to vendor-specific properties - - - - - - - - - - - - - */
384-
#define CANPROP_GET_VENDOR_PROP 256U /**< get a vendor-specific property value (void*) */
385-
#define CANPROP_SET_VENDOR_PROP 512U /**< set a vendor-specific property value (void*) */
385+
#define CANPROP_GET_VENDOR_PROP 256U /**< offset to get a vendor-specific property value (void*) */
386+
#define CANPROP_SET_VENDOR_PROP 512U /**< offset to set a vendor-specific property value (void*) */
386387
#define CANPROP_VENDOR_PROP_RANGE 256U /**< range for vendor-specific property values */
387388
#define CANPROP_MAX_BUFFER_SIZE 256U /**< max. buffer size for property values */
388389
#define CANPROP_MAX_STRING_LENGTH 1024U /**< max. length of a formatted message */
389390
/* - - aliases (legacy names) - - - - - - - - - - - - - - - - - - - - */
390-
#define CANPROP_GET_DEVICE_TYPE CANPROP_GET_DEVICE_CHANNEL
391391
#define CANPROP_GET_CHANNEL_TYPE CANPROP_GET_CHANNEL_NO
392392
#define CANPROP_GET_RCV_QUEUE_MAX CANPROP_GET_RCV_QUEUE_SIZE
393393
/** @} */

Sources/CANAPI/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
_Copyright &copy; 2004-2022 Uwe Vogt, UV Software, Berlin ([email protected])_ \
44
_All rights reserved._
55

6-
Version $Rev: 1020 $
6+
Version $Rev: 1036 $
77

88
# A CAN Interface Wrapper Specification
99

Sources/PeakCAN.cpp

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@
4949
#ifdef _MSC_VER
5050
#define VERSION_MAJOR 0
5151
#define VERSION_MINOR 4
52-
#define VERSION_PATCH 2
52+
#define VERSION_PATCH 3
5353
#else
5454
#define VERSION_MAJOR 0
5555
#define VERSION_MINOR 2
56-
#define VERSION_PATCH 2
56+
#define VERSION_PATCH 3
5757
#endif
5858
#define VERSION_BUILD BUILD_NO
5959
#define VERSION_STRING TOSTRING(VERSION_MAJOR) "." TOSTRING(VERSION_MINOR) "." TOSTRING(VERSION_PATCH) " (" TOSTRING(BUILD_NO) ")"
@@ -138,6 +138,50 @@ CPeakCAN::~CPeakCAN() {
138138
(void)TeardownChannel();
139139
}
140140

141+
EXPORT
142+
bool CPeakCAN::GetFirstChannel(SChannelInfo &info, void *param) {
143+
bool result = false;
144+
memset(&info, 0, sizeof(SChannelInfo));
145+
info.m_nChannelNo = (-1);
146+
// set index to the first entry in the interface list (if any)
147+
CANAPI_Return_t rc = can_property((-1), CANPROP_SET_FIRST_CHANNEL, NULL, 0U);
148+
if (CANERR_NOERROR == rc) {
149+
// get channel no, device name and device DLL name at actual index in the interface list
150+
if (((can_property((-1), CANPROP_GET_CHANNEL_NO, (void*)&info.m_nChannelNo, sizeof(int32_t))) == 0) &&
151+
((can_property((-1), CANPROP_GET_CHANNEL_NAME, (void*)&info.m_szDeviceName, CANPROP_MAX_BUFFER_SIZE)) == 0) &&
152+
((can_property((-1), CANPROP_GET_CHANNEL_DLLNAME, (void*)&info.m_szDeviceDllName, CANPROP_MAX_BUFFER_SIZE)) == 0)) {
153+
// we know the library id and its vendor already
154+
info.m_nLibraryId = PCAN_LIB_ID;
155+
strncpy(info.m_szVendorName, PCAN_LIB_VENDOR, CANPROP_MAX_BUFFER_SIZE-1);
156+
result = true;
157+
}
158+
}
159+
(void)param;
160+
return result;
161+
}
162+
163+
EXPORT
164+
bool CPeakCAN::GetNextChannel(SChannelInfo &info, void *param) {
165+
bool result = false;
166+
memset(&info, 0, sizeof(SChannelInfo));
167+
info.m_nChannelNo = (-1);
168+
// set index to the next entry in the interface list (if any)
169+
CANAPI_Return_t rc = can_property((-1), CANPROP_SET_NEXT_CHANNEL, NULL, 0U);
170+
if (CANERR_NOERROR == rc) {
171+
// get channel no, device name and device DLL name at actual index in the interface list
172+
if (((can_property((-1), CANPROP_GET_CHANNEL_NO, (void*)&info.m_nChannelNo, sizeof(int32_t))) == 0) &&
173+
((can_property((-1), CANPROP_GET_CHANNEL_NAME, (void*)&info.m_szDeviceName, CANPROP_MAX_BUFFER_SIZE)) == 0) &&
174+
((can_property((-1), CANPROP_GET_CHANNEL_DLLNAME, (void*)&info.m_szDeviceDllName, CANPROP_MAX_BUFFER_SIZE)) == 0)) {
175+
// we know the library id and its vendor already
176+
info.m_nLibraryId = PCAN_LIB_ID;
177+
strncpy(info.m_szVendorName, PCAN_LIB_VENDOR, CANPROP_MAX_BUFFER_SIZE-1);
178+
result = true;
179+
}
180+
}
181+
(void)param;
182+
return result;
183+
}
184+
141185
EXPORT
142186
CANAPI_Return_t CPeakCAN::ProbeChannel(int32_t channel, const CANAPI_OpMode_t &opMode, const void *param, EChannelState &state) {
143187
// test the CAN interface (hardware and driver)

0 commit comments

Comments
 (0)