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.3 #31

Merged
merged 31 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8d6abb2
Set version numbers for next release
mac-can Apr 9, 2024
3fec558
Add common file Version.h to the project
mac-can Apr 9, 2024
80cf86e
Update Makefiles
mac-can Apr 9, 2024
233df4f
Update CAN API V3 sources to rev. 1270
mac-can Apr 15, 2024
c84b4b6
Remove unused class attributes
mac-can Apr 15, 2024
61e56c0
Squashed commit of the following:
mac-can Apr 16, 2024
4fa3e4c
Rework TouCAN USB command interface
mac-can Apr 16, 2024
dc98c8c
Implement acceptance filtering
mac-can Apr 16, 2024
27b477f
Add test suites for acceptance filtering
mac-can Apr 16, 2024
480f88d
Update README.md
mac-can Apr 16, 2024
e596814
Update CAN API V3 testing sources to rev. 1272
mac-can Apr 16, 2024
fd5c40b
Update build_no.sh
mac-can Apr 16, 2024
8bc3d9e
Update utility `can_test`
mac-can Apr 18, 2024
5d8095c
Update utility `can_moni`
mac-can Apr 18, 2024
7832a87
Update CAN API V3 testing sources to rev. 1272
mac-can Apr 18, 2024
d91a7f6
Update Deployment.md
mac-can Apr 18, 2024
d0b2dc8
Update README.md
mac-can Apr 18, 2024
93115f8
Merge branch 'main' into development
mac-can Apr 18, 2024
ecb2c12
Plastic surgery
mac-can Apr 20, 2024
60e9dc0
Create .gitattributes
mac-can Apr 20, 2024
3746348
Fix a bug with macro `DLC2LEN`
mac-can Apr 20, 2024
2e3c18d
Update Makefile
mac-can Apr 20, 2024
81258fb
Update README.md
mac-can Apr 20, 2024
7d356fe
Correct findings from walkthrough
mac-can Apr 21, 2024
c9a05a5
Improve compiler and linker flags
mac-can Apr 21, 2024
19a1e86
Update Python wrapper and examples
mac-can Apr 21, 2024
56c2541
Update README.md
mac-can Apr 21, 2024
017a29f
Update Swift wrapper and examples
mac-can Apr 22, 2024
2dbcd55
Update README.md
mac-can Apr 22, 2024
257bde0
Fix a bug in the Python wrapper
mac-can Apr 24, 2024
1629410
Update README.md
mac-can Apr 24, 2024
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
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -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.

18 changes: 7 additions & 11 deletions Deployment.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### macOS® User-Space Driver for TouCAN USB Interfaces from Rusoku

_Copyright © 2020-2023 Uwe Vogt, UV Software, Berlin ([email protected])_ \
_Copyright © 2020-2024 Uwe Vogt, UV Software, Berlin ([email protected])_ \
_All rights reserved._

