Skip to content

Commit

Permalink
Merge pull request #17 from mac-can/development
Browse files Browse the repository at this point in the history
Release Candidate 1 for Version 0.2 SR8
  • Loading branch information
mac-can committed Apr 26, 2024
2 parents 77fb4ca + b9589a4 commit 4b57e39
Show file tree
Hide file tree
Showing 91 changed files with 6,664 additions and 3,990 deletions.
5 changes: 5 additions & 0 deletions .gitattributes
@@ -0,0 +1,5 @@
# Auto detect text files and perform LF normalization
* text=auto

# Never modify line endings of bash scripts
*.sh text eol=lf
4 changes: 0 additions & 4 deletions .travis.yml

This file was deleted.

32 changes: 15 additions & 17 deletions Deployment.md
@@ -1,6 +1,6 @@
### macOS® Wrapper Library for PCAN-USB Interfaces from PEAK-System

_Copyright © 2005-2010, 2012-2023 Uwe Vogt, UV Software, Berlin (info@mac-can.com)_ \
_Copyright © 2005-2010, 2012-2024 Uwe Vogt, UV Software, Berlin (info@mac-can.com)_ \
_All rights reserved._

# Deployment
Expand All @@ -26,16 +26,15 @@ _All rights reserved._
- `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:
- `$(PROJROOT)\Sources\Version.h`
- `$(PROJROOT)/Sources/PeakCAN.h`
- `$(PROJROOT)/Sources/PeakCAN.cpp`
- `$(PROJROOT)/Sources/Wrapper\can_api.cpp`
- `$(PROJROOT)/Sources/Wrapper\can_api.c`
- `$(PROJROOT)/Libraries/CANAPI/Makefile`<sup>*</sup>
- `$(PROJROOT)/Libraries/PeakCAN/Makefile`<sup>*</sup>
- `$(PROJROOT)/Utilities/can_moni/Driver.h`
- `$(PROJROOT)/Utilities/can_moni/Makefile`
- `$(PROJROOT)/Utilities/can_moni/README.md`
- `$(PROJROOT)/Utilities/can_test/Driver.h`
- `$(PROJROOT)/Utilities/can_test/Makefile`
- `$(PROJROOT)/Utilities/can_test/README.md`

<sup>*</sup>_) Set variable_ `CURRENT_VERSION` _and_ `COMPATIBILITY_VERSION` _accordingly._
Expand All @@ -60,7 +59,7 @@ _All rights reserved._
7. 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._
8. Build and try out the examples (repair them when necessary);
8. Build and try out the examples (fix them if necessary);
- `$(PROJROOT)/Examples/C++`
- `$(PROJROOT)/Examples/Python`

Expand All @@ -76,40 +75,39 @@ _All rights reserved._
### Preparation

1. Pull or clone the default branch on all development systems.
>>> Don't forget the Linux system! <<<
> Don't forget the Linux system!
2. Double check all version numbers again (see above).
3. Run the `Makefile` in the project root directory:
- `uv-pc013mac:~ eris$ cd $(PROJROOT)`
- `uv-pc013mac:PCBUSB eris$ make pristine`
- `uv-pc013mac:PCBUSB eris$ make BINARY=UNIVERSAL`
- `uv-pc013mac:PCBUSB eris$ make test`
- `uv-pc013mac:PCBUSB eris$ make all BINARY=UNIVERSAL`
- `uv-pc013mac:PCBUSB eris$ sudo make install`
4. Build the CAN API V3 GoogleTest program:
- `uv-pc013mac:~ eris$ cd $(PROJROOT)/Tests/CANAPI`
- `uv-pc013mac:CANAPI eris$ make pristine`
- `uv-pc013mac:CANAPI eris$ make clean`
- `uv-pc013mac:CANAPI eris$ make all`
5. Run the CAN API V3 GoogleTest program with two PCAN-USB devices:
5. Run the CAN API V3 GoogleTest program with two PCAN-USB devices in CAN 2.0 mode:
- `uv-pc013mac:CANAPI eris$./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 binary's directory `$(PROJROOT)/Binaries`.
6. Run the CAN API V3 GoogleTest program with two PCAN-USB FD devices:
- `uv-pc013mac:CANAPI eris$./pcb_testing --can_dut1=PCAN-USB3 --can_dut2=PCAN-USB4 --gtest_output=xml:TestReport_PCAN-USB_FD.xml --run_all=YES --smoketest_frames=100000` [...]
6. Run the CAN API V3 GoogleTest program with two PCAN-USB FD devices in CAN FD mode:
- `uv-pc013mac:CANAPI eris$./pcb_testing --can_dut1=PCAN-USB3 --can_dut2=PCAN-USB4 --can_mode=FDF+BRS --can_bitrate=DEFAULT --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 binary's directory `$(PROJROOT)/Binaries`.
7. Pack the artifacts into a .zip-archive, e.g. `artifacts.zip`:
- `$(PROJROOT)/Binaries/*.*`
- `$(PROJROOT)/Includes/*.*`
- `$(PROJROOT)/README.md`
- `$(PROJROOT)/LICENSE`
8. Double check and update the [`README.md`](https://github.com/mac-can/PCANBasic-Wrapper/blob/main/README.md) on GitHub (or insert just a blank).
- `$(PROJROOT)/LICENSE.*`
8. Double check and update the [`README.md`](https://github.com/mac-can/PCBUSB-Wrapper/blob/main/README.md) on GitHub (or insert just a blank).

### Procedure

1. Click on `Draft a new release` in the [GitHub](https://github.com/mac-can/PCANBasic-Wrapper) repo.
1. Click on `Draft a new release` in the [GitHub](https://github.com/mac-can/PCBUSB-Wrapper) repo.
2. Fill out all required fields:
- Tag version: e.g `v0.2.6` (cf. semantic versioning)
- Tag version: e.g `v0.2.8` (cf. semantic versioning)
- Target: `main` (default branch)
- Release title: e.g. `Release of November 6, 2023`
- Release title: e.g. `Release of January 19, 2038`
- 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`.
Expand Down
20 changes: 10 additions & 10 deletions Examples/C++/Makefile
@@ -1,30 +1,30 @@
OS := $(shell sh -c 'uname 2>/dev/null || echo Unknown OS')

ifeq ($(OS),Darwin) # macOS - libPeakCAN.dylib
LIBRARY = libPeakCAN.a
CXXFLAGS =
ifeq ($(OS),Darwin) # macOS - libPeakCAN.a (C++) and libUVCANPCB.a (C)
LIBRARY1 = libPeakCAN.a
LIBRARY2 = libUVCANPCB.a
CXXFLAGS = -Wall -Wextra -pthread
LDFLAGS = -rpath /usr/local/lib
CXX = clang++
LD = clang++
RM = rm -f
endif
ifeq ($(OS),Linux) # Linux - libpeakcan.so
LIBRARY = libpeakcan.a
CXXFLAGS =
ifeq ($(OS),Linux) # Linux - libpeakcan.a (C++) and libuvcanpcb.a (C)
LIBRARY1 = libpeakcan.a
LIBRARY2 = libuvcanpcb.a
CXXFLAGS = -Wall -Wextra -pthread
LDFLAGS =
CXX = g++
LD = g++
RM = rm -f
endif
BINARIES = ../../Binaries
INCLUDES = ../../Includes

TARGET1 = can_recv
SOURCE1 = $(TARGET1).cpp $(BINARIES)/$(LIBRARY)
SOURCE1 = $(TARGET1).cpp $(BINARIES)/$(LIBRARY1)
DEFINES1 = -DCHANNEL=0x51 -DBAUDRATE=CANBTR_INDEX_250K

TARGET2 = can_send
SOURCE2 = $(TARGET2).cpp $(BINARIES)/$(LIBRARY)
SOURCE2 = $(TARGET2).cpp $(BINARIES)/$(LIBRARY2)
DEFINES2 = -DCHANNEL=0x52 -DBAUDRATE=CANBTR_INDEX_250K


Expand Down
19 changes: 16 additions & 3 deletions Examples/C++/can_recv.cpp
@@ -1,3 +1,15 @@
//
// can_recv.cpp
// PCANBasic-Wrapper
// Receive some CAN messages using the C++ API (PeakCAN.h)
// Library: PeakCAN.dll, libPeakCAN.dylib, libpeakcan.so
//
#ifdef _MSC_VER
//no Microsoft extensions please!
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS 1
#endif
#endif
#include <iostream>
#include <signal.h>
#include <errno.h>
Expand All @@ -16,7 +28,7 @@ static volatile int running = 1;

static CPeakCAN myDriver = CPeakCAN();

int main(int argc, const char * argv[]) {
int main(/*int argc, const char * argv[]*/) {
CANAPI_OpMode_t opMode = {};
opMode.byte = CANMODE_DEFAULT;
CANAPI_Bitrate_t bitrate = {};
Expand Down Expand Up @@ -59,14 +71,15 @@ int main(int argc, const char * argv[]) {
fprintf(stdout, "\n");
}
else if (retVal != CCanApi::ReceiverEmpty) {
fprintf(stderr, "+++ error: read message returned %i\n", retVal);
fprintf(stderr, "+++ error: read message returned %i", retVal);
running = 0;
}
}
std::cout << std::endl;
teardown:
if ((retVal = myDriver.TeardownChannel()) != CCanApi::NoError)
std::cerr << "+++ error: interface could not be shutdown" << std::endl;
std::cerr << "Cheers!" << std::endl;
std::cout << "Cheers!" << std::endl;
return retVal;
}

