Skip to content

Commit

Permalink
Merge pull request mac-can#15 from mac-can/development
Browse files Browse the repository at this point in the history
Release candidate 1 for version 0.1.2
  • Loading branch information
mac-can authored Apr 22, 2024
2 parents 584f16f + d07bb6a commit 5b43ec4
Show file tree
Hide file tree
Showing 79 changed files with 1,054 additions and 952 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/msbuild-x64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ jobs:
working-directory: ${{env.GITHUB_WORKSPACE}}
# Add additional options to the MSBuild command line here (like platform or verbosity level).
# See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference
run: ${{env.SOLUTION_FILE_PATH}}\x64_build.bat NOVARS NOTRIAL
run: ${{env.SOLUTION_FILE_PATH}}\x64_build.bat NOVARS NOTRIAL NODEBUG
76 changes: 72 additions & 4 deletions Examples/Python/CANAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@
Interface API for various CAN interfaces from different
vendors running under multiple operating systems.
$Author: haumea $
$Author: makemake $
$Rev: 1258 $
$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': 1}

# CAN Identifier Ranges
#
Expand Down Expand Up @@ -638,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()
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()
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 @@ -704,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 @@ -754,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 @@ -763,5 +831,5 @@ def len2dlc(length):
# have a great time
print('Bye, bye!')

# * $Id: CANAPI.py 1258 2024-03-19 21:35:15Z haumea $ *** (c) UV Software, Berlin ***
# * $Id: CANAPI.py 1274 2024-04-21 17:34:21Z makemake $ *** (c) UV Software, Berlin ***
#
5 changes: 5 additions & 0 deletions Examples/Python/can_recv.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def sigterm(signo, frame):
print(CANAPI.version())
print('>>> can = CANAPI(' + lib + ')')
can = CANAPI(lib)
print(can.software())

# serial port settings
port = SerialPort()
Expand Down Expand Up @@ -159,6 +160,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 @@ -71,6 +71,7 @@ def sigterm(signo, frame):
print(CANAPI.version())
print('>>> can = CANAPI(' + lib + ')')
can = CANAPI(lib)
print(can.software())

# serial port settings
port = SerialPort()
Expand Down Expand Up @@ -149,6 +150,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
87 changes: 36 additions & 51 deletions Libraries/CANAPI/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ current_OS := $(patsubst MSYS%,MinGW,$(current_OS))

MAJOR = 0
MINOR = 1
PATCH = 1
PATCH = 2

ifeq ($(PATCH),0)
VERSION = $(MAJOR).$(MINOR)
Expand All @@ -71,6 +71,19 @@ OBJECTS = $(OUTDIR)/can_api.o $(OUTDIR)/can_btr.o \
$(OUTDIR)/slcan.o $(OUTDIR)/serial.o \
$(OUTDIR)/buffer.o $(OUTDIR)/queue.o $(OUTDIR)/logger.o

DEFINES = -DOPTION_CAN_2_0_ONLY=0 \
-DOPTION_CANAPI_DRIVER=1 \
-DOPTION_CANAPI_RETVALS=1 \
-DOPTION_CANAPI_COMPANIONS=1 \
-DOPTION_CANAPI_DEBUG_LEVEL=0 \
-DOPTION_SERIAL_DEBUG_LEVEL=0 \
-DOPTION_SLCAN_DEBUG_LEVEL=0

HEADERS = -I$(SOURCE_DIR) \
-I$(CANAPI_DIR) \
-I$(SERIAL_DIR) \
-I$(WRAPPER_DIR)


ifeq ($(current_OS),Darwin) # macOS - libUVCANSLC.dylib

Expand All @@ -85,37 +98,21 @@ COMPATIBILITY_VERSION = $(MAJOR).$(MINOR).0

INSTALL = /usr/local/lib

INCLUDE = /usr/local/include

DEFINES = -DOPTION_CAN_2_0_ONLY=0 \
-DOPTION_CANAPI_SERIALCAN_DYLIB=1 \
-DOPTION_CANAPI_DRIVER=1 \
-DOPTION_CANAPI_RETVALS=1 \
-DOPTION_CANAPI_COMPANIONS=1 \
-DOPTION_CANAPI_DEBUG_LEVEL=0 \
-DOPTION_SERIAL_DEBUG_LEVEL=0 \
-DOPTION_SLCAN_DEBUG_LEVEL=0

HEADERS = -I$(SOURCE_DIR) \
-I$(CANAPI_DIR) \
-I$(SERIAL_DIR) \
-I$(WRAPPER_DIR)

LIBRARIES = -lpthread
DEFINES += -DOPTION_CANAPI_SERIALCAN_DYLIB=1

CFLAGS += -O2 -Wall -Wno-parentheses \
CFLAGS += -O2 -Wall -Wextra -Wno-parentheses \
-fno-strict-aliasing \
$(DEFINES) \
$(HEADERS)

CXXFLAGS += -g -Wall -Wextra -pthread \
CXXFLAGS += -O2 -g -Wall -Wextra -pthread \
$(DEFINES) \
$(HEADERS)

