Skip to content

Commit

Permalink
Merge pull request #12 from uv-software/development
Browse files Browse the repository at this point in the history
Release Candidate 1 for Version 0.4 SR7
  • Loading branch information
uv-software authored Nov 8, 2023
2 parents ac17786 + f287703 commit 26fb704
Show file tree
Hide file tree
Showing 36 changed files with 624 additions and 192 deletions.
43 changes: 21 additions & 22 deletions Deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ _All rights reserved._

### Preparation

1. Update the PCANBasic DLL in `$(PROJROOT)\Sources\PCANBasic` from PEAK�s website
when required and commit them with commit comment:
1. If necessary, update the PCANBasic DLL in `$(PROJROOT)\Sources\PCANBasic`
from PEAK's website and commit it with commit comment:
- `Update PEAK's PCANBasic DLL (version `_n_`.`_n_`.`_n_`)` \
`- `_list of major changes (optional)_
2. Update the CAN API V3 sources in `$(PROJROOT)\Sources\CANAPI` from SVN repo
when required and commit them with commit comment:
2. If necessary, update the CAN API V3 sources in `$(PROJROOT)\Sources\CANAPI`
from the SVN repo and commit them with commit comment:
- `Update CAN API V3 sources to rev. `_nnn_ \
`- `_list of major changes (optional)_
3. Update the CAN API V3 testing sources in `$(PROJROOT)\Tests` from SVN repo
when required and commit them with commit comment:
3. If necessary, update the CAN API V3 testing sources in `$(PROJROOT)\Tests`
from the SVN repo and commit them with commit comment:
- `Update CAN API V3 testing sources to rev. `_nnn_ \
`- `_list of major changes (optional)_
4. Check and update the version and date information in the following files:
Expand All @@ -37,28 +37,28 @@ _All rights reserved._
### Procedure

1. Check the working directory for uncommitted changes.
- _**There should not be any uncommitted change.**_
- _If there are uncommitted changes then commit them or revert them._
- _**There should not be any uncommitted changes.**_
- _If there are uncommitted changes then commit or undo them._
2. Open the trial program with Visual Studio and run a code analysis.
- _**There should not be any serious finding.**_
- _If there are findings then fix them or create an issue in the repo._
3. Run `x86_build.bat` and `x64_build.bat` in the project root directory.
- _**There should be absolute no compiler or linker error!**_
- _**There should be absolutely no compiler or linker error!**_
- _If there are compiler or linker warnings then think twice._
4. Try out the trial program with different options.
- _**There should be no crash, hangup, or any other error.**_
- _If there is an error then fix it or create an issue in the repo._
5. Try out the utilities with different options.
- _**There should be no crash, hangup, or any other error.**_
- _If there is an error then fix it or create an issue in the repo._
6. Build and try out the examples (repair them if necessary);
6. Build and try out the examples (fix them if necessary);
- `$(PROJROOT)\Examples\C++`
- `$(PROJROOT)\Examples\Python`

### Pull Request

1. Update the `README.md` (e.g. development environment, supported devices, etc.).
2. Push the feature branch onto the remote repo.
2. Push the feature branch to the remote repo.
3. Create a pull request and name it somehow like '**Release Candidate _n_ for** ...'.
4. Review the changes and merge the feature branch into the default branch.