Expand Down
16 changes: 14 additions & 2 deletions Examples/C++/can_send.cpp
@@ -1,3 +1,15 @@
//
// can_send.cpp
// PCANBasic-Wrapper
// Send some CAN messages using the C API (can_api.h)
// Library: u3canpcb.dll, libUVCANPCB.dylib, libuvcanpcb.so
//
#ifdef _MSC_VER
//no Microsoft extensions please!
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS 1
#endif
#endif
#include <iostream>
#if !defined(_WIN32) && !defined(_WIN64)
#include <unistd.h>
Expand All @@ -15,7 +27,7 @@
#endif
#define FRAMES (CAN_MAX_STD_ID+1)

int main(int argc, const char * argv[]) {
int main(/*int argc, const char * argv[]*/) {
int handle, result, i;
can_bitrate_t bitrate;
can_message_t message;
Expand Down Expand Up @@ -64,6 +76,6 @@ int main(int argc, const char * argv[]) {
end:
if ((result = can_exit(handle)) < CANERR_NOERROR)
std::cerr << "+++ error: interface could not be shutdown" << std::endl;
std::cerr << "Cheers!" << std::endl;
std::cout << "Cheers!" << std::endl;
return result;
}
83 changes: 76 additions & 7 deletions Examples/Python/CANAPI.py
Expand Up @@ -2,7 +2,7 @@
#
# CAN Interface API, Version 3 (Python Wrapper)
#
# Copyright (c) 2005-2023 Uwe Vogt, UV Software, Berlin (info@uv-software.com)
# Copyright (c) 2005-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com)
# All rights reserved.
#
# This file is part of CAN API V3.
Expand Down Expand Up @@ -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 <http://www.gnu.org/licenses/>.
# along with CAN API V3. If not, see <https://www.gnu.org/licenses/>.
#
"""
CAN API V3 Python Wrapper for generic CAN Interfaces.
Expand All @@ -54,7 +54,7 @@
$Author: makemake $
$Rev: 1198 $
$Rev: 1274 $
"""
from ctypes import *
import platform
Expand All @@ -69,7 +69,7 @@

# CAN API V3 - Python Wrapper
#
CAN_API_V3_PYTHON = {'major': 0, 'minor': 2, 'patch': 0}
CAN_API_V3_PYTHON = {'major': 0, 'minor': 2, 'patch': 2}

# CAN Identifier Ranges
#
Expand Down Expand Up @@ -210,8 +210,9 @@

# Control of blocking read
#
CANREAD_INFINITE = c_uint16(65535) # infinite time-out (blocking read)

CANWAIT_INFINITE = 65535 # infinite time-out (blocking operation)
CANREAD_INFINITE = CANWAIT_INFINITE
CANWRITE_INFINITE = CANWAIT_INFINITE

# CAN Status-register
#
Expand Down Expand Up @@ -637,6 +638,69 @@ def bitrate(self):
print('+++ exception: {}'.format(e))
raise

def hardware(self):
"""
retrieves the hardware version of the CAN controller
board as a zero-terminated string.
note: API function 'can_hardware' is marked as deprecated.
:return: version
version: version information as string
"""
try:
self.__m_library.can_hardware.restype = c_char_p
version_c = self.__m_library.can_hardware(self.__m_handle)
if version_c is not None:
return version_c.decode('utf-8')
else:
raise Exception('+++ error: can_hardware returned None')
except Exception as e:
print('+++ exception: {}'.format(e))
raise

def firmware(self):
"""
retrieves the firmware version of the CAN controller
board as a zero-terminated string.
note: API function 'can_firmware' is marked as deprecated.
:return: version
version: version information as string
"""
try:
self.__m_library.can_firmware.restype = c_char_p
version_c = self.__m_library.can_firmware(self.__m_handle)
if version_c is not None:
return version_c.decode('utf-8')
else:
raise Exception('+++ error: can_firmware returned None')
except Exception as e:
print('+++ exception: {}'.format(e))
raise

def software(self):
"""
retrieves version information of the CAN API V3 DLL
as a zero-terminated string.
note: API function 'can_version' is marked as deprecated.
:return: version
version: version information as string
"""
try:
self.__m_library.can_version.restype = c_char_p
version_c = self.__m_library.can_version()
if version_c is not None:
return version_c.decode('utf-8')
else:
raise Exception('+++ error: can_version returned None')
except Exception as e:
print('+++ exception: {}'.format(e))
raise

@staticmethod
def version():
"""
Expand Down Expand Up @@ -703,6 +767,7 @@ def len2dlc(length):
print(CANAPI.version())
print('>>> can = CANAPI(' + lib + ')')
can = CANAPI(lib)
print(can.software())

# initialize the CAN interface
print('>>> can.init({}, 0x{:02X})'.format(chn, opMode.byte))
Expand Down Expand Up @@ -753,6 +818,10 @@ def len2dlc(length):
else:
print('>>> can.status() >>> 0x{:02X}'.format(status.byte))

# print some version information
print('>>> can.hardware() >>> ' + can.hardware())
print('>>> can.firmware() >>> ' + can.firmware())

# shutdown the CAN interface
print('>>> can.exit()')
res = can.exit()
Expand All @@ -762,5 +831,5 @@ def len2dlc(length):
# have a great time
print('Bye, bye!')

# * $Id: CANAPI.py 1198 2023-09-13 08:43:19Z makemake $ *** (c) UV Software, Berlin ***
# * $Id: CANAPI.py 1274 2024-04-21 17:34:21Z makemake $ *** (c) UV Software, Berlin ***
#
6 changes: 6 additions & 0 deletions Examples/Python/can_recv.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
from CANAPI import *
import platform
import argparse
import signal
import sys
Expand Down Expand Up @@ -55,6 +56,7 @@ def sigterm(signo, frame):
print(CANAPI.version())
print('>>> can = CANAPI(' + lib + ')')
can = CANAPI(lib)
print(can.software())

# initialize the CAN interface
print('>>> can.init({}, 0x{:02X})'.format(chn, opMode.byte))
Expand Down Expand Up @@ -147,6 +149,10 @@ def sigterm(signo, frame):
else:
print('>>> can.status() >>> 0x{:02X}'.format(status.byte))

# print some version information
print('>>> can.hardware() >>> ' + can.hardware())
print('>>> can.firmware() >>> ' + can.firmware())

# shutdown the CAN interface
print('>>> can.exit()')
res = can.exit()
Expand Down

0 comments on commit 4b57e39

Please sign in to comment.