LDFLAGS += -nostartfiles -dynamiclib -fvisibility=hidden \
-install_name @rpath/$(INSTALL_NAME) \
-current_version $(CURRENT_VERSION) \
-compatibility_version $(COMPATIBILITY_VERSION)
LDFLAGS += -nostartfiles -dynamiclib -fvisibility=hidden \
-Wl,-install_name,@rpath/$(INSTALL_NAME) \
-Wl,-current_version,$(CURRENT_VERSION) \
-Wl,-compatibility_version,$(COMPATIBILITY_VERSION)

LTFLAGS += -static

Expand All @@ -125,12 +122,15 @@ CXXFLAGS += -arch arm64 -arch x86_64
LDFLAGS += -arch arm64 -arch x86_64
endif

LIBRARIES = -lpthread

CXX = clang++
CC = clang
LD = clang
LT = libtool
endif


ifeq ($(current_OS),$(filter $(current_OS),Linux Cygwin)) # linux - libuvcanslc.so.1

LIBRARY = libuvcanslc
Expand All @@ -141,43 +141,30 @@ STATIC = $(LIBRARY).a

INSTALL = /usr/local/lib

INCLUDE = /usr/local/include

DEFINES = -DOPTION_CAN_2_0_ONLY=0 \
-DOPTION_CANAPI_SERIALCAN_SO=1 \
-DOPTION_CANAPI_DRIVER=1 \
-DOPTION_CANAPI_RETVALS=1 \
-DOPTION_CANAPI_COMPANIONS=1 \
-DOPTION_CANAPI_DEBUG_LEVEL=0 \
-DOPTION_SERIAL_DEBUG_LEVEL=0 \
-DOPTION_SLCAN_DEBUG_LEVEL=0
DEFINES += -DOPTION_CANAPI_SERIALCAN_SO=1

HEADERS = -I$(SOURCE_DIR) \
-I$(CANAPI_DIR) \
-I$(SERIAL_DIR) \
-I$(WRAPPER_DIR)

CFLAGS += -fPIC -O2 -Wall -Wno-parentheses \
CFLAGS += -fPIC -O2 -Wall -Wextra -Wno-parentheses \
-fno-strict-aliasing \
$(DEFINES) \
$(HEADERS)

LIBRARIES = -lpthread

CXXFLAGS += -fPIC -g -Wall -Wextra -pthread \
CXXFLAGS += -fPIC -O2 -g -Wall -Wextra -pthread\
$(DEFINES) \
$(HEADERS)

LDFLAGS += --shared -Wl,-soname,$(SONAME) -lc
LDFLAGS += --shared -Wl,-soname,$(SONAME)

ARFLAGS = r

LIBRARIES = -lc -lpthread

CXX = g++
CC = gcc
LD = gcc
AR = ar
endif


RM = rm -f
CP = cp -f
LN = ln -s
Expand Down Expand Up @@ -220,9 +207,10 @@ ifeq ($(current_OS),Darwin)
$(RM) $(BINDIR)/*.dylib $(BINDIR)/*.a
endif
ifeq ($(current_OS),$(filter $(current_OS),Linux Cygwin))
$(RM) *.so *.a $(OUTDIR)/*.o $(OUTDIR)/*.d
$(RM) $(BINDIR)/*.so $(BINDIR)/*.a
$(RM) *.so.* *.a $(OUTDIR)/*.o $(OUTDIR)/*.d
$(RM) $(BINDIR)/*.so.* $(BINDIR)/*.a
endif
$(RM) $(INCDIR)/*.h

install:
@echo "Copying library file..."
Expand Down Expand Up @@ -262,14 +250,11 @@ $(STATIC): $(OBJECTS)
ifeq ($(current_OS),Darwin)
$(LT) $(LTFLAGS) -o $@ $(OBJECTS)
@lipo -archs $@
$(CP) $(STATIC) $(BINDIR)
@echo "\033[1mTarget '"$@"' successfully build\033[0m"
endif
ifeq ($(current_OS),$(filter $(current_OS),Linux Cygwin))
else
$(AR) $(ARFLAGS) $@ $(OBJECTS)
endif
$(CP) $(STATIC) $(BINDIR)
@echo "\033[1mTarget '"$@"' successfully build\033[0m"
endif

$(TARGET): $(OBJECTS)
$(LD) $(LDFLAGS) -o $@ $(OBJECTS) $(LIBRARIES)
Expand Down
File renamed without changes.
Binary file modified Libraries/CANAPI/uvcanslc.rc
Binary file not shown.
2 changes: 1 addition & 1 deletion Libraries/CANAPI/uvcanslc.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@
<ClInclude Include="..\..\Sources\Wrapper\can_defs.h" />
<ClInclude Include="Sources\framework.h" />
<ClInclude Include="Sources\pch.h" />
<ClInclude Include="Sources\resource.h" />
<ClInclude Include="resource.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\Sources\CANAPI\can_btr.c">
Expand Down
2 changes: 1 addition & 1 deletion Libraries/CANAPI/uvcanslc.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<ClInclude Include="Sources\pch.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Sources\resource.h">
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\Sources\CANAPI\can_api.h">
Expand Down
Loading

0 comments on commit 5b43ec4

Please sign in to comment.