Expand All @@ -77,18 +77,18 @@ _All rights reserved._
4. Build the CAN API V3 GoogleTest program:
- `C:\Users\haumea>cd C:\Projects\CAN\Drivers\PeakCAN\Tests`
- `C:\Projects\CAN\Drivers\PeakCAN\Tests>x86_build.bat`
5. Run the CAN API V3 GoogleTest with two PCAN-USB device:
5. Run the CAN API V3 GoogleTest program with two PCAN-USB devices:
- `C:\Projects\CAN\Drivers\PeakCAN\Tests>Debug\pcb_testing --can_dut1=PCAN-USB1 --can_dut2=PCAN-USB2 --gtest_output=xml:TestReport_PCAN-USB.xml --run_all=YES --smoketest_frames=100000` [...]
- _If there is any error then **stop** here or create an issue for each error in the repo._
- Copy the test report into the binaries directory `$(PROJROOT)\Binaries`.
6. Run the CAN API V3 GoogleTest with two PCAN-USB FD device:
- Copy the test report into the binary's directory `$(PROJROOT)\Binaries`.
6. Run the CAN API V3 GoogleTest program with two PCAN-USB FD devices:
- `C:\Projects\CAN\Drivers\PeakCAN\Tests>Debug\pcb_testing --can_dut1=PCAN-USB3 --can_dut2=PCAN-USB4 --gtest_output=xml:TestReport_PCAN-USB_FD.xml --run_all=YES --smoketest_frames=100000` [...]
- _If there is any error then **stop** here or create an issue for each error in the repo._
- Copy the test report into the binaries directory `$(PROJROOT)\Binaries`.
6. Run the CAN API V3 GoogleTest with the dual-channel PCAN-USB Pro FD device:
- Copy the test report into the binary's directory `$(PROJROOT)\Binaries`.
6. Run the CAN API V3 GoogleTest program with the dual-channel PCAN-USB Pro FD device:
- `C:\Projects\CAN\Drivers\PeakCAN\Tests>Debug\pcb_testing --can_dut1=PCAN-USB5 --can_dut2=PCAN-USB6 --gtest_output=xml:TestReport_PCAN-USB_Pro_FD.xml --run_all=YES --smoketest_frames=100000` [...]
- _If there is any error then **stop** here or create an issue for each error in the repo._
- Copy the test report into the binaries directory `$(PROJROOT)\Binaries`.
- Copy the test report into the binary's directory `$(PROJROOT)\Binaries`.
7. Pack the artifacts into a .zip-archive, e.g. `artifacts.zip`:
- `$(PROJROOT)\Binaries\*.*`
- `$(PROJROOT)\Includes\*.*`
Expand All @@ -100,20 +100,19 @@ _All rights reserved._

