Skip to content

Commit cede7f7

Browse files
authored
Merge pull request #4 from uv-software/development
Release candidate 2 for version v0.4.2 (service release)
2 parents cd78843 + 19fac04 commit cede7f7

File tree

6 files changed

+25
-16
lines changed

6 files changed

+25
-16
lines changed

Libraries/CANAPI/Resource.rc

0 Bytes
Binary file not shown.

Libraries/PeakCAN/Resource.rc

0 Bytes
Binary file not shown.

Sources/CANAPI/README.md

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

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

88
# A CAN Interface Wrapper Specification
99

@@ -54,7 +54,7 @@ extern int can_bitrate(int handle, can_bitrate_t *bitrate, can_speed_t *speed);
5454
extern int can_property(int handle, uint16_t param, void *value, uint32_t nbyte);
5555

5656
extern char *can_hardware(int handle);
57-
extern char *can_software(int handle);
57+
extern char *can_firmware(int handle);
5858

5959
#if (OPTION_CANAPI_LIBRARY != 0)
6060
extern char *can_library(int handle);

Sources/CANAPI/can_api.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*
33
* CAN Interface API, Version 3 (generic)
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.
@@ -51,7 +51,7 @@
5151
*
5252
* @author $Author: eris $
5353
*
54-
* @version $Rev: 993 $
54+
* @version $Rev: 1020 $
5555
*
5656
* @defgroup can_api CAN Interface API, Version 3
5757
* @{
@@ -120,6 +120,7 @@ typedef int can_handle_t;
120120
* @{ */
121121
#define can_transmit(hnd, msg) can_write(hnd, msg, 0U)
122122
#define can_receive(hnd, msg) can_read(hnd, msg, 0U)
123+
#define can_software(hnd) can_firmware(hnd)
123124
#define can_msg_t can_message_t
124125
/** @} */
125126

@@ -445,7 +446,7 @@ CANAPI char *can_hardware(int handle);
445446
*
446447
* @returns pointer to a zero-terminated string, or NULL on error.
447448
*/
448-
CANAPI char *can_software(int handle);
449+
CANAPI char *can_firmware(int handle);
449450

450451

451452
#if (OPTION_CANAPI_LIBRARY != 0)

Sources/PeakCAN.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
#ifdef _MSC_VER
5050
#define VERSION_MAJOR 0
5151
#define VERSION_MINOR 4
52-
#define VERSION_PATCH 9
52+
#define VERSION_PATCH 2
5353
#else
5454
#define VERSION_MAJOR 0
5555
#define VERSION_MINOR 2
@@ -290,7 +290,7 @@ char *CPeakCAN::GetHardwareVersion() {
290290
EXPORT
291291
char *CPeakCAN::GetFirmwareVersion() {
292292
// retrieve the firmware version of the CAN controller
293-
return can_software(m_Handle);
293+
return can_firmware(m_Handle);
294294
}
295295

296296
EXPORT

Sources/Wrapper/can_api.c

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ char *can_hardware(int handle)
924924
if (can[handle].board == PCAN_NONEBUS) // must be an opened handle
925925
return NULL;
926926

927-
if (CAN_GetValue(can[handle].board, PCAN_CHANNEL_VERSION, (void*)str, 256) != PCAN_ERROR_OK)
927+
if (CAN_GetValue(can[handle].board, PCAN_HARDWARE_NAME, (void*)str, 256) != PCAN_ERROR_OK)
928928
return NULL;
929929
if ((ptr = strchr(str, '\n')) != NULL)
930930
*ptr = '\0';
@@ -933,7 +933,7 @@ char *can_hardware(int handle)
933933
{
934934
if (CAN_GetValue(can[handle].board, PCAN_DEVICE_NUMBER, (void*)&dev, 4) != PCAN_ERROR_OK)
935935
return NULL;
936-
snprintf(hardware, 256, "%s (Device %02lXh)", str, dev);
936+
snprintf(hardware, 256, "%s, Device-Id. %02lXh", str, dev);
937937
}
938938
else
939939
strcpy(hardware, str);
@@ -942,20 +942,28 @@ char *can_hardware(int handle)
942942
}
943943

944944
EXPORT
945-
char *can_software(int handle)
945+
char *can_firmware(int handle)
946946
{
947-
static char software[256] = ""; // software version
948-
char str[256] = "PCAN-Basic API "; // info string
947+
static char firmware[256] = ""; // firmware version
948+
char str[256], *ptr; // info string
949+
char ver[256]; // version
949950

950951
if (!init) // must be initialized
951952
return NULL;
952-
(void)handle; // handle not needed here
953+
if (!IS_HANDLE_VALID(handle)) // must be a valid handle
954+
return NULL;
955+
if (can[handle].board == PCAN_NONEBUS) // must be an opened handle
956+
return NULL;
953957

954-
if (CAN_GetValue(PCAN_NONEBUS, PCAN_API_VERSION, (void*)&str[15], 256-15) != PCAN_ERROR_OK)
958+
if (CAN_GetValue(can[handle].board, PCAN_HARDWARE_NAME, (void*)str, 256) != PCAN_ERROR_OK)
959+
return NULL;
960+
if ((ptr = strchr(str, '\n')) != NULL)
961+
*ptr = '\0';
962+
if (CAN_GetValue(can[handle].board, PCAN_FIRMWARE_VERSION, (void*)ver, 256) != PCAN_ERROR_OK)
955963
return NULL;
956-
strcpy(software, str);
964+
snprintf(firmware, 256, "%s, Firmware %s", str, ver);
957965

958-
return (char*)software; // software version
966+
return (char*)firmware; // firmware version
959967
}
960968

961969
/* ----------- local functions ----------------------------------------

0 commit comments

Comments
 (0)