# Deployment Rules
Expand All @@ -26,16 +26,12 @@ _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/TouCAN.h`
- `$(PROJROOT)/Sources/TouCAN.cpp`
- `$(PROJROOT)/Sources/Wrapper/can_api.c`
- `$(PROJROOT)/Sources/Version.h`
- `$(PROJROOT)/Sources/Swift/CANAPI.swift`
- `$(PROJROOT)/Libraries/CANAPI/Makefile`<sup>*</sup>
- `$(PROJROOT)/Libraries/TouCAN/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`

Expand Down Expand Up @@ -85,12 +81,12 @@ _All rights reserved._
3. Run the `Makefile` in the project root folder:
- `uv-pc013mac:~ eris$ cd $(PROJROOT)`
- `uv-pc013mac:RusokuCAN eris$ make pristine`
- `uv-pc013mac:RusokuCAN eris$ make BINARY=UNIVERSAL`
- `uv-pc013mac:RusokuCAN eris$ make all BINARY=UNIVERSAL`
- `uv-pc013mac:RusokuCAN eris$ make test`
- `uv-pc013mac:RusokuCAN 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 TouCAN USB device:
- `uv-pc013mac:CANAPI eris$./tou_testing --can_dut1=TouCAN-USB1 --can_dut2=TouCAN-USB2 --gtest_output=xml:TestReport_TouCAN-USB.xml --run_all=YES --smoketest_frames=100000` [...]
Expand All @@ -100,16 +96,16 @@ _All rights reserved._
- `$(PROJROOT)/Binaries/*.*`
- `$(PROJROOT)/Includes/*.*`
- `$(PROJROOT)/README.md`
- `$(PROJROOT)/LICENSE`
- `$(PROJROOT)/LICENSE.*`
8. Double check and update the [`README.md`](https://github.com/mac-can/RusokuCAN/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/RusokuCAN) repo.
2. Fill out all required fields:
- Tag version: e.g `v0.2.6` (cf. semantic versioning)
- Tag version: e.g `v0.3` (cf. semantic versioning)
- Target: `main` (default branch)
- Release title: e.g. `Release of November 12, 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
2 changes: 1 addition & 1 deletion Examples/C++/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
BINARIES = ../../Binaries
INCLUDES = -I../../INCLUDES
INCLUDES = -I../../Includes

TARGET1 = can_recv
SOURCE1 = $(TARGET1).cpp $(BINARIES)/libTouCAN.a
Expand Down
170 changes: 162 additions & 8 deletions Examples/Python/CANAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# CAN Interface API, Version 3 (Python Wrapper)
#
# Copyright (c) 2005-2023 Uwe Vogt, UV Software, Berlin ([email protected])
# Copyright (c) 2005-2024 Uwe Vogt, UV Software, Berlin ([email protected])
# 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 @@ -52,9 +52,9 @@
Interface API for various CAN interfaces from different
vendors running under multiple operating systems.

$Author: makemake $
$Author: quaoar $

$Rev: 1198 $
$Rev: 1278 $
"""
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': 3, 'patch': 1}

# CAN Identifier Ranges
#
Expand Down Expand Up @@ -122,6 +122,13 @@
(49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64): c_uint8(0xF)
}

# CAN Acceptance Filter: (code ^ id) & mask == 0
#
CANACC_CODE_11BIT = 0x000 # mask for 11-bit acceptance code
CANACC_MASK_11BIT = 0x000 # mask for 11-bit acceptance mask
CANACC_CODE_29BIT = 0x00000000 # mask for 29-bit acceptance code
CANACC_MASK_29BIT = 0x00000000 # mask for 29-bit acceptance mask

# CAN 2.0 Predefined Bit-rates (as index acc. CiA)
#
CANBTR_INDEX_1M = c_int32(0) # bit-rate: 1000 kbit/s
Expand Down Expand Up @@ -210,8 +217,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 +645,133 @@ def bitrate(self):
print('+++ exception: {}'.format(e))
raise

def filter11bit(self, code, mask):
"""
sets a 11-bit filter for the CAN controller.

:param code: 11-bit code for the filter (or None)
:param mask: 11-bit mask for the filter (or None)
:return: result, code, mask
result: 0 if successful, or a negative value on error
code: 11-bit code for the filter
mask: 11-bit mask for the filter
"""
try:
# set the 11-bit filter (if code or mask are not None)
if code is not None or mask is not None:
__filter = c_uint64(0)
if code is not None:
__filter.value = code << 32
if mask is not None:
__filter.value |= mask & 0xFFFFFFFF
result = self.__m_library.can_property(self.__m_handle, 42, byref(__filter), 8)
if result < 0:
return int(result), None, None
# get the 11-bit filter
__value = c_uint64(0)
result = self.__m_library.can_property(self.__m_handle, 40, byref(__value), 8)
if result < 0:
return int(result), None, None
return int(result), int(__filter.value >> 32), int(__filter.value & 0xFFFFFFFF)
except Exception as e:
print('+++ exception: {}'.format(e))
raise

def filter29bit(self, code, mask):
"""
sets a 29-bit filter for the CAN controller.

:param code: 29-bit code for the filter (or None)
:param mask: 29-bit mask for the filter (or None)
:return: result, code, mask
result: 0 if successful, or a negative value on error
code: 29-bit code for the filter
mask: 29-bit mask for the filter
"""
try:
# set the 29-bit filter (if code or mask are not None)
if code is not None or mask is not None:
__filter = c_uint64(0)
if code is not None:
__filter.value = code << 32
if mask is not None:
__filter.value |= mask & 0xFFFFFFFF
result = self.__m_library.can_property(self.__m_handle, 43, byref(__filter), 8)
if result < 0:
return int(result), None, None
# get the 29-bit filter
__value = c_uint64(0)
result = self.__m_library.can_property(self.__m_handle, 41, byref(__value), 8)
if result < 0:
return int(result), None, None
return int(result), int(__filter.value >> 32), int(__filter.value & 0xFFFFFFFF)
except Exception as e:
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 +838,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 All @@ -715,6 +851,20 @@ def len2dlc(length):
else:
print('>>> can.status() >>> 0x{:02X}'.format(status.byte))

# set acceptance filter
code = CANACC_CODE_11BIT
mask = CANACC_MASK_11BIT
print('>>> can.filter11bit(0x{:03X}, 0x{:03X})'.format(code, mask))
res, code, mask = can.filter11bit(code=code, mask=mask)
if res < CANERR_NOERROR:
print('+++ error: can.filter11bit returned {}'.format(res))
code = CANACC_CODE_29BIT
mask = CANACC_MASK_29BIT
print('>>> can.filter29bit(0x{:08X}, 0x{:08X})'.format(code, mask))
res, code, mask = can.filter29bit(code=code, mask=mask)
if res < CANERR_NOERROR:
print('+++ error: can.filter29bit returned {}'.format(res))

# start the CAN controller
if bitRate.index > 0: # FIXME: Expected type 'int', got 'c_int32[int]' instead
print('>>> can.start([{},[{},{},{},{},{}],[{},{},{},{},])'.format(bitRate.btr.frequency,
Expand Down Expand Up @@ -753,6 +903,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 +916,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 1278 2024-04-23 08:34:36Z quaoar $ *** (c) UV Software, Berlin ***
#
19 changes: 19 additions & 0 deletions Examples/Python/can_recv.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,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 All @@ -67,6 +68,20 @@ def sigterm(signo, frame):
else:
print('>>> can.status() >>> 0x{:02X}'.format(status.byte))

# set acceptance filter
code = 0x70F #CANACC_CODE_11BIT
mask = 0x0F0 #CANACC_MASK_11BIT
mac-can marked this conversation as resolved.
Show resolved Hide resolved
print('>>> can.filter11bit(0x{:03X}, 0x{:03X})'.format(code, mask))
res, code, mask = can.filter11bit(code=code, mask=mask)
if res < CANERR_NOERROR:
print('+++ error: can.filter11bit returned {}'.format(res))
code = CANACC_CODE_29BIT
mask = CANACC_MASK_29BIT
print('>>> can.filter29bit(0x{:08X}, 0x{:08X})'.format(code, mask))
res, code, mask = can.filter29bit(code=code, mask=mask)
if res < CANERR_NOERROR:
print('+++ error: can.filter29bit returned {}'.format(res))

# start the CAN controller
if int(bitRate.index) > 0: # FIXME: Expected type 'int', got 'c_int32[int]' instead
print('>>> can.start([{},[{},{},{},{},{}],[{},{},{},{},])'.format(bitRate.btr.frequency,
Expand Down Expand Up @@ -147,6 +162,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
5 changes: 5 additions & 0 deletions Examples/Python/can_send.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,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 @@ -137,6 +138,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
Loading
Loading