1. Click on `Draft a new release` in the [GitHub](https://github.com/uv-software/PeakCAN-Wrapper) repo.
2. Fill out all required fields:
- Tag version: e.g `v0.4.5` (cf. semantic versioning)
- Tag version: e.g `v0.4.6` (cf. semantic versioning)
- Target: `main` (default branch)
- Release title: e.g. `Release of August 25, 2023`
- Release title: e.g. `Release of November 5, 2023`
- Change-log: list all major changes, e.g. from commit comments
- Assets: drag and drop the artifacts archive (see above)
3. Click on `Publish release`.
4. Thats all folks!
4. That's all folks!

### Announcement

1. Create a new post with the change-log in the `mac-can.github.io` repo.
2. Update the PCANBasic page in the `mac-can.github.io` repo.
2. Update the PCANBasic-Wrapper page in the `mac-can.github.io` repo.
3. Post the new release on
[Twitter](https://twitter.com/uv_software),
[LinkedIn](https://linkedin.com/in/uwe-vogt-software),
[Facebook](https://facebook.com/uvsoftware.berlin),
etc.
Binary file modified Libraries/CANAPI/Resource.rc
Binary file not shown.
Binary file modified Libraries/PeakCAN/Resource.rc
Binary file not shown.
6 changes: 3 additions & 3 deletions Sources/CANAPI/CANAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
///
/// \author $Author: haumea $
//
/// \version $Rev: 1143 $
/// \version $Rev: 1212 $
//
/// \defgroup can_api CAN Interface API, Version 3
/// \{
Expand Down Expand Up @@ -357,7 +357,7 @@ class CANCPP CCanApi {
//
/// \returns 0 if successful, or a negative value on error.
//
virtual CANAPI_Return_t ReadMessage(CANAPI_Message_t &message, uint16_t timeout = CANREAD_INFINITE) = 0;
virtual CANAPI_Return_t ReadMessage(CANAPI_Message_t &message, uint16_t timeout = CANWAIT_INFINITE) = 0;

/// \brief retrieves the status register of the CAN interface.
//
Expand Down Expand Up @@ -478,4 +478,4 @@ class CANCPP CCanApi {
/// \}
#endif // CANAPI_H_INCLUDED
/// \}
// $Id: CANAPI.h 1143 2023-08-13 17:50:24Z haumea $ Copyright (c) UV Software //
// $Id: CANAPI.h 1212 2023-10-04 15:41:24Z haumea $ Copyright (c) UV Software //
11 changes: 7 additions & 4 deletions Sources/CANAPI/CANAPI_Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
*
* @author $Author: haumea $
*
* @version $Rev: 1128 $
* @version $Rev: 1212 $
*
* @addtogroup can_api
* @{
Expand Down Expand Up @@ -290,11 +290,14 @@ extern "C" {
#define CANBRD_NOT_TESTABLE (-2) /**< CAN board not testable (e.g. legacy API) */
/** @} */

/** @name Blocking Read
* @brief Control of blocking read
/** @name Blocking Operations
* @brief Control of blocking operations
* @{ */
#define CANREAD_INFINITE 65535U /**< infinite time-out (blocking read) */
#define CANWAIT_INFINITE 65535U /**< infinite time-out (blocking operation) */
#define CANKILL_ALL (-1) /**< to signal all waiting event objects */
/* aliases (legacy names) */
#define CANREAD_INFINITE CANWAIT_INFINITE /**< blocking read */
#define CANWRITE_INFINITE CANWAIT_INFINITE /**< blocking write */
/** @} */

/** @name Property IDs
Expand Down
4 changes: 2 additions & 2 deletions Sources/CANAPI/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
### CAN Interface API, Version 3

_Copyright &copy; 2004-2023 Uwe Vogt, UV Software, Berlin ([email protected])_ \
_Copyright &copy; 2004-2023 Uwe Vogt, UV Software, Berlin ([email protected])_ \
_All rights reserved._

Version $Rev: 1187 $
Version $Rev: 1212 $

# A CAN Interface Wrapper Specification

Expand Down
3 changes: 2 additions & 1 deletion Sources/PCANBasic/PCANBasic.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//
// ------------------------------------------------------------------
// Author : Keneth Wagner
// Last change: 2023-06-01
// Last change: 2023-08-28
//
// Language: ANSI-C
// ------------------------------------------------------------------
Expand Down Expand Up @@ -183,6 +183,7 @@
#define PCAN_ATTACHED_CHANNELS 0x2BU // Get information about PCAN channels attached to a system
#define PCAN_ALLOW_ECHO_FRAMES 0x2CU // Echo messages reception status within a PCAN-Channel
#define PCAN_DEVICE_PART_NUMBER 0x2DU // Get the part number associated to a device
#define PCAN_HARD_RESET_STATUS 0x2EU // Activation status of hard reset processing via CAN_Reset calls

// DEPRECATED parameters
//
Expand Down
4 changes: 2 additions & 2 deletions Sources/PeakCAN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@
#ifdef _MSC_VER
#define VERSION_MAJOR 0
#define VERSION_MINOR 4
#define VERSION_PATCH 6
#define VERSION_PATCH 7
#else
#define VERSION_MAJOR 0
#define VERSION_MINOR 2
#define VERSION_PATCH 6
#define VERSION_PATCH 7
#endif
#define VERSION_BUILD BUILD_NO
#define VERSION_STRING TOSTRING(VERSION_MAJOR) "." TOSTRING(VERSION_MINOR) "." TOSTRING(VERSION_PATCH) " (" TOSTRING(BUILD_NO) ")"
Expand Down
4 changes: 2 additions & 2 deletions Sources/Wrapper/can_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@
#ifdef _MSC_VER
#define VERSION_MAJOR 0
#define VERSION_MINOR 4
#define VERSION_PATCH 6
#define VERSION_PATCH 7
#else
#define VERSION_MAJOR 0
#define VERSION_MINOR 2
#define VERSION_PATCH 6
#define VERSION_PATCH 7
#endif
#define VERSION_BUILD BUILD_NO
#define VERSION_STRING TOSTRING(VERSION_MAJOR) "." TOSTRING(VERSION_MINOR) "." TOSTRING(VERSION_PATCH) " (" TOSTRING(BUILD_NO) ")"
Expand Down
4 changes: 2 additions & 2 deletions Tests/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
### CAN API V3 Testing with GoogleTest

_Copyright &copy; 2004-2023 Uwe Vogt, UV Software, Berlin ([email protected])_ \
_Copyright &copy; 2004-2023 Uwe Vogt, UV Software, Berlin ([email protected])_ \
_All rights reserved._

Version $Rev: 1201 $
Version $Rev: 1219 $

# CAN Interface Wrapper Specification

Expand Down
32 changes: 13 additions & 19 deletions Tests/Sources/Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@
#define MESSAGE(n,i,l,d) do{ }while(0)
#endif

#define DIFF_TIME(t1,t2) (((t1.tv_sec * 1000000000) + t1.tv_nsec) - ((t2.tv_sec * 1000000000) + t2.tv_nsec))

CCanDevice::CCanDevice(int32_t library, int32_t channel, CANAPI_OpMode_t opMode, CANAPI_Bitrate_t bitRate, void *param) {
m_nLibraryId = library;
m_nChannelNo = channel;
Expand Down Expand Up @@ -191,7 +189,7 @@ int32_t CCanDevice::SendAndReceiveFrames(CCanDevice *sender, CCanDevice *receive
struct timespec m0 = {};
struct timespec m1 = {};
// get current time: start of transmission
clock_gettime(CLOCK_MONOTONIC, &t0);
t0 = CTimer::GetTime();
#endif
// send the messages
CProgress progress = CProgress(frames);
Expand Down Expand Up @@ -248,15 +246,15 @@ int32_t CCanDevice::SendAndReceiveFrames(CCanDevice *sender, CCanDevice *receive
}
#if (DEVICE_DEBUG != 0)
// get current time: end of transmission
clock_gettime(CLOCK_MONOTONIC, &t1);
t1 = CTimer::GetTime();
#endif
// finish the plate
int32_t remaining = (int32_t)(frames - n);
#if (0) //defined(_WIN32) || defined(_WIN64)
uint32_t timeout = ((uint32_t)remaining * DEVICE_LOOP_TIMEOUT * CTimer::MSEC); // FIXME: does not work for all bit-rates
uint32_t timeout = ((uint64_t)remaining * DEVICE_LOOP_TIMEOUT * CTimer::MSEC); // FIXME: does not work for all bit-rates
#else
uint32_t timeout = ((TransmissionTime(receiver->GetBitrate(), (remaining + DEVICE_LOOP_EXTRA))
* DEVICE_LOOP_FACTOR) / DEVICE_LOOP_DIVISOR); // bit-rate dependent timeout
uint64_t timeout = (((uint64_t)TransmissionTime(receiver->GetBitrate(), (remaining + DEVICE_LOOP_EXTRA))
* (uint64_t)DEVICE_LOOP_FACTOR) / (uint64_t)DEVICE_LOOP_DIVISOR); // bit-rate dependent timeout
#endif
if (n < frames) {
CTimer timer = CTimer(timeout);
Expand Down Expand Up @@ -300,17 +298,17 @@ int32_t CCanDevice::SendAndReceiveFrames(CCanDevice *sender, CCanDevice *receive
}
#if (DEVICE_DEBUG != 0)
// get current time: end of reception
clock_gettime(CLOCK_MONOTONIC, &t2);
t2 = CTimer::GetTime();
#endif
// return the number of received messages
progress.Clear();
#if (DEVICE_DEBUG != 0)
if (frames > 0) {
std::cout << " " << frames << " total sent frames in " << ((float)TimeDifference(t0, t1) / 1000.f) << "ms";
std::cout << " " << frames << " total sent frames in " << ((float)CTimer::DiffTime(t0, t1) * 1000.f) << "ms";
if (remaining > 0)
std::cout << " + " << remaining << " remaining frames in " << ((float)TimeDifference(t1, t2) / 1000.f) << "ms w/ timeout " << ((float)timeout / 1000.f) << "ms";
std::cout << " + " << remaining << " remaining frames in " << ((float)CTimer::DiffTime(t1, t2) * 1000.f) << "ms w/ timeout " << ((float)timeout / 1000.f) << "ms";
if (remaining > 1)
std::cout << " : reception of " << n << " frames in " << ((float)TimeDifference(m0, m1) / 1000.f) << "ms";
std::cout << " : reception of " << n << " frames in " << ((float)CTimer::DiffTime(m0, m1) * 1000.f) << "ms";
std::cout << std::endl;
}
#endif
Expand Down Expand Up @@ -438,27 +436,23 @@ bool CCanDevice::CompareBitrates(CANAPI_Bitrate_t bitRate1, CANAPI_Bitrate_t bit
return true;
}

uint32_t CCanDevice::TransmissionTime(CANAPI_Bitrate_t bitRate, int32_t frames, uint8_t payload) {
uint64_t CCanDevice::TransmissionTime(CANAPI_Bitrate_t bitRate, int32_t frames, uint8_t payload) {
float time_per_bit = 100.f; // assume the slowest bit-rate (10kbps)
float bits_per_msg = 1.f + 11.f + 7.f + ((float)payload * 8.f) + 15.f + 1.f + 2.f + 7.f + 3.f;

CANAPI_BusSpeed_t speed = {};
if (CCanDevice::MapBitrate2Speed(bitRate, speed) == CCanApi::NoError)
time_per_bit = 1000000.f / speed.nominal.speed;

uint32_t usec = (uint32_t)((float)frames * bits_per_msg * time_per_bit);
uint64_t usec = (uint64_t)((float)frames * bits_per_msg * time_per_bit);

return (usec < 100U) ? 100U : usec; // FIXME: CTimer::Delay calls Sleep(0) if t < 100us
}

long CCanDevice::TimeDifference(struct timespec &start, struct timespec &stop) {
return (long)(DIFF_TIME(stop, start) / 1000);
}

void CCanDevice::ShowTimeDifference(const char *prefix, struct timespec &start, struct timespec &stop) {
if (prefix)
std::cout << prefix << ' ';
std::cout << "dt=" << ((float)TimeDifference(start, stop) / 1000.f) << "ms" << std::endl;
std::cout << "dt=" << ((float)CTimer::DiffTime(start, stop) * 1000.f) << "ms" << std::endl;
}

void CCanDevice::ShowLibrayInformation(const char *prefix) {
Expand Down Expand Up @@ -596,4 +590,4 @@ void CCanDevice::ShowChannelCapabilities(const char* prefix) {
std::cout << std::endl;
}

// $Id: Device.cpp 1185 2023-08-29 10:42:03Z haumea $ Copyright (c) UV Software, Berlin //
// $Id: Device.cpp 1217 2023-10-10 19:28:31Z haumea $ Copyright (c) UV Software, Berlin //
5 changes: 2 additions & 3 deletions Tests/Sources/Device.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ class CCanDevice : public CCanDriver {
// special stuff
static bool CompareMessages(CANAPI_Message_t message1, CANAPI_Message_t message2, bool esiFlag = false);
static bool CompareBitrates(CANAPI_Bitrate_t bitRate1, CANAPI_Bitrate_t bitRate2, bool dataPhase = false);
static uint32_t TransmissionTime(CANAPI_Bitrate_t bitRate, int32_t frames = 1, uint8_t payload = 8U);
static long TimeDifference(struct timespec &start, struct timespec &stop);
static uint64_t TransmissionTime(CANAPI_Bitrate_t bitRate, int32_t frames = 1, uint8_t payload = 8U);
static void ShowTimeDifference(const char *prefix, struct timespec &start, struct timespec &stop);
private:
int32_t SendAndReceiveFrames(CCanDevice *sender, CCanDevice *receiver, int32_t frames);
Expand All @@ -171,4 +170,4 @@ class CCanDevice : public CCanDriver {

#endif // DEVICE_H_INCLUDED

// $Id: Device.h 1185 2023-08-29 10:42:03Z haumea $ Copyright (c) UV Software, Berlin.
// $Id: Device.h 1217 2023-10-10 19:28:31Z haumea $ Copyright (c) UV Software, Berlin.
2 changes: 1 addition & 1 deletion Tests/Sources/Progress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,4 @@ void CCounter::Increment() {
#endif
}

// $Id$ Copyright (c) UV Software, Berlin //
// $Id: Progress.cpp 798 2023-10-07 19:01:13Z makemake $ Copyright (c) UV Software, Berlin //
2 changes: 1 addition & 1 deletion Tests/Sources/Progress.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ class CCounter {

#endif // PROGRESS_H_INCLUDED

// $Id$ Copyright (c) UV Software, Berlin //
// $Id: Progress.h 798 2023-10-07 19:01:13Z makemake $ Copyright (c) UV Software, Berlin //
6 changes: 3 additions & 3 deletions Tests/Sources/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,14 @@
#if (PCBUSB_INIT_DELAY_WORKAROUND != WORKAROUND_DISABLED)
// - When initializing two PCAN-USB devices then a delay of 100ms is required
// before sending messages. The receiver swallows the first few (issue #291)
#define PCBUSB_INIT_DELAY() do { CTimer::Delay(100U * CTimer::MSEC); } while(0)
#define PCBUSB_INIT_DELAY() do { CTimer::Delay((uint64_t)100 * CTimer::MSEC); } while(0)
#else
#define PCBUSB_INIT_DELAY() while(0)
#endif
#if (PCBUSB_QXMTFULL_WORKAROUND != WORKAROUND_DISABLED)
// - Up to now no solution found to catch QXMTFULL event when sending a lot of
// messages back to back with buffered transfer (no acknowledge, issue #101)
#define PCBUSB_QXMT_DELAY() do { CTimer::Delay(0U * CTimer::MSEC); } while(0)
#define PCBUSB_QXMT_DELAY() do { CTimer::Delay((uint64_t)0 * CTimer::MSEC); } while(0)
#else
#define PCBUSB_QXMT_DELAY() while(0)
#endif
Expand Down Expand Up @@ -158,4 +158,4 @@
#endif
#endif // SETTINGS_H_INCLUDED

// $Id: Settings.h 1188 2023-09-01 18:21:43Z haumea $ Copyright (c) UV Software, Berlin.
// $Id: Settings.h 1217 2023-10-10 19:28:31Z haumea $ Copyright (c) UV Software, Berlin.
Loading

0 comments on commit 26fb704

Please sign in to comment.