Skip to content

Commit

Permalink
Merge branch 'mac-can:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
uv-software authored Mar 31, 2024
2 parents bdea1b1 + 584f16f commit a89075f
Show file tree
Hide file tree
Showing 12 changed files with 95 additions and 84 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Makefile CI
name: macOS Build

on:
push:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# separate terms of service, privacy policy, and support
# documentation.

name: MSBuild
name: MSBuild x64

on:
push:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Trial/*.vcxproj.user
Libraries/CANAPI/.objects
Libraries/CANAPI/*.dylib
Libraries/CANAPI/*.so.*
Libraries/CANAPI/*.a
Libraries/CANAPI/.vs
Libraries/CANAPI/x64
Libraries/CANAPI/x86
Expand All @@ -24,6 +25,7 @@ Libraries/CANAPI/*.vcxproj.user
Libraries/SerialCAN/.objects
Libraries/SerialCAN/*.dylib
Libraries/SerialCAN/*.so.*
Libraries/SerialCAN/*.a
Libraries/SerialCAN/.vs
Libraries/SerialCAN/x64
Libraries/SerialCAN/x86
Expand Down
6 changes: 0 additions & 6 deletions Libraries/CANAPI/.gitignore

This file was deleted.

6 changes: 0 additions & 6 deletions Libraries/SerialCAN/.gitignore

This file was deleted.

22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
### Library for CAN-over-Serial-Line Interfaces (SLCAN Protocol)

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

![macOS Build](https://github.com/mac-can/SerialCAN/actions/workflows/macOS-build.yml/badge.svg)
![MSBuild x64](https://github.com/mac-can/SerialCAN/actions/workflows/msbuild-x64.yml/badge.svg)

# CAN API V3 Library for CAN-over-Serial-Line Interfaces

CAN API V3 is a wrapper specification to have a uniform CAN Interface API for various CAN interfaces from different vendors running under multiple operating systems.

This repo contains the source code for _CAN-over-Serial-Line_ interfaces based on
[Lawicel SLCAN protocol](http://www.can232.com/docs/canusb_manual.pdf).
[Lawicel SLCAN protocol](https://www.canusb.com/products/canusb).
It provides the build environments to build dynamic libraries on macOS®, Linux®, Cygwin® and Windows®,
either as a C++ class library ([_libSerialCAN_](#libSerialCAN)),
or as a _CAN API V3_ driver library ([_libUVCANSLC_](#libUVCANSLC)),
either as a C++ class library ([libSerialCAN](#libSerialCAN)),
or as a _CAN API V3_ driver library ([libUVCANSLC](#libUVCANSLC)),
as well as my beloved utilities [`can_moni`](#can_moni) and [`can_test`](#can_test),
and some C/C++ example programs.

Expand Down Expand Up @@ -132,7 +134,7 @@ Windows® (x64 operating system):
#### macOS Sonoma
- macOS Sonoma (14.4) on a Mac mini (M1, 2020)
- macOS Sonoma (14.4.1) on a Mac mini (M1, 2020)
- Apple clang version 15.0.0 (clang-1500.3.9.4)
- Xcode Version 15.3 (15E204a)
Expand All @@ -148,14 +150,14 @@ Windows® (x64 operating system):
- Apple LLVM version 10.0.0 (clang-1000.11.45.5)
- Xcode Version 10.1 (10B61)
#### Debian Bullseye (11.2)
#### Debian "bookworm" (12.5)
- Debian 4.19.160-2 (2020-11-18) x86_64 GNU/Linux
- gcc (Debian 10.2.1-6) 10.2.1 20210110
- Debian 6.1,76-1 (2024-02-01) x86_64 GNU/Linux
- gcc (Debian 12.2.0-14) 12.2.0
#### Cygwin (64-bit)
- Cygwin 3.5.1-1.x86_64 under Windows 10 Pro
- Cygwin 3.5.1-1.x86_64 2024-02-27 11:54 UTC x86_64 Cygwin
- GNU C/C++ Compiler (GCC) 11.4.0
#### Windows 10 & 11
Expand Down
4 changes: 0 additions & 4 deletions Trial/.gitignore

This file was deleted.

4 changes: 2 additions & 2 deletions Trial/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ endif
LIBRARIES = -lpthread

CHECKER = warning,information
IGNORE = -i can_msg.c -i can_dev.c
IGNORE = -i serial_w.c -i buffer_w.c -i queue_w.c -i logger_w.c -i can_msg.c -i can_dev.c
ifeq ($(HUNTER),BUGS)
CHECKER += --bug-hunting
endif
Expand Down Expand Up @@ -117,7 +117,7 @@ outdir:
@mkdir -p $(OUTDIR)

check:
ifeq ($(current_OS),Darwin) # macOS - libSerialCAN.dylib
ifeq ($(current_OS),Darwin) # macOS - libSerialCAN.dylib
cppcheck --enable=$(CHECKER) --suppressions-list=$(HOME_DIR)/suppress.txt \
-D__APPLE__ $(DEFINES) $(HEADERS) $(IGNORE) $(SOURCE_DIR)
else
Expand Down
20 changes: 6 additions & 14 deletions Utilities/can_moni/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ else
TARGET = can_moni.exe
endif
INSTALL = ~/bin

PROJ_DIR = ../..
HOME_DIR = .
MAIN_DIR = ./Sources
Expand All @@ -37,11 +38,6 @@ CANAPI_DIR = $(PROJ_DIR)/Sources/CANAPI

OBJECTS = $(OUTDIR)/main.o $(OUTDIR)/Timer.o $(OUTDIR)/Message.o $(OUTDIR)/can_msg.o






DEFINES = -DOPTION_CANAPI_DRIVER=1 \
-DOPTION_CANAPI_COMPANIONS=1

Expand All @@ -50,8 +46,11 @@ HEADERS = -I$(MAIN_DIR) \
-I$(DRIVER_DIR) \
-I$(CANAPI_DIR)


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

OBJECTS += $(BINDIR)/libSerialCAN.a

CFLAGS += -O2 -Wall -Wextra -Wno-parentheses \
-fno-strict-aliasing \
$(DEFINES) \
Expand All @@ -61,8 +60,6 @@ CXXFLAGS += -O2 -g -Wall -Wextra -pthread \
$(DEFINES) \
$(HEADERS)



LDFLAGS += -lpthread \
-rpath /usr/local/lib

Expand All @@ -73,19 +70,15 @@ LDFLAGS += -arch arm64 -arch x86_64
endif

LIBRARIES =

CXX = clang++
CC = clang
LD = clang++


else # linux - libserialcan.so

OBJECTS += $(BINDIR)/libserialcan.a





CFLAGS += -O2 -Wall -Wextra -Wno-parentheses \
-fno-strict-aliasing \
$(DEFINES) \
Expand All @@ -99,7 +92,6 @@ LDFLAGS += -lpthread

LIBRARIES =


CXX = g++
CC = gcc
LD = g++
Expand Down Expand Up @@ -143,7 +135,7 @@ install:
$(CP) $(TARGET) $(INSTALL)


$(OUTDIR)/main.o: $(MAIN_DIR)/main.cpp
$(OUTDIR)/main.o: $(MAIN_DIR)/main.cpp $(MAIN_DIR)/main_p.cpp
$(CXX) $(CXXFLAGS) -MMD -MF $*.d -o $@ -c $<

$(OUTDIR)/Timer.o: $(MAIN_DIR)/Timer.cpp
Expand Down
3 changes: 1 addition & 2 deletions Utilities/can_test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ TARGET = can_test
else
TARGET = can_test.exe
endif

INSTALL = ~/bin

PROJ_DIR = ../..
Expand Down Expand Up @@ -136,7 +135,7 @@ install:
$(CP) $(TARGET) $(INSTALL)


$(OUTDIR)/main.o: $(MAIN_DIR)/main.cpp
$(OUTDIR)/main.o: $(MAIN_DIR)/main.cpp $(MAIN_DIR)/main_p.cpp
$(CXX) $(CXXFLAGS) -MMD -MF $*.d -o $@ -c $<

$(OUTDIR)/Timer.o: $(MAIN_DIR)/Timer.cpp
Expand Down
54 changes: 35 additions & 19 deletions x64_build.bat
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
@echo off

rem parse arguments: [[NOVARS] NOTRIAL]
if "%1" == "NOVARS" (
set VCVARS="False"
SHIFT
) else (
set VCVARS="True"
)
if "%1" == "NOTRIAL" (
set TRIAL="False"
SHIFT
) else (
set TRIAL="True"
)
set VCVARS="True"
set TRIAL="True"
set LIBD="False"

rem parse arguments: [NOVARS] [NOTRIAL] [DEBUG]
:LOOP
if "%1" == "NOVARS" set VCVARS="False"
if "%1" == "NOTRIAL" set TRIAL="False"
if "%1" == "DEBUG" set LIBD="True"
SHIFT
if not "%1" == "" goto LOOP

rem set MSBuild environment variables
if %VCVARS% == "True" (
Expand All @@ -37,18 +35,26 @@ if errorlevel 1 goto end
call msbuild.exe .\Libraries\CANAPI\uvcanslc.vcxproj /t:Clean;Build /p:"Configuration=Release_lib";"Platform=x64"
if errorlevel 1 goto end

if %LIBD% == "True" (
call msbuild.exe .\Libraries\CANAPI\uvcanslc.vcxproj /t:Clean;Build /p:"Configuration=Debug_lib";"Platform=x64"
if errorlevel 1 goto end
)
rem build the CAN API V3 C++ library (dynamic and static)
call msbuild.exe .\Libraries\SerialCAN\SerialCAN.vcxproj /t:Clean;Build /p:"Configuration=Release_dll";"Platform=x64"
if errorlevel 1 goto end

call msbuild.exe .\Libraries\SerialCAN\SerialCAN.vcxproj /t:Clean;Build /p:"Configuration=Release_lib";"Platform=x64"
if errorlevel 1 goto end

if %LIBD% == "True" (
call msbuild.exe .\Libraries\SerialCAN\SerialCAN.vcxproj /t:Clean;Build /p:"Configuration=Debug_lib";"Platform=x64"
if errorlevel 1 goto end
)
rem copy the arifacts into the Binaries folder
echo Copying artifacts...
set BIN=".\Binaries"
set BIN=.\Binaries
if not exist %BIN% mkdir %BIN%
set BIN="%BIN%\x64"
set BIN=%BIN%\x64
if not exist %BIN% mkdir %BIN%
copy /Y .\Libraries\CANAPI\x64\Release_dll\u3canslc.dll %BIN%
copy /Y .\Libraries\CANAPI\x64\Release_dll\u3canslc.exp %BIN%
Expand All @@ -58,17 +64,27 @@ copy /Y .\Libraries\SerialCAN\x64\Release_dll\uvSerialCAN.dll %BIN%
copy /Y .\Libraries\SerialCAN\x64\Release_dll\uvSerialCAN.exp %BIN%
copy /Y .\Libraries\SerialCAN\x64\Release_dll\uvSerialCAN.lib %BIN%
copy /Y .\Libraries\SerialCAN\x64\Release_dll\uvSerialCAN.pdb %BIN%
set BIN="%BIN%\lib"
set BIN=%BIN%\lib
if not exist %BIN% mkdir %BIN%
copy /Y .\Libraries\CANAPI\x64\Release_lib\u3canslc.lib %BIN%
copy /Y .\Libraries\CANAPI\x64\Release_lib\u3canslc.pdb %BIN%
copy /Y .\Libraries\SerialCAN\x64\Release_lib\uvSerialCAN.lib %BIN%
copy /Y .\Libraries\SerialCAN\x64\Release_lib\uvSerialCAN.pdb %BIN%
echo Static libraries (x64) > %BIN%\readme.txt

echo "Static libraries (x64)" > %BIN%\readme.txt
set BIN=%BIN%\Debug
if %LIBD% == "True" (
if not exist %BIN% mkdir %BIN%
copy /Y .\Libraries\CANAPI\x64\Debug_lib\u3canslc.lib %BIN%
copy /Y .\Libraries\CANAPI\x64\Debug_lib\u3canslc.pdb %BIN%
copy /Y .\Libraries\CANAPI\x64\Debug_lib\u3canslc.idb %BIN%
copy /Y .\Libraries\SerialCAN\x64\Debug_lib\uvSerialCAN.lib %BIN%
copy /Y .\Libraries\SerialCAN\x64\Debug_lib\uvSerialCAN.pdb %BIN%
copy /Y .\Libraries\SerialCAN\x64\Debug_lib\uvSerialCAN.idb %BIN%
echo "Static debug libraries (x64)" > %BIN%\readme.txt
)
rem copy the header files into the Includes folder
echo Copying header files...
set INC=".\Includes"
set INC=.\Includes
if not exist %INC% mkdir %INC%
copy /Y .\Sources\SerialCAN*.h %INC%
copy /Y .\Sources\CANAPI\CANAPI.h %INC%
Expand Down
54 changes: 35 additions & 19 deletions x86_build.bat
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
@echo off

rem parse arguments: [[NOVARS] NOTRIAL]
if "%1" == "NOVARS" (
set VCVARS="False"
SHIFT
) else (
set VCVARS="True"
)
if "%1" == "NOTRIAL" (
set TRIAL="False"
SHIFT
) else (
set TRIAL="True"
)
set VCVARS="True"
set TRIAL="True"
set LIBD="False"

rem parse arguments: [NOVARS] [NOTRIAL] [DEBUG]
:LOOP
if "%1" == "NOVARS" set VCVARS="False"
if "%1" == "NOTRIAL" set TRIAL="False"
if "%1" == "DEBUG" set LIBD="True"
SHIFT
if not "%1" == "" goto LOOP

rem set MSBuild environment variables
if %VCVARS% == "True" (
Expand All @@ -37,18 +35,26 @@ if errorlevel 1 goto end
call msbuild.exe .\Libraries\CANAPI\uvcanslc.vcxproj /t:Clean;Build /p:"Configuration=Release_lib";"Platform=Win32"
if errorlevel 1 goto end

if %LIBD% == "True" (
call msbuild.exe .\Libraries\CANAPI\uvcanslc.vcxproj /t:Clean;Build /p:"Configuration=Debug_lib";"Platform=Win32"
if errorlevel 1 goto end
)
rem build the CAN API V3 C++ library (dynamic and static)
call msbuild.exe .\Libraries\SerialCAN\SerialCAN.vcxproj /t:Clean;Build /p:"Configuration=Release_dll";"Platform=Win32"
if errorlevel 1 goto end

call msbuild.exe .\Libraries\SerialCAN\SerialCAN.vcxproj /t:Clean;Build /p:"Configuration=Release_lib";"Platform=Win32"
if errorlevel 1 goto end

if %LIBD% == "True" (
call msbuild.exe .\Libraries\SerialCAN\SerialCAN.vcxproj /t:Clean;Build /p:"Configuration=Debug_lib";"Platform=Win32"
if errorlevel 1 goto end
)
rem copy the arifacts into the Binaries folder
echo Copying artifacts...
set BIN=".\Binaries"
set BIN=.\Binaries
if not exist %BIN% mkdir %BIN%
set BIN="%BIN%\x86"
set BIN=%BIN%\x86
if not exist %BIN% mkdir %BIN%
copy /Y .\Libraries\CANAPI\Release_dll\u3canslc.dll %BIN%
copy /Y .\Libraries\CANAPI\Release_dll\u3canslc.exp %BIN%
Expand All @@ -58,17 +64,27 @@ copy /Y .\Libraries\SerialCAN\Release_dll\uvSerialCAN.dll %BIN%
copy /Y .\Libraries\SerialCAN\Release_dll\uvSerialCAN.exp %BIN%
copy /Y .\Libraries\SerialCAN\Release_dll\uvSerialCAN.lib %BIN%
copy /Y .\Libraries\SerialCAN\Release_dll\uvSerialCAN.pdb %BIN%
set BIN="%BIN%\lib"
set BIN=%BIN%\lib
if not exist %BIN% mkdir %BIN%
copy /Y .\Libraries\CANAPI\Release_lib\u3canslc.lib %BIN%
copy /Y .\Libraries\CANAPI\Release_lib\u3canslc.pdb %BIN%
copy /Y .\Libraries\SerialCAN\Release_lib\uvSerialCAN.lib %BIN%
copy /Y .\Libraries\SerialCAN\Release_lib\uvSerialCAN.pdb %BIN%
echo Static libraries (x86) > %BIN%\readme.txt

echo "Static libraries (x86)" > %BIN%\readme.txt
set BIN=%BIN%\Debug
if %LIBD% == "True" (
if not exist %BIN% mkdir %BIN%
copy /Y .\Libraries\CANAPI\Debug_lib\u3canslc.lib %BIN%
copy /Y .\Libraries\CANAPI\Debug_lib\u3canslc.pdb %BIN%
copy /Y .\Libraries\CANAPI\Debug_lib\u3canslc.idb %BIN%
copy /Y .\Libraries\SerialCAN\Debug_lib\uvSerialCAN.lib %BIN%
copy /Y .\Libraries\SerialCAN\Debug_lib\uvSerialCAN.pdb %BIN%
copy /Y .\Libraries\SerialCAN\Debug_lib\uvSerialCAN.idb %BIN%
echo "Static debug libraries (x86)" > %BIN%\readme.txt
)
rem copy the header files into the Includes folder
echo Copying header files...
set INC=".\Includes"
set INC=.\Includes
if not exist %INC% mkdir %INC%
copy /Y .\Sources\SerialCAN*.h %INC%
copy /Y .\Sources\CANAPI\CANAPI.h %INC%
Expand Down

0 comments on commit a89075f

Please sign in to comment.