├── .gitattributes ├── .github ├── FUNDING.yml └── workflows │ ├── macOS-build.yml │ └── msbuild-x64.yml ├── .gitignore ├── Doxygen ├── .gitignore ├── Doxyfile └── logo.png ├── Examples ├── C++ │ ├── .gitignore │ ├── Makefile │ ├── can_recv.cpp │ └── can_send.cpp ├── Makefile └── Python │ ├── .gitignore │ ├── CANAPI.py │ ├── CANAPI_SerialCAN.py │ ├── Makefile │ ├── can_recv.py │ └── can_send.py ├── LICENSE.BSD-2-Clause ├── LICENSE.GPL-3.0-or-later ├── Libraries ├── CANAPI │ ├── Makefile │ ├── Sources │ │ ├── dllmain.cpp │ │ ├── framework.h │ │ ├── pch.cpp │ │ └── pch.h │ ├── resource.h │ ├── uvcanslc.rc │ ├── uvcanslc.vcxproj │ └── uvcanslc.vcxproj.filters ├── SLCAN │ └── README.md └── SerialCAN │ ├── Makefile │ ├── SerialCAN.rc │ ├── SerialCAN.vcxproj │ ├── SerialCAN.vcxproj.filters │ ├── Sources │ ├── dllmain.cpp │ ├── framework.h │ ├── pch.cpp │ └── pch.h │ └── resource.h ├── Makefile ├── README.md ├── SerialCAN.cppcheck ├── Sources ├── CANAPI │ ├── .gitignore │ ├── CANAPI.h │ ├── CANAPI_Defines.h │ ├── CANAPI_Types.h │ ├── CANAPI_Version.h │ ├── CANBTR_Defaults.h │ ├── LICENSE.BSD-2-Clause │ ├── LICENSE.GPL-3.0-or-later │ ├── README.md │ ├── SerialCAN_Defines.h │ ├── can_api.h │ ├── can_btr.c │ ├── can_btr.h │ ├── can_msg.c │ └── can_msg.h ├── SLCAN │ ├── LICENSE.BSD-2-Clause │ ├── LICENSE.GPL-3.0-or-later │ ├── README.md │ ├── buffer.c │ ├── buffer.h │ ├── buffer_p.c │ ├── buffer_w.c │ ├── logger.c │ ├── logger.h │ ├── logger_p.c │ ├── logger_w.c │ ├── queue.c │ ├── queue.h │ ├── queue_p.c │ ├── queue_w.c │ ├── serial.c │ ├── serial.h │ ├── serial_attr.h │ ├── serial_p.c │ ├── serial_w.c │ ├── slcan.c │ ├── slcan.h │ ├── timer.c │ ├── timer.h │ ├── timer_p.c │ └── timer_w.c ├── SerialCAN.cpp ├── SerialCAN.h ├── Version.h ├── Wrapper │ ├── can_api.c │ └── can_defs.h └── debug.h ├── Tests └── UnitTests │ ├── .gitignore │ ├── Bitrates.cpp │ ├── Bitrates.h │ ├── Driver.h │ ├── Parameter.cpp │ ├── Parameter.h │ ├── README.md │ ├── Settings.h │ ├── Tester.cpp │ ├── Tester.h │ ├── Testing.mm │ ├── Timer.cpp │ ├── Timer.h │ ├── test_can_exit.mm │ ├── test_can_init.mm │ ├── test_can_read.mm │ ├── test_can_reset.mm │ ├── test_can_start.mm │ ├── test_can_status.mm │ └── test_can_write.mm ├── Trial ├── Makefile ├── Sources │ └── main.cpp ├── slc_test.vcxproj ├── slc_test.vcxproj.filters └── slc_test.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ └── xcshareddata │ └── xcschemes │ ├── SerialCAN.xcscheme │ └── Testing.xcscheme ├── Utilities ├── Makefile ├── can_moni │ ├── COPYING │ ├── Driver.h │ ├── Makefile │ ├── README.md │ ├── Sources │ │ ├── .gitignore │ │ ├── COPYING │ │ ├── Message.cpp │ │ ├── Message.h │ │ ├── Options.cpp │ │ ├── Options.h │ │ ├── Options_p.cpp │ │ ├── Options_w.cpp │ │ ├── README │ │ ├── Timer.cpp │ │ ├── Timer.h │ │ ├── dosopt.c │ │ ├── dosopt.h │ │ └── main.cpp │ ├── can_moni.vcxproj │ └── can_moni.vcxproj.filters ├── can_test │ ├── COPYING │ ├── Driver.h │ ├── Makefile │ ├── README.md │ ├── Sources │ │ ├── .gitignore │ │ ├── COPYING │ │ ├── Options.cpp │ │ ├── Options.h │ │ ├── Options_p.cpp │ │ ├── Options_w.cpp │ │ ├── README │ │ ├── Timer.cpp │ │ ├── Timer.h │ │ ├── dosopt.c │ │ ├── dosopt.h │ │ └── main.cpp │ ├── can_test.vcxproj │ └── can_test.vcxproj.filters └── can_utils.sln ├── build_no.bat ├── build_no.sh ├── suppress.txt ├── x64_build.bat ├── x64_install.bat ├── x64_prompt.bat ├── x86_build.bat ├── x86_install.bat ├── x86_prompt.bat └── xxl_build.bat /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Never modify line endings of bash scripts 5 | *.sh text eol=lf 6 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: mac-can # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 14 | -------------------------------------------------------------------------------- /.github/workflows/macOS-build.yml: -------------------------------------------------------------------------------- 1 | name: macOS Build 2 | 3 | on: 4 | push: 5 | branches: [ "main" ] 6 | pull_request: 7 | branches: [ "main" ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: macos-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v3 16 | 17 | - name: Build 18 | run: make clean all 19 | -------------------------------------------------------------------------------- /.github/workflows/msbuild-x64.yml: -------------------------------------------------------------------------------- 1 | # This workflow uses actions that are not certified by GitHub. 2 | # They are provided by a third-party and are governed by 3 | # separate terms of service, privacy policy, and support 4 | # documentation. 5 | 6 | name: MSBuild x64 7 | 8 | on: 9 | push: 10 | branches: [ "main" ] 11 | pull_request: 12 | branches: [ "main" ] 13 | 14 | env: 15 | # Path to the solution file relative to the root of the project. 16 | SOLUTION_FILE_PATH: . 17 | 18 | # Configuration type to build. 19 | # You can convert this to a build matrix if you need coverage of multiple configuration types. 20 | # https://docs.github.com/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix 21 | BUILD_CONFIGURATION: Release 22 | 23 | permissions: 24 | contents: read 25 | 26 | jobs: 27 | build: 28 | runs-on: windows-latest 29 | 30 | steps: 31 | - uses: actions/checkout@v3 32 | 33 | - name: Add MSBuild to PATH 34 | uses: microsoft/setup-msbuild@v1.0.2 35 | 36 | - name: Build for x64 37 | working-directory: ${{env.GITHUB_WORKSPACE}} 38 | # Add additional options to the MSBuild command line here (like platform or verbosity level). 39 | # See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference 40 | run: ${{env.SOLUTION_FILE_PATH}}\x64_build.bat NOVARS NOTRIAL NODEBUG 41 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | #.gitignore 2 | Sources/build_no.h 3 | Trial/.objects 4 | Trial/.vs 5 | Trial/x64 6 | Trial/x86 7 | Trial/Debug 8 | Trial/Release 9 | Trial/slc_test 10 | Trial/*.sln 11 | Trial/*.vcxproj.user 12 | Libraries/CANAPI/.objects 13 | Libraries/CANAPI/*.dylib 14 | Libraries/CANAPI/*.so.* 15 | Libraries/CANAPI/*.a 16 | Libraries/CANAPI/.vs 17 | Libraries/CANAPI/x64 18 | Libraries/CANAPI/x86 19 | Libraries/CANAPI/Debug* 20 | Libraries/CANAPI/Release* 21 | Libraries/CANAPI/uvcanslc 22 | Libraries/CANAPI/*.sln 23 | Libraries/CANAPI/*.aps 24 | Libraries/CANAPI/*.vcxproj.user 25 | Libraries/SerialCAN/.objects 26 | Libraries/SerialCAN/*.dylib 27 | Libraries/SerialCAN/*.so.* 28 | Libraries/SerialCAN/*.a 29 | Libraries/SerialCAN/.vs 30 | Libraries/SerialCAN/x64 31 | Libraries/SerialCAN/x86 32 | Libraries/SerialCAN/Debug* 33 | Libraries/SerialCAN/Release* 34 | Libraries/SerialCAN/SerialCAN 35 | Libraries/SerialCAN/*.sln 36 | Libraries/SerialCAN/*.aps 37 | Libraries/SerialCAN/*.vcxproj.user 38 | Utilities/.vs 39 | Utilities/x64 40 | Utilities/x86 41 | Utilities/Debug 42 | Utilities/Release 43 | Utilities/can_moni/.objects 44 | Utilities/can_moni/.vs 45 | Utilities/can_moni/x64 46 | Utilities/can_moni/x86 47 | Utilities/can_moni/Debug 48 | Utilities/can_moni/Release 49 | Utilities/can_moni/can_moni 50 | Utilities/can_moni/*.sln 51 | Utilities/can_moni/*.vcxproj.user 52 | Utilities/can_test/.objects 53 | Utilities/can_test/.vs 54 | Utilities/can_test/x64 55 | Utilities/can_test/x86 56 | Utilities/can_test/Debug 57 | Utilities/can_test/Release 58 | Utilities/can_test/can_test 59 | Utilities/can_test/*.sln 60 | Utilities/can_test/*.vcxproj.user 61 | #Tests 62 | SerialCAN-cppcheck-build-dir 63 | checker.txt 64 | artifacts 65 | Binaries 66 | Includes 67 | Testing 68 | .vscode 69 | *.exe 70 | *.log 71 | *.pdf 72 | -------------------------------------------------------------------------------- /Doxygen/.gitignore: -------------------------------------------------------------------------------- 1 | html 2 | -------------------------------------------------------------------------------- /Doxygen/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mac-can/SerialCAN/4bb7945e328553813b419f1c821542e99bb57fec/Doxygen/logo.png -------------------------------------------------------------------------------- /Examples/C++/.gitignore: -------------------------------------------------------------------------------- 1 | can_recv 2 | can_send 3 | *.o 4 | *.exe 5 | -------------------------------------------------------------------------------- /Examples/C++/Makefile: -------------------------------------------------------------------------------- 1 | current_OS := $(shell sh -c 'uname 2>/dev/null || echo Unknown OS') 2 | current_OS := $(patsubst CYGWIN%,Cygwin,$(current_OS)) 3 | current_OS := $(patsubst MINGW%,MinGW,$(current_OS)) 4 | current_OS := $(patsubst MSYS%,MinGW,$(current_OS)) 5 | 6 | BINARIES = ../../Binaries 7 | INCLUDES = -I../../Includes 8 | 9 | TARGET1 = can_recv 10 | ifeq ($(current_OS),Darwin) # macOS - libSerial.dylib 11 | SOURCE1 = $(TARGET1).cpp $(BINARIES)/libSerialCAN.a 12 | endif 13 | ifeq ($(current_OS),$(filter $(current_OS),Linux Cygwin)) # linux - libserialcan.so.1 14 | SOURCE1 = $(TARGET1).cpp $(BINARIES)/libserialcan.a 15 | endif 16 | DEFINES1 = -DBAUDRATE=CANBTR_INDEX_250K 17 | 18 | TARGET2 = can_send 19 | ifeq ($(current_OS),Darwin) # macOS - libUVCANSLC.dylib 20 | SOURCE2 = $(TARGET2).cpp $(BINARIES)/libUVCANSLC.a 21 | endif 22 | ifeq ($(current_OS),$(filter $(current_OS),Linux Cygwin)) # linux - libuvcanslc.so.1 23 | SOURCE2 = $(TARGET2).cpp $(BINARIES)/libuvcanslc.a 24 | endif 25 | DEFINES2 = -DBAUDRATE=CANBTR_INDEX_250K 26 | 27 | CXXFLAGS = -pthread 28 | LDFLAGS = 29 | 30 | CXX = g++ 31 | LD = g++ 32 | RM = rm -f 33 | CP = cp 34 | 35 | all: $(TARGET1) $(TARGET2) 36 | 37 | $(TARGET1): $(SOURCE1) 38 | $(CXX) $(SOURCE1) $(DEFINES1) $(INCLUDES) $(CXXFLAGS) $(LDFLAGS) -o $(TARGET1) 39 | 40 | $(TARGET2): $(SOURCE2) 41 | $(CXX) $(SOURCE2) $(DEFINES2) $(INCLUDES) $(CXXFLAGS) $(LDFLAGS) -o $(TARGET2) 42 | 43 | clean: 44 | @-$(RM) *.o *~ $(TARGET1) $(TARGET2) 45 | pristine: 46 | @-$(RM) *.o *~ $(TARGET1) $(TARGET2) 47 | 48 | install: 49 | @-$(CP) $(TARGET1) /usr/local/bin 50 | @-$(CP) $(TARGET2) /usr/local/bin 51 | -------------------------------------------------------------------------------- /Examples/C++/can_recv.cpp: -------------------------------------------------------------------------------- 1 | #ifdef _MSC_VER 2 | //no Microsoft extensions please! 3 | #ifndef _CRT_SECURE_NO_WARNINGS 4 | #define _CRT_SECURE_NO_WARNINGS 1 5 | #endif 6 | #endif 7 | #include 8 | #include 9 | #include 10 | 11 | #if !defined(_WIN32) && !defined(_WIN64) 12 | #include 13 | #if defined(__APPLE__) 14 | #define SERIAL_PORT "/dev/tty.usbserial-LW4KOZQW" 15 | #elif !defined(__CYGWIN__) 16 | #define SERIAL_PORT "/dev/ttyUSB0" 17 | #else 18 | #define SERIAL_PORT "/dev/ttyS3" 19 | #endif 20 | #else 21 | #include 22 | #define SERIAL_PORT "\\\\.\\COM4" 23 | int usleep(unsigned int usec); 24 | #endif 25 | 26 | #include "SerialCAN_Defines.h" 27 | #include "SerialCAN.h" 28 | 29 | #ifndef BAUDRATE 30 | #define BAUDRATE CANBTR_INDEX_250K 31 | #endif 32 | 33 | static void sigterm(int signo); 34 | static volatile int running = 1; 35 | 36 | static CSerialCAN mySerialCAN = CSerialCAN(); 37 | 38 | int main(int argc, const char * argv[]) { 39 | CANAPI_OpMode_t opMode = {}; 40 | opMode.byte = CANMODE_DEFAULT; 41 | CANAPI_Bitrate_t bitrate = {}; 42 | bitrate.index = BAUDRATE; 43 | CANAPI_Message_t message; 44 | CANAPI_Return_t retVal = 0; 45 | int frames = 0; 46 | 47 | std::cout << CSerialCAN::GetVersion() << std::endl; 48 | if((signal(SIGINT, sigterm) == SIG_ERR) || 49 | #if !defined(_WIN32) && !defined(_WIN64) 50 | (signal(SIGHUP, sigterm) == SIG_ERR) || 51 | #endif 52 | (signal(SIGTERM, sigterm) == SIG_ERR)) { 53 | perror("+++ error"); 54 | return errno; 55 | } 56 | if ((retVal = mySerialCAN.InitializeChannel(SERIAL_PORT, opMode)) != CSerialCAN::NoError) { 57 | std::cerr << "+++ error: interface could not be initialized" << std::endl; 58 | return retVal; 59 | } 60 | if ((retVal = mySerialCAN.StartController(bitrate)) != CSerialCAN::NoError) { 61 | std::cerr << "+++ error: interface could not be started" << std::endl; 62 | goto teardown; 63 | } 64 | std::cout << "Press Ctrl+C to abort..." << std::endl; 65 | while (running) { 66 | if ((retVal = mySerialCAN.ReadMessage(message, CANREAD_INFINITE)) == CSerialCAN::NoError) { 67 | fprintf(stdout, "%i\t%7li.%04li\t%03X\t%c%c [%i]", frames++, 68 | message.timestamp.tv_sec, message.timestamp.tv_nsec / 100000, 69 | message.id, message.xtd? 'X' : 'S', message.rtr? 'R' : ' ', message.dlc); 70 | for (int i = 0; i < message.dlc; i++) 71 | fprintf(stdout, " %02X", message.data[i]); 72 | if (message.sts) 73 | fprintf(stdout, " <<< status frame"); 74 | fprintf(stdout, "\n"); 75 | } 76 | else if (retVal != CSerialCAN::ReceiverEmpty) { 77 | fprintf(stderr, "+++ error: read message returned %i", retVal); 78 | running = 0; 79 | } 80 | } 81 | std::cout << std::endl; 82 | teardown: 83 | if ((retVal = mySerialCAN.TeardownChannel()) != CSerialCAN::NoError) 84 | std::cerr << "+++ error: interface could not be shutdown" << std::endl; 85 | std::cout << "Cheers!" << std::endl; 86 | return retVal; 87 | } 88 | 89 | static void sigterm(int signo) { 90 | //fprintf(stderr, "%s: got signal %d\n", __FILE__, signo); 91 | (void)mySerialCAN.SignalChannel(); 92 | running = 0; 93 | (void)signo; 94 | } 95 | -------------------------------------------------------------------------------- /Examples/C++/can_send.cpp: -------------------------------------------------------------------------------- 1 | #ifdef _MSC_VER 2 | //no Microsoft extensions please! 3 | #ifndef _CRT_SECURE_NO_WARNINGS 4 | #define _CRT_SECURE_NO_WARNINGS 1 5 | #endif 6 | #endif 7 | #include 8 | 9 | #if !defined(_WIN32) && !defined(_WIN64) 10 | #include 11 | #if defined(__APPLE__) 12 | #define SERIAL_PORT "/dev/tty.usbserial-LW4KOZQW" 13 | #elif !defined(__CYGWIN__) 14 | #define SERIAL_PORT "/dev/ttyUSB0" 15 | #else 16 | #define SERIAL_PORT "/dev/ttyS3" 17 | #endif 18 | #else 19 | #include 20 | #define SERIAL_PORT "\\\\.\\COM4" 21 | int usleep(unsigned int usec); 22 | #endif 23 | #define OPTION_CANAPI_DRIVER 1 24 | #include "can_api.h" 25 | 26 | #include "CANAPI_Defines.h" 27 | #include "SerialCAN_Defines.h" 28 | 29 | #ifndef BAUDRATE 30 | #define BAUDRATE CANBTR_INDEX_250K 31 | #endif 32 | #define FRAMES (CAN_MAX_STD_ID+1) 33 | 34 | int main(int argc, const char * argv[]) { 35 | int handle, result, i; 36 | can_bitrate_t bitrate; 37 | can_message_t message; 38 | 39 | can_sio_param_t port; 40 | port.name = (char*)SERIAL_PORT; 41 | port.attr.protocol = CANSIO_LAWICEL; 42 | port.attr.baudrate = CANSIO_BD57600; 43 | port.attr.bytesize = CANSIO_8DATABITS; 44 | port.attr.parity = CANSIO_NOPARITY; 45 | port.attr.stopbits = CANSIO_1STOPBIT; 46 | 47 | std::cout << can_version() << std::endl; 48 | if ((handle = can_init(CAN_BOARD(CANLIB_SERIALCAN, CANDEV_SERIAL), CANMODE_DEFAULT, (const void*)&port)) < 0) { 49 | std::cerr << "+++ error: interface could not be initialized" << std::endl; 50 | return -1; 51 | } 52 | bitrate.index = BAUDRATE; 53 | if ((result = can_start(handle, &bitrate)) < 0) { 54 | std::cerr << "+++ error: interface could not be started" << std::endl; 55 | goto end; 56 | } 57 | std::cout << ">>> Be patient..." << std::flush; 58 | message.xtd = message.rtr = message.sts = 0; 59 | //message.fdf = message.brs = message.esi = 0; 60 | for (i = 0; i < FRAMES; i++) { 61 | message.id = (uint32_t)i & CAN_MAX_STD_ID; 62 | message.dlc = 8U; 63 | message.data[0] = (uint8_t)((uint64_t)i >> 0); 64 | message.data[1] = (uint8_t)((uint64_t)i >> 8); 65 | message.data[2] = (uint8_t)((uint64_t)i >> 16); 66 | message.data[3] = (uint8_t)((uint64_t)i >> 24); 67 | message.data[4] = (uint8_t)((uint64_t)i >> 32); 68 | message.data[5] = (uint8_t)((uint64_t)i >> 40); 69 | message.data[6] = (uint8_t)((uint64_t)i >> 48); 70 | message.data[7] = (uint8_t)((uint64_t)i >> 56); 71 | do { 72 | result = can_write(handle, &message, 0U); 73 | } while (result == CANERR_TX_BUSY); 74 | if (result < CANERR_NOERROR) { 75 | std::cerr << "\n+++ error: message could not be sent" << std::endl; 76 | goto reset; 77 | } 78 | } 79 | #if !defined(_WIN32) && !defined(_WIN64) 80 | usleep(1000000); // afterburner 81 | #else 82 | Sleep(1000); // wait a minute 83 | #endif 84 | reset: 85 | std::cout << i << " frame(s) sent" << std::endl; 86 | if ((result = can_reset(handle)) < 0) 87 | std::cerr << "+++ error: interface could not be stopped" << std::endl; 88 | end: 89 | if ((result = can_exit(handle)) < 0) 90 | std::cerr << "+++ error: interface could not be shutdown" << std::endl; 91 | std::cout << "Cheers!" << std::endl; 92 | return result; 93 | } 94 | -------------------------------------------------------------------------------- /Examples/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | # if any Makefile failed, stop building all... 3 | @for m in `find . -mindepth 2 -name Makefile`; do\ 4 | $(MAKE) -C `dirname $$m`; \ 5 | if [ $$? -ne 0 ]; then exit 1; fi; \ 6 | done 7 | 8 | clean: 9 | -@for m in `find . -mindepth 2 -name Makefile`; do\ 10 | $(MAKE) -C `dirname $$m` clean; \ 11 | done 12 | 13 | pristine: 14 | -@for m in `find . -mindepth 2 -name Makefile`; do\ 15 | $(MAKE) -C `dirname $$m` pristine; \ 16 | done 17 | -------------------------------------------------------------------------------- /Examples/Python/.gitignore: -------------------------------------------------------------------------------- 1 | .svn 2 | .idea 3 | CANAPI_SocketCAN.py 4 | CANAPI_RocketCAN.py 5 | __pycache__ 6 | *.pyc 7 | *.log 8 | -------------------------------------------------------------------------------- /Examples/Python/CANAPI_SerialCAN.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # SerialCAN - CAN API V3 Driver for CAN-over-Serial-Line Interfaces 4 | # 5 | # Copyright (c) 2020-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com) 6 | # All rights reserved. 7 | # 8 | # This file is part of SerialCAN. 9 | # 10 | # SerialCAN is dual-licensed under the BSD 2-Clause "Simplified" License 11 | # and under the GNU General Public License v3.0 (or any later version). You can 12 | # choose between one of them if you use SerialCAN in whole or in part. 13 | # 14 | # BSD 2-Clause "Simplified" License: 15 | # Redistribution and use in source and binary forms, with or without 16 | # modification, are permitted provided that the following conditions are met: 17 | # 1. Redistributions of source code must retain the above copyright notice, this 18 | # list of conditions and the following disclaimer. 19 | # 2. Redistributions in binary form must reproduce the above copyright notice, 20 | # this list of conditions and the following disclaimer in the documentation 21 | # and/or other materials provided with the distribution. 22 | # 23 | # SerialCAN IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 27 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 31 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | # OF SerialCAN, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | # 34 | # GNU General Public License v3.0 or later: 35 | # SerialCAN is free software: you can redistribute it and/or modify 36 | # it under the terms of the GNU General Public License as published by 37 | # the Free Software Foundation, either version 3 of the License, or 38 | # (at your option) any later version. 39 | # 40 | # SerialCAN is distributed in the hope that it will be useful, 41 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 42 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 43 | # GNU General Public License for more details. 44 | # 45 | # You should have received a copy of the GNU General Public License 46 | # along with SerialCAN. If not, see . 47 | # 48 | """ 49 | CAN API V3 Python Wrapper for CAN-over-Serial-Line Interfaces. 50 | 51 | CAN API V3 is a wrapper specification to have a uniform CAN 52 | Interface API for various CAN interfaces from different 53 | vendors running under multiple operating systems. 54 | 55 | $Author: makemake $ 56 | 57 | $Rev: 1397 $ 58 | """ 59 | from CANAPI import * 60 | from ctypes import * 61 | 62 | 63 | # CAN-over-Serial-Line interfaces 64 | # 65 | CANDEV_SERIAL = -1 # channel ID for serial port device 66 | 67 | # SerialCAN protocol options 68 | # 69 | CANSIO_LAWICEL = 0x00 # Lawicel SLCAN protocol 70 | CANSIO_CANABLE = 0x01 # CANable SLCAN protocol 71 | CANSIO_AUTO = 0xFF # auto detect (not realized yet) 72 | CANSIO_SLCAN = CANSIO_LAWICEL # Lawicel SLCAN protocol (default) 73 | 74 | # Baud rate (CBAUDEX compatible, e.g. CygWin) 75 | # 76 | CANSIO_BD57600 = 57600 # 57.6 kBd 77 | CANSIO_BD115200 = 115200 # 115.2 kBd 78 | CANSIO_BD230400 = 230400 # 230.4 kBd 79 | CANSIO_BD460800 = 460800 # 460.8 kBd 80 | CANSIO_BD500000 = 500000 # 500.0 kBd 81 | CANSIO_BD576000 = 576000 # 576.0 kBd 82 | CANSIO_BD921600 = 921600 # 921.6 kBd 83 | CANSIO_BD1000000 = 1000000 # 1.000 MBd 84 | CANSIO_BD1152000 = 1152000 # 1.152 MBd 85 | CANSIO_BD1500000 = 1500000 # 1.500 MBd 86 | CANSIO_BD2000000 = 2000000 # 2.000 MBd 87 | CANSIO_BD2500000 = 2500000 # 2.500 MBd 88 | CANSIO_BD3000000 = 3000000 # 3.000 MBd 89 | 90 | # Number of data bits (5, 6, 7, 8) 91 | # 92 | CANSIO_5DATABITS = 5 # 5 bits per data byte 93 | CANSIO_6DATABITS = 6 # 6 bits per data byte 94 | CANSIO_7DATABITS = 7 # 7 bits per data byte 95 | CANSIO_8DATABITS = 8 # 8 bits per data byte 96 | 97 | # Parity bit (None, Even, Odd) 98 | # 99 | CANSIO_NOPARITY = 0 # no parity 100 | CANSIO_ODDPARITY = 1 # odd parity 101 | CANSIO_EVENPARITY = 2 # even parity 102 | 103 | # Number of stop bits (1 or 2) 104 | # 105 | CANSIO_1STOPBIT = 1 # 1 stop bit 106 | CANSIO_2STOPBITS = 2 # 2 stop bits 107 | 108 | 109 | class SerialAttr(LittleEndianStructure): 110 | """ 111 | SerialCAN port attributes 112 | """ 113 | _fields_ = [ 114 | ('baudrate', c_uint32), 115 | ('bytesize', c_uint8), 116 | ('parity', c_uint8), 117 | ('stopbits', c_uint8), 118 | ('protocol', c_uint8) 119 | ] 120 | def __init__(self): 121 | self.protocol = CANSIO_SLCAN 122 | self.baudrate = CANSIO_BD57600 123 | self.bytesize = CANSIO_8DATABITS 124 | self.parity = CANSIO_NOPARITY 125 | self.stopbits = CANSIO_1STOPBIT 126 | 127 | class SerialPort(LittleEndianStructure): 128 | """ 129 | SerialCAN port parameters 130 | """ 131 | _fields_ = [ 132 | ('name', c_char_p), 133 | ('attr', SerialAttr) 134 | ] 135 | -------------------------------------------------------------------------------- /Examples/Python/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | @-echo python3 Nothing to be done for ''all'' 3 | 4 | clean: 5 | @-rm -f *.pyc 6 | 7 | pristine: 8 | @-rm -f *.pyc 9 | @-rm -rf __pycache__ 10 | -------------------------------------------------------------------------------- /LICENSE.BSD-2-Clause: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2020-2021, Uwe Vogt, UV Software 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /Libraries/CANAPI/Sources/dllmain.cpp: -------------------------------------------------------------------------------- 1 | // dllmain.cpp : Defines the entry point for the DLL application. 2 | #include "pch.h" 3 | 4 | BOOL APIENTRY DllMain( HMODULE hModule, 5 | DWORD ul_reason_for_call, 6 | LPVOID lpReserved 7 | ) 8 | { 9 | switch (ul_reason_for_call) 10 | { 11 | case DLL_PROCESS_ATTACH: 12 | case DLL_THREAD_ATTACH: 13 | case DLL_THREAD_DETACH: 14 | case DLL_PROCESS_DETACH: 15 | break; 16 | } 17 | return TRUE; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /Libraries/CANAPI/Sources/framework.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 4 | // Windows Header Files 5 | #include 6 | -------------------------------------------------------------------------------- /Libraries/CANAPI/Sources/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to the pre-compiled header 2 | 3 | #include "pch.h" 4 | 5 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed. 6 | -------------------------------------------------------------------------------- /Libraries/CANAPI/Sources/pch.h: -------------------------------------------------------------------------------- 1 | // pch.h: This is a precompiled header file. 2 | // Files listed below are compiled only once, improving build performance for future builds. 3 | // This also affects IntelliSense performance, including code completion and many code browsing features. 4 | // However, files listed here are ALL re-compiled if any one of them is updated between builds. 5 | // Do not add files here that you will be updating frequently as this negates the performance advantage. 6 | 7 | #ifndef PCH_H 8 | #define PCH_H 9 | 10 | // add headers that you want to pre-compile here 11 | #include "framework.h" 12 | 13 | #endif //PCH_H 14 | -------------------------------------------------------------------------------- /Libraries/CANAPI/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by u3canslc.rc 4 | 5 | // Next default values for new objects 6 | // 7 | #ifdef APSTUDIO_INVOKED 8 | #ifndef APSTUDIO_READONLY_SYMBOLS 9 | #define _APS_NEXT_RESOURCE_VALUE 101 10 | #define _APS_NEXT_COMMAND_VALUE 40001 11 | #define _APS_NEXT_CONTROL_VALUE 1001 12 | #define _APS_NEXT_SYMED_VALUE 101 13 | #endif 14 | #endif 15 | -------------------------------------------------------------------------------- /Libraries/CANAPI/uvcanslc.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mac-can/SerialCAN/4bb7945e328553813b419f1c821542e99bb57fec/Libraries/CANAPI/uvcanslc.rc -------------------------------------------------------------------------------- /Libraries/CANAPI/uvcanslc.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | Header Files 32 | 33 | 34 | Header Files 35 | 36 | 37 | 38 | 39 | Source Files 40 | 41 | 42 | Source Files 43 | 44 | 45 | Source Files 46 | 47 | 48 | Source Files 49 | 50 | 51 | Source Files 52 | 53 | 54 | Source Files 55 | 56 | 57 | Source Files 58 | 59 | 60 | Source Files 61 | 62 | 63 | Source Files 64 | 65 | 66 | Source Files 67 | 68 | 69 | 70 | 71 | Resource Files 72 | 73 | 74 | -------------------------------------------------------------------------------- /Libraries/SLCAN/README.md: -------------------------------------------------------------------------------- 1 | ### Lawicel SLCAN Protocol (Serial-Line CAN) 2 | 3 | _Copyright © 2016,2020-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com)_ \ 4 | _All rights reserved._ 5 | 6 | # SLCAN 7 | 8 | Note: **Creation of Lawicel SLCAN library has moved into its own [repo](https://github.com/mac-can/SLCAN).** 9 | 10 | ## This and That 11 | 12 | The documentation of the SLCAN protocol can be found on [Lawicel CANUSB product page](https://www.canusb.com/products/canusb). 13 | 14 | ### Dual-License 15 | 16 | This work is dual-licensed under the terms of the BSD 2-Clause "Simplified" License and under the terms of the GNU General Public License v3.0 (or any later version). 17 | You can choose between one of them if you use this work in whole or in part. 18 | 19 | `SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-or-later` 20 | 21 | ### Trademarks 22 | 23 | Mac and macOS are trademarks of Apple Inc., registered in the U.S. and other countries. \ 24 | Windows is a registered trademarks of Microsoft Corporation in the United States and/or other countries. \ 25 | POSIX is a registered of the Institute of Electrical and Electronic Engineers, Inc. \ 26 | Linux is a registered trademark of Linus Torvalds. \ 27 | Cygwin is a registered trademark of Red Hat, Inc. \ 28 | All other company, product and service names mentioned herein may be trademarks, registered trademarks, or service marks of their respective owners. 29 | 30 | ### Contact 31 | 32 | E-Mail: mailto://info@uv-software.com \ 33 | Internet: https://www.uv-software.com 34 | -------------------------------------------------------------------------------- /Libraries/SerialCAN/SerialCAN.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mac-can/SerialCAN/4bb7945e328553813b419f1c821542e99bb57fec/Libraries/SerialCAN/SerialCAN.rc -------------------------------------------------------------------------------- /Libraries/SerialCAN/SerialCAN.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | Header Files 32 | 33 | 34 | 35 | 36 | Source Files 37 | 38 | 39 | Source Files 40 | 41 | 42 | Source Files 43 | 44 | 45 | Source Files 46 | 47 | 48 | Source Files 49 | 50 | 51 | Source Files 52 | 53 | 54 | Source Files 55 | 56 | 57 | Source Files 58 | 59 | 60 | Source Files 61 | 62 | 63 | Source Files 64 | 65 | 66 | Source Files 67 | 68 | 69 | 70 | 71 | Resource Files 72 | 73 | 74 | -------------------------------------------------------------------------------- /Libraries/SerialCAN/Sources/dllmain.cpp: -------------------------------------------------------------------------------- 1 | // dllmain.cpp : Defines the entry point for the DLL application. 2 | #include "pch.h" 3 | 4 | BOOL APIENTRY DllMain( HMODULE hModule, 5 | DWORD ul_reason_for_call, 6 | LPVOID lpReserved 7 | ) 8 | { 9 | switch (ul_reason_for_call) 10 | { 11 | case DLL_PROCESS_ATTACH: 12 | case DLL_THREAD_ATTACH: 13 | case DLL_THREAD_DETACH: 14 | case DLL_PROCESS_DETACH: 15 | break; 16 | } 17 | return TRUE; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /Libraries/SerialCAN/Sources/framework.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 4 | // Windows Header Files 5 | #include 6 | -------------------------------------------------------------------------------- /Libraries/SerialCAN/Sources/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to the pre-compiled header 2 | 3 | #include "pch.h" 4 | 5 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed. 6 | -------------------------------------------------------------------------------- /Libraries/SerialCAN/Sources/pch.h: -------------------------------------------------------------------------------- 1 | // pch.h: This is a precompiled header file. 2 | // Files listed below are compiled only once, improving build performance for future builds. 3 | // This also affects IntelliSense performance, including code completion and many code browsing features. 4 | // However, files listed here are ALL re-compiled if any one of them is updated between builds. 5 | // Do not add files here that you will be updating frequently as this negates the performance advantage. 6 | 7 | #ifndef PCH_H 8 | #define PCH_H 9 | 10 | // add headers that you want to pre-compile here 11 | #include "framework.h" 12 | 13 | #endif //PCH_H 14 | -------------------------------------------------------------------------------- /Libraries/SerialCAN/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by SerialCAN.rc 4 | 5 | // Next default values for new objects 6 | // 7 | #ifdef APSTUDIO_INVOKED 8 | #ifndef APSTUDIO_READONLY_SYMBOLS 9 | #define _APS_NEXT_RESOURCE_VALUE 101 10 | #define _APS_NEXT_COMMAND_VALUE 40001 11 | #define _APS_NEXT_CONTROL_VALUE 1001 12 | #define _APS_NEXT_SYMED_VALUE 101 13 | #endif 14 | #endif 15 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # SerialCAN - CAN API V3 Driver for CAN-over-Serial-Line Interfaces 3 | # 4 | # Copyright (c) 2016,2020-2022 Uwe Vogt, UV Software, Berlin (info@uv-software.com) 5 | # All rights reserved. 6 | # 7 | # This file is part of SerialCAN. 8 | # 9 | # SerialCAN is dual-licensed under the BSD 2-Clause "Simplified" License 10 | # and under the GNU General Public License v3.0 (or any later version). You can 11 | # choose between one of them if you use SerialCAN in whole or in part. 12 | # 13 | # BSD 2-Clause "Simplified" License: 14 | # Redistribution and use in source and binary forms, with or without 15 | # modification, are permitted provided that the following conditions are met: 16 | # 1. Redistributions of source code must retain the above copyright notice, this 17 | # list of conditions and the following disclaimer. 18 | # 2. Redistributions in binary form must reproduce the above copyright notice, 19 | # this list of conditions and the following disclaimer in the documentation 20 | # and/or other materials provided with the distribution. 21 | # 22 | # SerialCAN IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF SerialCAN, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | # GNU General Public License v3.0 or later: 34 | # SerialCAN is free software: you can redistribute it and/or modify 35 | # it under the terms of the GNU General Public License as published by 36 | # the Free Software Foundation, either version 3 of the License, or 37 | # (at your option) any later version. 38 | # 39 | # SerialCAN is distributed in the hope that it will be useful, 40 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 41 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 42 | # GNU General Public License for more details. 43 | # 44 | # You should have received a copy of the GNU General Public License 45 | # along with SerialCAN. If not, see . 46 | # 47 | all: 48 | @./build_no.sh 49 | @echo "\033[1mBuilding SerialCAN...\033[0m" 50 | $(MAKE) -C Trial $@ 51 | $(MAKE) -C Libraries/SerialCAN $@ 52 | $(MAKE) -C Libraries/CANAPI $@ 53 | $(MAKE) -C Utilities/can_test $@ 54 | $(MAKE) -C Utilities/can_moni $@ 55 | 56 | clean: 57 | $(MAKE) -C Trial $@ 58 | $(MAKE) -C Libraries/SerialCAN $@ 59 | $(MAKE) -C Libraries/CANAPI $@ 60 | $(MAKE) -C Utilities/can_test $@ 61 | $(MAKE) -C Utilities/can_moni $@ 62 | 63 | pristine: 64 | $(MAKE) -C Trial $@ 65 | $(MAKE) -C Libraries/SerialCAN $@ 66 | $(MAKE) -C Libraries/CANAPI $@ 67 | $(MAKE) -C Utilities/can_test $@ 68 | $(MAKE) -C Utilities/can_moni $@ 69 | 70 | install: 71 | # $(MAKE) -C Trial $@ 72 | $(MAKE) -C Libraries/SerialCAN $@ 73 | $(MAKE) -C Libraries/CANAPI $@ 74 | # $(MAKE) -C Utilities/can_test $@ 75 | # $(MAKE) -C Utilities/can_moni $@ 76 | 77 | test: 78 | $(MAKE) -C Trial $@ 79 | 80 | check: 81 | $(MAKE) -C Trial $@ 2> checker.txt 82 | 83 | build_no: 84 | @./build_no.sh 85 | @cat Sources/build_no.h 86 | -------------------------------------------------------------------------------- /SerialCAN.cppcheck: -------------------------------------------------------------------------------- 1 | 2 | 3 | SerialCAN-cppcheck-build-dir 4 | Trial/slc_test.vcxproj 5 | false 6 | true 7 | true 8 | 2 9 | 100 10 | 11 | Debug 12 | 13 | 14 | windows 15 | 16 | 17 | -------------------------------------------------------------------------------- /Sources/CANAPI/.gitignore: -------------------------------------------------------------------------------- 1 | .svn 2 | # we don't use the JSON files yet 3 | can_dev.? 4 | vanilla.? 5 | # other blacklisted files 6 | SocketCAN_Defines.h 7 | RocketCAN_Defines.h 8 | -------------------------------------------------------------------------------- /Sources/CANAPI/CANAPI_Version.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-or-later */ 2 | /* 3 | * CAN Interface API, Version 3 (Data Types and Defines) 4 | * 5 | * Copyright (c) 2004-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com) 6 | * All rights reserved. 7 | * 8 | * This file is part of CAN API V3. 9 | * 10 | * CAN API V3 is dual-licensed under the BSD 2-Clause "Simplified" License 11 | * and under the GNU General Public License v3.0 (or any later version). 12 | * You can choose between one of them if you use this file. 13 | * 14 | * BSD 2-Clause "Simplified" License: 15 | * Redistribution and use in source and binary forms, with or without 16 | * modification, are permitted provided that the following conditions are met: 17 | * 1. Redistributions of source code must retain the above copyright notice, this 18 | * list of conditions and the following disclaimer. 19 | * 2. Redistributions in binary form must reproduce the above copyright notice, 20 | * this list of conditions and the following disclaimer in the documentation 21 | * and/or other materials provided with the distribution. 22 | * 23 | * CAN API V3 IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 31 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF CAN API V3, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * GNU General Public License v3.0 or later: 35 | * CAN API V3 is free software: you can redistribute it and/or modify 36 | * it under the terms of the GNU General Public License as published by 37 | * the Free Software Foundation, either version 3 of the License, or 38 | * (at your option) any later version. 39 | * 40 | * CAN API V3 is distributed in the hope that it will be useful, 41 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 42 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 43 | * GNU General Public License for more details. 44 | * 45 | * You should have received a copy of the GNU General Public License 46 | * along with CAN API V3. If not, see . 47 | */ 48 | /** @file CANAPI_Version.h 49 | * 50 | * @brief CAN API V3 for generic CAN Interfaces - Version Number 51 | * 52 | * @note This is only a dummy file to have a SVN revision number. 53 | * 54 | * @author $Author: eris $ 55 | * 56 | * @version $Rev: 1398 $ 57 | * 58 | * @addtogroup can_api 59 | * @{ 60 | */ 61 | #ifndef CANAPI_VERSION_H_INCLUDED 62 | #define CANAPI_VERSION_H_INCLUDED 63 | // SVN revision number (update with each commit: II) 64 | #define CAN_API_REV "$Rev: 1398 $" 65 | #endif /* CANAPI_VERSION_H_INCLUDED */ 66 | /** @} 67 | */ 68 | /* ---------------------------------------------------------------------- 69 | * Uwe Vogt, UV Software, Chausseestrasse 33 A, 10115 Berlin, Germany 70 | * Tel.: +49-30-46799872, Fax: +49-30-46799873, Mobile: +49-170-3801903 71 | * E-Mail: uwe.vogt@uv-software.de, Homepage: https://www.uv-software.de 72 | */ 73 | -------------------------------------------------------------------------------- /Sources/CANAPI/LICENSE.BSD-2-Clause: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2004-2024, Uwe Vogt, UV Software 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /Sources/CANAPI/README.md: -------------------------------------------------------------------------------- 1 | ### CAN Interface API, Version 3 2 | 3 | _Copyright © 2004-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com)_ \ 4 | _All rights reserved._ 5 | 6 | # A CAN Interface Wrapper Specification 7 | 8 | Originally, the CAN Interface API was based on a CAN interface definition as part of a microcontroller hardware abstraction layer for an 82527-compatible on-chip CAN controller. 9 | It was developed for use by (simple hand-coded) CANopen applications and migrated to different microcontroller types (even if the CAN peripherals on that micro had a different design). 10 | 11 | ## CAN API V1 12 | 13 | What works on microcontrollers should also work on PC. 14 | I started to use this interface definition as a wrapper specification for different CAN devices from various vendors: e.g. for IXXAT, PEAK, Vector, Kvaser, and also for Linux-CAN (aka SocketCAN). 15 | 16 | ## CAN API V2 17 | 18 | Dealing around with 14 virtual Basic-CAN messages boxes and a FIFO upon a virtual Full-CAN message box was a little bit over-engineered and error-prone. 19 | I optimized the interface definition to have an easy to use API following an _init-start-read-write-stop-exit_ pattern. 20 | 21 | ## CAN API V3 22 | 23 | Version 3 is the latest adaption of the CAN API wrapper specification. 24 | As new features it supports CAN FD long frames and fast frames, selectable operation-modes, blocking-read, and is multi-channel capable. 25 | Additionally it provides companion modules for bit-rate conversion and message formatting. 26 | 27 | # CAN Interface API, Version 3 28 | 29 | In case of doubt the source code: 30 | 31 | ```C 32 | #if (OPTION_CANAPI_LIBRARY != 0) 33 | extern int can_test(int32_t library, int32_t channel, uint8_t mode, const void *param, int *result); 34 | extern int can_init(int32_t library, int32_t channel, uint8_t mode, const void *param); 35 | #else 36 | extern int can_test(int32_t channel, uint8_t mode, const void *param, int *result); 37 | extern int can_init(int32_t channel, uint8_t mode, const void *param); 38 | #endif 39 | extern int can_exit(int handle); 40 | extern int can_kill(int handle); 41 | 42 | extern int can_start(int handle, const can_bitrate_t *bitrate); 43 | extern int can_reset(int handle); 44 | 45 | extern int can_write(int handle, const can_message_t *message, uint16_t timeout); 46 | extern int can_read(int handle, can_message_t *message, uint16_t timeout); 47 | 48 | extern int can_status(int handle, uint8_t *status); 49 | extern int can_busload(int handle, uint8_t *load, uint8_t *status); 50 | 51 | extern int can_bitrate(int handle, can_bitrate_t *bitrate, can_speed_t *speed); 52 | extern int can_property(int handle, uint16_t param, void *value, uint32_t nbyte); 53 | 54 | extern char *can_hardware(int handle); 55 | extern char *can_firmware(int handle); 56 | 57 | #if (OPTION_CANAPI_LIBRARY != 0) 58 | extern char *can_library(int handle); 59 | #endif 60 | extern char* can_version(void); 61 | ``` 62 | See header file `can_api.h` for a description of the provided functions. 63 | 64 | ## This and That 65 | 66 | ### CAN API V3 Reference 67 | 68 | A generic documentation of the CAN API V3 application programming interface can be found [here](https://uv-software.github.io/CANAPI-Docs/#/). 69 | 70 | ### vanilla-json 71 | 72 | The implementation is using [vanilla-json](https://github.com/uv-software/vanilla-json) to read CAN API wrapper configurations from JSON files. 73 | 74 | **vanilla-json** is a very simple JSON parser by UV Software written in C90, and it has the same dual-license model as CAN API V3; see below. 75 | 76 | ### Dual-License 77 | 78 | This work is dual-licensed under the terms of the BSD 2-Clause "Simplified" License and under the terms of the GNU General Public License v3.0 (or any later version). 79 | You can choose between one of them if you use this work in whole or in part. 80 | 81 | ### Contact 82 | 83 | E-Mail: mailto://info@uv-software.com \ 84 | Internet: https://www.uv-software.com 85 | -------------------------------------------------------------------------------- /Sources/SLCAN/LICENSE.BSD-2-Clause: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2020-2024, Uwe Vogt, UV Software 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /Sources/SLCAN/buffer.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-or-later */ 2 | /* 3 | * Software for Industrial Communication, Motion Control and Automation 4 | * 5 | * Copyright (c) 2002-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com) 6 | * All rights reserved. 7 | * 8 | * Module 'buffer' 9 | * 10 | * This module is dual-licensed under the BSD 2-Clause "Simplified" License 11 | * and under the GNU General Public License v3.0 (or any later version). 12 | * You can choose between one of them if you use this module. 13 | * 14 | * BSD 2-Clause "Simplified" License: 15 | * Redistribution and use in source and binary forms, with or without 16 | * modification, are permitted provided that the following conditions are met: 17 | * 1. Redistributions of source code must retain the above copyright notice, this 18 | * list of conditions and the following disclaimer. 19 | * 2. Redistributions in binary form must reproduce the above copyright notice, 20 | * this list of conditions and the following disclaimer in the documentation 21 | * and/or other materials provided with the distribution. 22 | * 23 | * THIS MODULE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 31 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS MODULE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * GNU General Public License v3.0 or later: 35 | * This module is free software: you can redistribute it and/or modify 36 | * it under the terms of the GNU General Public License as published by 37 | * the Free Software Foundation, either version 3 of the License, or 38 | * (at your option) any later version. 39 | * 40 | * This module is distributed in the hope that it will be useful, 41 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 42 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 43 | * GNU General Public License for more details. 44 | * 45 | * You should have received a copy of the GNU General Public License 46 | * along with this module. If not, see . 47 | */ 48 | #if defined(_WIN32) || defined(_WIN64) 49 | #include "buffer_w.c" 50 | #else 51 | #include "buffer_p.c" 52 | #endif 53 | 54 | /* $Id: buffer.c 811 2024-04-18 14:03:48Z quaoar $ Copyright (c) UV Software */ 55 | -------------------------------------------------------------------------------- /Sources/SLCAN/logger.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-or-later */ 2 | /* 3 | * Software for Industrial Communication, Motion Control and Automation 4 | * 5 | * Copyright (c) 2002-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com) 6 | * All rights reserved. 7 | * 8 | * Module 'logger' 9 | * 10 | * This module is dual-licensed under the BSD 2-Clause "Simplified" License 11 | * and under the GNU General Public License v3.0 (or any later version). 12 | * You can choose between one of them if you use this module. 13 | * 14 | * BSD 2-Clause "Simplified" License: 15 | * Redistribution and use in source and binary forms, with or without 16 | * modification, are permitted provided that the following conditions are met: 17 | * 1. Redistributions of source code must retain the above copyright notice, this 18 | * list of conditions and the following disclaimer. 19 | * 2. Redistributions in binary form must reproduce the above copyright notice, 20 | * this list of conditions and the following disclaimer in the documentation 21 | * and/or other materials provided with the distribution. 22 | * 23 | * THIS MODULE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 31 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS MODULE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * GNU General Public License v3.0 or later: 35 | * This module is free software: you can redistribute it and/or modify 36 | * it under the terms of the GNU General Public License as published by 37 | * the Free Software Foundation, either version 3 of the License, or 38 | * (at your option) any later version. 39 | * 40 | * This module is distributed in the hope that it will be useful, 41 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 42 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 43 | * GNU General Public License for more details. 44 | * 45 | * You should have received a copy of the GNU General Public License 46 | * along with this module. If not, see . 47 | */ 48 | #if defined(_WIN32) || defined(_WIN64) 49 | #include "logger_w.c" 50 | #else 51 | #include "logger_p.c" 52 | #endif 53 | 54 | /* $Id: logger.c 811 2024-04-18 14:03:48Z quaoar $ Copyright (c) UV Software */ 55 | -------------------------------------------------------------------------------- /Sources/SLCAN/queue.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-or-later */ 2 | /* 3 | * Software for Industrial Communication, Motion Control and Automation 4 | * 5 | * Copyright (c) 2002-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com) 6 | * All rights reserved. 7 | * 8 | * Module 'queue' 9 | * 10 | * This module is dual-licensed under the BSD 2-Clause "Simplified" License 11 | * and under the GNU General Public License v3.0 (or any later version). 12 | * You can choose between one of them if you use this module. 13 | * 14 | * BSD 2-Clause "Simplified" License: 15 | * Redistribution and use in source and binary forms, with or without 16 | * modification, are permitted provided that the following conditions are met: 17 | * 1. Redistributions of source code must retain the above copyright notice, this 18 | * list of conditions and the following disclaimer. 19 | * 2. Redistributions in binary form must reproduce the above copyright notice, 20 | * this list of conditions and the following disclaimer in the documentation 21 | * and/or other materials provided with the distribution. 22 | * 23 | * THIS MODULE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 31 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS MODULE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * GNU General Public License v3.0 or later: 35 | * This module is free software: you can redistribute it and/or modify 36 | * it under the terms of the GNU General Public License as published by 37 | * the Free Software Foundation, either version 3 of the License, or 38 | * (at your option) any later version. 39 | * 40 | * This module is distributed in the hope that it will be useful, 41 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 42 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 43 | * GNU General Public License for more details. 44 | * 45 | * You should have received a copy of the GNU General Public License 46 | * along with this module. If not, see . 47 | */ 48 | #if defined(_WIN32) || defined(_WIN64) 49 | #include "queue_w.c" 50 | #else 51 | #include "queue_p.c" 52 | #endif 53 | 54 | /* $Id: queue.c 811 2024-04-18 14:03:48Z quaoar $ Copyright (c) UV Software */ 55 | -------------------------------------------------------------------------------- /Sources/SLCAN/serial.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-or-later */ 2 | /* 3 | * Software for Industrial Communication, Motion Control and Automation 4 | * 5 | * Copyright (c) 2002-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com) 6 | * All rights reserved. 7 | * 8 | * Module 'serial' 9 | * 10 | * This module is dual-licensed under the BSD 2-Clause "Simplified" License 11 | * and under the GNU General Public License v3.0 (or any later version). 12 | * You can choose between one of them if you use this module. 13 | * 14 | * BSD 2-Clause "Simplified" License: 15 | * Redistribution and use in source and binary forms, with or without 16 | * modification, are permitted provided that the following conditions are met: 17 | * 1. Redistributions of source code must retain the above copyright notice, this 18 | * list of conditions and the following disclaimer. 19 | * 2. Redistributions in binary form must reproduce the above copyright notice, 20 | * this list of conditions and the following disclaimer in the documentation 21 | * and/or other materials provided with the distribution. 22 | * 23 | * THIS MODULE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 31 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS MODULE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * GNU General Public License v3.0 or later: 35 | * This module is free software: you can redistribute it and/or modify 36 | * it under the terms of the GNU General Public License as published by 37 | * the Free Software Foundation, either version 3 of the License, or 38 | * (at your option) any later version. 39 | * 40 | * This module is distributed in the hope that it will be useful, 41 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 42 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 43 | * GNU General Public License for more details. 44 | * 45 | * You should have received a copy of the GNU General Public License 46 | * along with this module. If not, see . 47 | */ 48 | #if defined(_WIN32) || defined(_WIN64) 49 | #include "serial_w.c" 50 | #else 51 | #include "serial_p.c" 52 | #endif 53 | 54 | /* $Id: serial.c 811 2024-04-18 14:03:48Z quaoar $ Copyright (c) UV Software */ 55 | -------------------------------------------------------------------------------- /Sources/SLCAN/serial_attr.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-or-later */ 2 | /* 3 | * Software for Industrial Communication, Motion Control and Automation 4 | * 5 | * Copyright (c) 2002-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com) 6 | * All rights reserved. 7 | * 8 | * Module 'serial' 9 | * 10 | * This module is dual-licensed under the BSD 2-Clause "Simplified" License 11 | * and under the GNU General Public License v3.0 (or any later version). 12 | * You can choose between one of them if you use this module. 13 | * 14 | * BSD 2-Clause "Simplified" License: 15 | * Redistribution and use in source and binary forms, with or without 16 | * modification, are permitted provided that the following conditions are met: 17 | * 1. Redistributions of source code must retain the above copyright notice, this 18 | * list of conditions and the following disclaimer. 19 | * 2. Redistributions in binary form must reproduce the above copyright notice, 20 | * this list of conditions and the following disclaimer in the documentation 21 | * and/or other materials provided with the distribution. 22 | * 23 | * THIS MODULE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 31 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS MODULE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * GNU General Public License v3.0 or later: 35 | * This module is free software: you can redistribute it and/or modify 36 | * it under the terms of the GNU General Public License as published by 37 | * the Free Software Foundation, either version 3 of the License, or 38 | * (at your option) any later version. 39 | * 40 | * This module is distributed in the hope that it will be useful, 41 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 42 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 43 | * GNU General Public License for more details. 44 | * 45 | * You should have received a copy of the GNU General Public License 46 | * along with this module. If not, see . 47 | */ 48 | /** @file serial_attr.h 49 | * 50 | * @brief Serial transmission attributes. 51 | * 52 | * @author $Author: quaoar $ 53 | * 54 | * @version $Rev: 811 $ 55 | * 56 | * @addtogroup serial 57 | * @{ 58 | */ 59 | #ifndef SERIAL_ATTR_H_INCLUDED 60 | #define SERIAL_ATTR_H_INCLUDED 61 | 62 | #include 63 | 64 | 65 | /* ----------- options ------------------------------------------------ 66 | */ 67 | 68 | 69 | /* ----------- defines ------------------------------------------------ 70 | */ 71 | 72 | 73 | /* ----------- types -------------------------------------------------- 74 | */ 75 | 76 | /** @brief Number of data bits (5, 6, 7, 8) 77 | */ 78 | typedef enum sio_bytesize_t_ { 79 | BYTESIZE5 = 5, 80 | BYTESIZE6 = 6, 81 | BYTESIZE7 = 7, 82 | BYTESIZE8 = 8, 83 | } sio_bytesize_t; 84 | 85 | /** @brief Parity bit (none, odd, even, mark, space) 86 | */ 87 | typedef enum sio_parity_t_ { 88 | PARITYNONE = 0, 89 | PARITYODD = 1, 90 | PARITYEVEN = 2, 91 | PARITYMARK = 3, 92 | PARITYSPACE = 4 93 | } sio_parity_t; 94 | 95 | /** @brief Number of stop bits (1 or 1.5 or 2) 96 | */ 97 | typedef enum sio_stopbits_t_ { 98 | STOPBITS1 = 0, 99 | STOPBITS1_5 = 1, 100 | STOPBITS2 = 2 101 | } sio_stopbits_t; 102 | 103 | /** @brief Serial port attributes 104 | */ 105 | typedef struct sio_attr_t_ { /* serial port attributes: */ 106 | uint32_t baudrate; /**< baud rate (in [bps]) */ 107 | sio_bytesize_t bytesize; /**< number of data bits (5, 6, 7, 8) */ 108 | sio_parity_t parity; /**< parity bit (none, odd, even, mark, space) */ 109 | sio_stopbits_t stopbits; /**< number of stop bits (1 or 1.5 or 2) */ 110 | } sio_attr_t; 111 | 112 | 113 | /* ----------- variables ---------------------------------------------- 114 | */ 115 | 116 | 117 | /* ----------- prototypes --------------------------------------------- 118 | */ 119 | #ifdef __cplusplus 120 | extern "C" { 121 | #endif 122 | 123 | 124 | #ifdef __cplusplus 125 | } 126 | #endif 127 | #endif /* SERIAL_ATTR_H_INCLUDED */ 128 | 129 | /* ---------------------------------------------------------------------- 130 | * Uwe Vogt, UV Software, Chausseestrasse 33 A, 10115 Berlin, Germany 131 | * Tel.: +49-30-46799872, Fax: +49-30-46799873, Mobile: +49-170-3801903 132 | * E-Mail: uwe.vogt@uv-software.de, Homepage: http://www.uv-software.de/ 133 | */ 134 | -------------------------------------------------------------------------------- /Sources/SLCAN/timer.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-or-later */ 2 | /* 3 | * Software for Industrial Communication, Motion Control and Automation 4 | * 5 | * Copyright (c) 2002-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com) 6 | * All rights reserved. 7 | * 8 | * Module 'timer' 9 | * 10 | * This module is dual-licensed under the BSD 2-Clause "Simplified" License 11 | * and under the GNU General Public License v3.0 (or any later version). 12 | * You can choose between one of them if you use this module. 13 | * 14 | * BSD 2-Clause "Simplified" License: 15 | * Redistribution and use in source and binary forms, with or without 16 | * modification, are permitted provided that the following conditions are met: 17 | * 1. Redistributions of source code must retain the above copyright notice, this 18 | * list of conditions and the following disclaimer. 19 | * 2. Redistributions in binary form must reproduce the above copyright notice, 20 | * this list of conditions and the following disclaimer in the documentation 21 | * and/or other materials provided with the distribution. 22 | * 23 | * THIS MODULE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 31 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS MODULE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * GNU General Public License v3.0 or later: 35 | * This module is free software: you can redistribute it and/or modify 36 | * it under the terms of the GNU General Public License as published by 37 | * the Free Software Foundation, either version 3 of the License, or 38 | * (at your option) any later version. 39 | * 40 | * This module is distributed in the hope that it will be useful, 41 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 42 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 43 | * GNU General Public License for more details. 44 | * 45 | * You should have received a copy of the GNU General Public License 46 | * along with this module. If not, see . 47 | */ 48 | #if defined(_WIN32) || defined(_WIN64) 49 | #include "timer_w.c" 50 | #else 51 | #include "timer_p.c" 52 | #endif 53 | 54 | /* $Id: timer.c 822 2024-08-27 09:23:18Z makemake $ Copyright (c) UV Software */ 55 | -------------------------------------------------------------------------------- /Sources/Version.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-3.0-or-later */ 2 | /* 3 | * SerialCAN - CAN API V3 Driver for CAN-over-Serial-Line Interfaces 4 | * 5 | * Copyright (c) 2020-2022 Uwe Vogt, UV Software, Berlin (info@uv-software.com) 6 | * All rights reserved. 7 | * 8 | * This file is part of SerialCAN. 9 | * 10 | * SerialCAN is dual-licensed under the BSD 2-Clause "Simplified" License 11 | * and under the GNU General Public License v3.0 (or any later version). You can 12 | * choose between one of them if you use SerialCAN in whole or in part. 13 | * 14 | * BSD 2-Clause "Simplified" License: 15 | * Redistribution and use in source and binary forms, with or without 16 | * modification, are permitted provided that the following conditions are met: 17 | * 1. Redistributions of source code must retain the above copyright notice, this 18 | * list of conditions and the following disclaimer. 19 | * 2. Redistributions in binary form must reproduce the above copyright notice, 20 | * this list of conditions and the following disclaimer in the documentation 21 | * and/or other materials provided with the distribution. 22 | * 23 | * SerialCAN IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 31 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF SerialCAN, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * GNU General Public License v3.0 or later: 35 | * SerialCAN is free software: you can redistribute it and/or modify 36 | * it under the terms of the GNU General Public License as published by 37 | * the Free Software Foundation, either version 3 of the License, or 38 | * (at your option) any later version. 39 | * 40 | * SerialCAN is distributed in the hope that it will be useful, 41 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 42 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 43 | * GNU General Public License for more details. 44 | * 45 | * You should have received a copy of the GNU General Public License 46 | * along with SerialCAN. If not, see . 47 | */ 48 | #ifndef VERSION_H_INCLUDED 49 | #define VERSION_H_INCLUDED 50 | #include "build_no.h" 51 | #define VERSION_MAJOR 0 52 | #define VERSION_MINOR 3 53 | #define VERSION_PATCH 0 54 | #define VERSION_BUILD BUILD_NO 55 | #if (VERSION_PATCH == 0) 56 | #define VERSION_STRING TOSTRING(VERSION_MAJOR) "." TOSTRING(VERSION_MINOR) " (" TOSTRING(BUILD_NO) ")" 57 | #else 58 | #define VERSION_STRING TOSTRING(VERSION_MAJOR) "." TOSTRING(VERSION_MINOR) "." TOSTRING(VERSION_PATCH) " (" TOSTRING(BUILD_NO) ")" 59 | #endif 60 | #endif 61 | -------------------------------------------------------------------------------- /Sources/Wrapper/can_defs.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-or-later */ 2 | /* 3 | * CAN Interface API, Version 3 (for CAN-over-Serial-Line Interfaces) 4 | * 5 | * Copyright (c) 2005-2010 Uwe Vogt, UV Software, Friedrichshafen 6 | * Copyright (c) 2016-2022 Uwe Vogt, UV Software, Berlin (info@uv-software.com) 7 | * All rights reserved. 8 | * 9 | * This file is part of SerialCAN. 10 | * 11 | * SerialCAN is dual-licensed under the BSD 2-Clause "Simplified" License 12 | * and under the GNU General Public License v3.0 (or any later version). You can 13 | * choose between one of them if you use SerialCAN in whole or in part. 14 | * 15 | * BSD 2-Clause "Simplified" License: 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted provided that the following conditions are met: 18 | * 1. Redistributions of source code must retain the above copyright notice, this 19 | * list of conditions and the following disclaimer. 20 | * 2. Redistributions in binary form must reproduce the above copyright notice, 21 | * this list of conditions and the following disclaimer in the documentation 22 | * and/or other materials provided with the distribution. 23 | * 24 | * SerialCAN IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | * OF SerialCAN, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | * GNU General Public License v3.0 or later: 36 | * SerialCAN is free software: you can redistribute it and/or modify 37 | * it under the terms of the GNU General Public License as published by 38 | * the Free Software Foundation, either version 3 of the License, or 39 | * (at your option) any later version. 40 | * 41 | * SerialCAN is distributed in the hope that it will be useful, 42 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 43 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 44 | * GNU General Public License for more details. 45 | * 46 | * You should have received a copy of the GNU General Public License 47 | * along with SerialCAN. If not, see . 48 | */ 49 | /** @addtogroup can_api 50 | * @{ 51 | */ 52 | #ifndef CAN_DEFS_H_INCLUDED 53 | #define CAN_DEFS_H_INCLUDED 54 | 55 | /* ----------- includes ------------------------------------------------ 56 | */ 57 | 58 | #include "Version.h" 59 | #include "CANAPI_Defines.h" 60 | #include "SerialCAN_Defines.h" 61 | 62 | 63 | /* ----------- options ------------------------------------------------ 64 | */ 65 | /* note: all options moved into header SerialCAN_Defines.h */ 66 | 67 | 68 | /* ----------- defines ------------------------------------------------ 69 | */ 70 | /* note: all defines moved into header SerialCAN_Defines.h */ 71 | 72 | 73 | /* ----------- types -------------------------------------------------- 74 | */ 75 | /* note: all type definitions moved into header SerialCAN_Defines.h */ 76 | 77 | 78 | #endif /* CAN_DEFS_H_INCLUDED */ 79 | /** @} 80 | */ 81 | /* ---------------------------------------------------------------------- 82 | * Uwe Vogt, UV Software, Chausseestrasse 33 A, 10115 Berlin, Germany 83 | * Tel.: +49-30-46799872, Fax: +49-30-46799873, Mobile: +49-170-3801903 84 | * E-Mail: uwe.vogt@uv-software.de, Homepage: https://www.uv-software.de/ 85 | */ 86 | -------------------------------------------------------------------------------- /Sources/debug.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-or-later */ 2 | /* 3 | * Controler Area Network - Lawicel SLCAN Protocol (Serial-Line CAN) 4 | * 5 | * Copyright (c) 2016-2022 Uwe Vogt, UV Software, Berlin (info@uv-software.com) 6 | * All rights reserved. 7 | * 8 | * This module is dual-licensed under the BSD 2-Clause "Simplified" License and 9 | * under the GNU General Public License v3.0 (or any later version). 10 | * You can choose between one of them if you use this module. 11 | * 12 | * BSD 2-Clause "Simplified" License: 13 | * Redistribution and use in source and binary forms, with or without 14 | * modification, are permitted provided that the following conditions are met: 15 | * 1. Redistributions of source code must retain the above copyright notice, this 16 | * list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 21 | * THIS MODULE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS MODULE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | * GNU General Public License v3.0 or later: 33 | * This module is free software: you can redistribute it and/or modify 34 | * it under the terms of the GNU General Public License as published by 35 | * the Free Software Foundation, either version 3 of the License, or 36 | * (at your option) any later version. 37 | * 38 | * This module is distributed in the hope that it will be useful, 39 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 40 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 41 | * GNU General Public License for more details. 42 | * 43 | * You should have received a copy of the GNU General Public License 44 | * along with this module. If not, see . 45 | */ 46 | #ifndef DEBUG_H_INCLUDED 47 | #define DEBUG_H_INCLUDED 48 | 49 | #include "logger.h" 50 | 51 | #if (OPTION_SLCAN_DEBUG_LEVEL > 0) || (OPTION_SERIAL_DEBUG_LEVEL > 0) 52 | #define LOGGER_INIT(fn) log_init(fn) 53 | #define LOGGER_EXIT() log_exit() 54 | #if defined(_WIN32) || defined(_WIN64) 55 | #define LOGGER_KILL() log_kill() 56 | #endif 57 | #else 58 | #define LOGGER_INIT(fn) while (0) 59 | #define LOGGER_EXIT() while (0) 60 | #if defined(_WIN32) || defined(_WIN64) 61 | #define LOGGER_KILL() while (0) 62 | #endif 63 | #endif 64 | 65 | #endif /* DEBUG_H_INCLUDED */ 66 | -------------------------------------------------------------------------------- /Tests/UnitTests/.gitignore: -------------------------------------------------------------------------------- 1 | .svn 2 | Template.h 3 | # excluded test files 4 | test_can_test.mm 5 | test_can_kill.mm 6 | test_can_bitrate.mm 7 | test_can_busload.mm 8 | test_can_property.mm 9 | test_can_firmware.mm 10 | test_can_hardware.mm 11 | test_can_version.mm 12 | test_can_btr.mm 13 | -------------------------------------------------------------------------------- /Tests/UnitTests/Bitrates.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-or-later 2 | // 3 | // CAN Interface API, Version 3 (Testing) 4 | // 5 | // Copyright (c) 2004-2023 Uwe Vogt, UV Software, Berlin (info@uv-software.com) 6 | // All rights reserved. 7 | // 8 | // This file is part of CAN API V3. 9 | // 10 | // CAN API V3 is dual-licensed under the BSD 2-Clause "Simplified" License and 11 | // under the GNU General Public License v3.0 (or any later version). 12 | // You can choose between one of them if you use this file. 13 | // 14 | // BSD 2-Clause "Simplified" License: 15 | // Redistribution and use in source and binary forms, with or without 16 | // modification, are permitted provided that the following conditions are met: 17 | // 1. Redistributions of source code must retain the above copyright notice, this 18 | // list of conditions and the following disclaimer. 19 | // 2. Redistributions in binary form must reproduce the above copyright notice, 20 | // this list of conditions and the following disclaimer in the documentation 21 | // and/or other materials provided with the distribution. 22 | // 23 | // CAN API V3 IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 27 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 31 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | // OF CAN API V3, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | // 34 | // GNU General Public License v3.0 or later: 35 | // CAN API V3 is free software: you can redistribute it and/or modify 36 | // it under the terms of the GNU General Public License as published by 37 | // the Free Software Foundation, either version 3 of the License, or 38 | // (at your option) any later version. 39 | // 40 | // CAN API V3 is distributed in the hope that it will be useful, 41 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 42 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 43 | // GNU General Public License for more details. 44 | // 45 | // You should have received a copy of the GNU General Public License 46 | // along with CAN API V3. If not, see . 47 | // 48 | #ifndef BITRATES_H_INCLUDED 49 | #define BITRATES_H_INCLUDED 50 | 51 | typedef const char *TBitrateString; 52 | 53 | class CBitrates { 54 | private: 55 | int m_nIndex; 56 | public: 57 | // constructor / destructor 58 | CBitrates(); 59 | virtual ~CBitrates() {}; 60 | // methods 61 | TBitrateString GetFirstEntry(bool fValid = true); 62 | TBitrateString GetNextEntry(bool fValid = true); 63 | // predicates 64 | bool IsInRange(); 65 | bool IsCanFdWithBrse(); 66 | }; 67 | #endif // BITRATES_H_INCLUDED 68 | 69 | // $Id: Bitrates.h 1094 2023-07-23 17:20:14Z makemake $ Copyright (c) UV Software, Berlin // 70 | 71 | -------------------------------------------------------------------------------- /Tests/UnitTests/Parameter.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-or-later 2 | // 3 | // CAN Interface API, Version 3 (Testing) 4 | // 5 | // Copyright (c) 2004-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com) 6 | // All rights reserved. 7 | // 8 | // This file is part of CAN API V3. 9 | // 10 | // CAN API V3 is dual-licensed under the BSD 2-Clause "Simplified" License 11 | // and under the GNU General Public License v3.0 (or any later version). You 12 | // can choose between one of them if you use CAN API V3 in whole or in part. 13 | // 14 | // BSD 2-Clause "Simplified" License: 15 | // Redistribution and use in source and binary forms, with or without 16 | // modification, are permitted provided that the following conditions are met: 17 | // 1. Redistributions of source code must retain the above copyright notice, this 18 | // list of conditions and the following disclaimer. 19 | // 2. Redistributions in binary form must reproduce the above copyright notice, 20 | // this list of conditions and the following disclaimer in the documentation 21 | // and/or other materials provided with the distribution. 22 | // 23 | // CAN API V3 IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 27 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 31 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | // OF CAN API V3, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | // 34 | // GNU General Public License v3.0 or later: 35 | // CAN API V3 is free software: you can redistribute it and/or modify 36 | // it under the terms of the GNU General Public License as published by 37 | // the Free Software Foundation, either version 3 of the License, or 38 | // (at your option) any later version. 39 | // 40 | // CAN API V3 is distributed in the hope that it will be useful, 41 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 42 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 43 | // GNU General Public License for more details. 44 | // 45 | // You should have received a copy of the GNU General Public License 46 | // along with CAN API V3. If not, see . 47 | // 48 | #include "Parameter.h" 49 | #include "Settings.h" 50 | 51 | #include 52 | 53 | #if (SERIAL_CAN_SUPPORTED != 0) 54 | static can_sio_param_t sio_param[2] = {}; 55 | static int init = 0; 56 | 57 | static can_sio_param_t *get_sio_param(int device) { 58 | if (!init) { 59 | sio_param[0].name = (char*)TEST_SERIAL1; 60 | sio_param[1].name = (char*)TEST_SERIAL2; 61 | sio_param[0].attr.protocol = TEST_PROTOCOL1; 62 | sio_param[1].attr.protocol = TEST_PROTOCOL2; 63 | sio_param[1].attr.baudrate = sio_param[0].attr.baudrate = CANSIO_BD57600; 64 | sio_param[1].attr.bytesize = sio_param[0].attr.bytesize = CANSIO_8DATABITS; 65 | sio_param[1].attr.stopbits = sio_param[0].attr.stopbits = CANSIO_1STOPBIT; 66 | sio_param[1].attr.parity = sio_param[0].attr.parity = CANSIO_NOPARITY; 67 | init = 1; 68 | } 69 | if ((0 <= device) && (device <= 1)) 70 | return &sio_param[device]; 71 | else 72 | return NULL; 73 | } 74 | #endif 75 | 76 | void *GetParameter(int device) { 77 | #if (SERIAL_CAN_SUPPORTED != 0) 78 | // CAN over serial devices require an additional parameter (COM port) 79 | return (void*)get_sio_param(device); 80 | #else 81 | // other USB CAN devices not (plug 'n' play) 82 | return (void*)NULL; 83 | #endif 84 | } 85 | 86 | // $Id: Parameter.cpp 1341 2024-06-15 16:43:48Z makemake $ Copyright (c) UV Software, Berlin // 87 | -------------------------------------------------------------------------------- /Tests/UnitTests/Parameter.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-or-later 2 | // 3 | // CAN Interface API, Version 3 (Testing) 4 | // 5 | // Copyright (c) 2004-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com) 6 | // All rights reserved. 7 | // 8 | // This file is part of CAN API V3. 9 | // 10 | // CAN API V3 is dual-licensed under the BSD 2-Clause "Simplified" License 11 | // and under the GNU General Public License v3.0 (or any later version). You 12 | // can choose between one of them if you use CAN API V3 in whole or in part. 13 | // 14 | // BSD 2-Clause "Simplified" License: 15 | // Redistribution and use in source and binary forms, with or without 16 | // modification, are permitted provided that the following conditions are met: 17 | // 1. Redistributions of source code must retain the above copyright notice, this 18 | // list of conditions and the following disclaimer. 19 | // 2. Redistributions in binary form must reproduce the above copyright notice, 20 | // this list of conditions and the following disclaimer in the documentation 21 | // and/or other materials provided with the distribution. 22 | // 23 | // CAN API V3 IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 27 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 31 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | // OF CAN API V3, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | // 34 | // GNU General Public License v3.0 or later: 35 | // CAN API V3 is free software: you can redistribute it and/or modify 36 | // it under the terms of the GNU General Public License as published by 37 | // the Free Software Foundation, either version 3 of the License, or 38 | // (at your option) any later version. 39 | // 40 | // CAN API V3 is distributed in the hope that it will be useful, 41 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 42 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 43 | // GNU General Public License for more details. 44 | // 45 | // You should have received a copy of the GNU General Public License 46 | // along with CAN API V3. If not, see . 47 | // 48 | #ifndef PARAMETER_H_INCLUDED 49 | #define PARAMETER_H_INCLUDED 50 | 51 | extern void *GetParameter(int device); 52 | 53 | #endif // PARAMETER_H_INCLUDED 54 | 55 | // $Id: Parameter.h 1341 2024-06-15 16:43:48Z makemake $ Copyright (c) UV Software, Berlin // 56 | -------------------------------------------------------------------------------- /Tests/UnitTests/README.md: -------------------------------------------------------------------------------- 1 | _Copyright © 2004-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com)_ \ 2 | _All rights reserved._ 3 | 4 | Version $Rev: 1334 $ 5 | 6 | # A CAN Interface Wrapper Specification 7 | 8 | [CAN API V3](https://mac-can.github.io/wrapper/canapi-v3/) is a wrapper specification by UV Software to have a uniform CAN Interface API for various CAN interfaces from different vendors running under multiple operating systems. 9 | Due to the fact that the CAN APIs of the different OEMs are not compatible with each other, UV Software has defined a CAN Interface Wrapper specification. 10 | Its goal is to have a multi-vendor, cross-platform CAN Interface API. 11 | 12 | # CAN Interface API, Version 3 13 | 14 | In case of doubt the source code: 15 | 16 | ```C 17 | #if (OPTION_CANAPI_LIBRARY != 0) 18 | extern int can_test(int32_t library, int32_t channel, uint8_t mode, const void *param, int *result); 19 | extern int can_init(int32_t library, int32_t channel, uint8_t mode, const void *param); 20 | #else 21 | extern int can_test(int32_t channel, uint8_t mode, const void *param, int *result); 22 | extern int can_init(int32_t channel, uint8_t mode, const void *param); 23 | #endif 24 | extern int can_exit(int handle); 25 | extern int can_kill(int handle); 26 | 27 | extern int can_start(int handle, const can_bitrate_t *bitrate); 28 | extern int can_reset(int handle); 29 | 30 | extern int can_write(int handle, const can_message_t *message, uint16_t timeout); 31 | extern int can_read(int handle, can_message_t *message, uint16_t timeout); 32 | 33 | extern int can_status(int handle, uint8_t *status); 34 | extern int can_busload(int handle, uint8_t *load, uint8_t *status); 35 | 36 | extern int can_bitrate(int handle, can_bitrate_t *bitrate, can_speed_t *speed); 37 | extern int can_property(int handle, uint16_t param, void *value, uint32_t nbyte); 38 | 39 | extern char *can_hardware(int handle); 40 | extern char *can_firmware(int handle); 41 | 42 | #if (OPTION_CANAPI_LIBRARY != 0) 43 | extern char *can_library(int handle); 44 | #endif 45 | extern char* can_version(void); 46 | ``` 47 | See header file `can_api.h` for a description of the provided functions. 48 | 49 | ## CAN API V3 Testing 50 | 51 | ### Xcodetest 52 | 53 | Tbd. 54 | 55 | ### GoogleTest 56 | 57 | Tbd. 58 | 59 | ## This and That 60 | 61 | ### SVN Repo 62 | 63 | The CAN API V3 Testing sources are maintained in a SVN repo to synchronized them between the different CAN API V3 wrapper repos. 64 | 65 | ### Dual-License 66 | 67 | This work is dual-licensed under the terms of the BSD 2-Clause "Simplified" License and under the terms of the GNU General Public License v3.0 (or any later version). 68 | You can choose between one of them if you use this work in whole or in part. 69 | 70 | `SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-or-later` 71 | 72 | ### Contact 73 | 74 | E-Mail: mailto://info@uv-software.com \ 75 | Internet: https://www.uv-software.com 76 | -------------------------------------------------------------------------------- /Tests/UnitTests/Tester.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-or-later 2 | // 3 | // CAN Interface API, Version 3 (Testing) 4 | // 5 | // Copyright (c) 2004-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com) 6 | // All rights reserved. 7 | // 8 | // This file is part of CAN API V3. 9 | // 10 | // CAN API V3 is dual-licensed under the BSD 2-Clause "Simplified" License 11 | // and under the GNU General Public License v3.0 (or any later version). You 12 | // can choose between one of them if you use CAN API V3 in whole or in part. 13 | // 14 | // BSD 2-Clause "Simplified" License: 15 | // Redistribution and use in source and binary forms, with or without 16 | // modification, are permitted provided that the following conditions are met: 17 | // 1. Redistributions of source code must retain the above copyright notice, this 18 | // list of conditions and the following disclaimer. 19 | // 2. Redistributions in binary form must reproduce the above copyright notice, 20 | // this list of conditions and the following disclaimer in the documentation 21 | // and/or other materials provided with the distribution. 22 | // 23 | // CAN API V3 IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 27 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 31 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | // OF CAN API V3, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | // 34 | // GNU General Public License v3.0 or later: 35 | // CAN API V3 is free software: you can redistribute it and/or modify 36 | // it under the terms of the GNU General Public License as published by 37 | // the Free Software Foundation, either version 3 of the License, or 38 | // (at your option) any later version. 39 | // 40 | // CAN API V3 is distributed in the hope that it will be useful, 41 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 42 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 43 | // GNU General Public License for more details. 44 | // 45 | // You should have received a copy of the GNU General Public License 46 | // along with CAN API V3. If not, see . 47 | // 48 | #ifndef TESTER_H_INCLUDED 49 | #define TESTER_H_INCLUDED 50 | 51 | // HowTo: make a copy of header 'Template.h' and name it 'Driver.h' 52 | // set define 'CDriverCAN' to your MacCAN Driver Under Test 53 | // and adapt the driver specific test settings there 54 | #include "Driver.h" 55 | #include "Settings.h" 56 | #include "Parameter.h" 57 | 58 | class CTester : CDriverCAN { 59 | public: 60 | // constructor / destructor 61 | CTester() {}; 62 | virtual ~CTester() {}; 63 | // methods 64 | int SendSomeFrames(int handle, int32_t channel, int frames = 1, uint32_t canId = 0x100U); 65 | int ReceiveSomeFrames(int handle, int32_t channel, int frames = 1, uint32_t canId = 0x200U); 66 | private: 67 | int CheckReceivedId(const CANAPI_Message_t &message, int32_t canId); 68 | int CheckReceivedDlc(const CANAPI_Message_t &message, uint8_t canDlc); 69 | int CheckReceivedData(const CANAPI_Message_t &message, uint64_t &expected); 70 | public: 71 | static uint8_t Dlc2Len(uint8_t dlc) { return CCanApi::Dlc2Len(dlc); } 72 | static uint8_t Len2Dlc(uint8_t len) { return CCanApi::Len2Dlc(len); }}; 73 | 74 | #endif // TESTER_H_INCLUDED 75 | 76 | // $Id: Tester.h 1341 2024-06-15 16:43:48Z makemake $ Copyright (c) UV Software, Berlin // 77 | -------------------------------------------------------------------------------- /Tests/UnitTests/Timer.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-or-later 2 | // 3 | // Software for Industrial Communication, Motion Control and Automation 4 | // 5 | // Copyright (c) 2002-2021 Uwe Vogt, UV Software, Berlin (info@uv-software.com) 6 | // All rights reserved. 7 | // 8 | // This class is dual-licensed under the BSD 2-Clause "Simplified" License and 9 | // under the GNU General Public License v3.0 (or any later version). 10 | // You can choose between one of them if you use this class. 11 | // 12 | // BSD 2-Clause "Simplified" License: 13 | // Redistribution and use in source and binary forms, with or without 14 | // modification, are permitted provided that the following conditions are met: 15 | // 1. Redistributions of source code must retain the above copyright notice, this 16 | // list of conditions and the following disclaimer. 17 | // 2. Redistributions in binary form must reproduce the above copyright notice, 18 | // this list of conditions and the following disclaimer in the documentation 19 | // and/or other materials provided with the distribution. 20 | // 21 | // THIS CLASS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS CLASS, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | // 32 | // GNU General Public License v3.0 or later: 33 | // This class is free software: you can redistribute it and/or modify 34 | // it under the terms of the GNU General Public License as published by 35 | // the Free Software Foundation, either version 3 of the License, or 36 | // (at your option) any later version. 37 | // 38 | // This class is distributed in the hope that it will be useful, 39 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 40 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 41 | // GNU General Public License for more details. 42 | // 43 | // You should have received a copy of the GNU General Public License 44 | // along with this class. If not, see . 45 | // 46 | #ifndef TIMER_H_INCLUDED 47 | #define TIMER_H_INCLUDED 48 | 49 | #if _MSC_VER > 1000 50 | #pragma once 51 | #endif 52 | 53 | #include 54 | #if defined(_WIN32) || defined(_WIN64) 55 | #include 56 | #endif 57 | 58 | #if defined(_WIN32) || defined(_WIN64) 59 | #define CTIMER_WAITABLE_TIMER // a Windows alternative for usleep() 60 | #endif 61 | 62 | class CTimer { 63 | public: 64 | static const uint32_t USEC = 1U; // 1 microsecond 65 | static const uint32_t MSEC = 1000U; // 1 millisecond 66 | static const uint32_t SEC = 1000000U; // 1 second 67 | static const uint32_t MIN = 60000000U; // 1 minute 68 | private: 69 | #if !defined(_WIN32) && !defined(_WIN64) 70 | uint64_t m_u64UntilStop; // counter value for the desired time-out 71 | #else 72 | LARGE_INTEGER m_largeFrequency; // frequency in counts per second 73 | LONGLONG m_llUntilStop; // counter value for the desired time-out 74 | #endif 75 | public: 76 | CTimer(uint32_t u32Microseconds = 0); 77 | virtual ~CTimer() {}; 78 | 79 | bool Restart(uint32_t u32Timeout); // restart the timer! 80 | bool Timeout(); // time-out occurred? 81 | 82 | static bool Delay(uint32_t u32Delay); // delay timer 83 | }; 84 | 85 | #endif // TIMER_H_INCLUDED 86 | 87 | // $Id: Timer.h 710 2021-05-25 15:35:30Z eris $ Copyright (c) UV Software, Berlin // 88 | -------------------------------------------------------------------------------- /Trial/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Trial Program 3 | # SerialCAN (SLCAN protocol) 4 | # Bart Simpson didn't do it 5 | # 6 | current_OS := $(shell sh -c 'uname 2>/dev/null || echo Unknown OS') 7 | current_OS := $(patsubst CYGWIN%,Cygwin,$(current_OS)) 8 | current_OS := $(patsubst MINGW%,MinGW,$(current_OS)) 9 | current_OS := $(patsubst MSYS%,MinGW,$(current_OS)) 10 | 11 | 12 | ifeq ($(current_OS),$(filter $(current_OS),Linux Darwin)) 13 | TARGET = slc_test 14 | else 15 | TARGET = slc_test.exe 16 | endif 17 | 18 | INSTALL = ~/bin 19 | 20 | HOME_DIR = .. 21 | MAIN_DIR = ./Sources 22 | 23 | SOURCE_DIR = $(HOME_DIR)/Sources 24 | SERIAL_DIR = $(HOME_DIR)/Sources/SLCAN 25 | CANAPI_DIR = $(HOME_DIR)/Sources/CANAPI 26 | WRAPPER_DIR = $(HOME_DIR)/Sources/Wrapper 27 | 28 | OBJECTS = $(OUTDIR)/SerialCAN.o \ 29 | $(OUTDIR)/can_api.o $(OUTDIR)/can_btr.o \ 30 | $(OUTDIR)/slcan.o $(OUTDIR)/serial.o \ 31 | $(OUTDIR)/buffer.o $(OUTDIR)/queue.o \ 32 | $(OUTDIR)/timer.o $(OUTDIR)/logger.o \ 33 | $(OUTDIR)/main.o 34 | 35 | DEFINES = -DOPTION_CAN_2_0_ONLY=0 \ 36 | -DOPTION_CANAPI_DRIVER=1 \ 37 | -DOPTION_CANAPI_RETVALS=0 \ 38 | -DOPTION_CANAPI_COMPANIONS=1 \ 39 | -DOPTION_CANAPI_DEBUG_LEVEL=0 \ 40 | -DOPTION_SERIAL_DEBUG_LEVEL=3 \ 41 | -DOPTION_SLCAN_FAKE_COMMANDS=1 \ 42 | -DOPTION_SLCAN_DEBUG_LEVEL=1 43 | 44 | HEADERS = -I$(SOURCE_DIR) \ 45 | -I$(SERIAL_DIR) \ 46 | -I$(CANAPI_DIR) \ 47 | -I$(WRAPPER_DIR) \ 48 | -I$(MAIN_DIR) 49 | 50 | 51 | ifeq ($(current_OS),Darwin) # macOS - libSerialCAN.dylib 52 | 53 | CFLAGS += -O0 -g -Wall -Wextra -Wno-parentheses \ 54 | -fmessage-length=0 -fno-strict-aliasing \ 55 | $(DEFINES) \ 56 | $(HEADERS) 57 | 58 | CXXFLAGS += -O0 -g -Wall -Wextra -pthread \ 59 | $(DEFINES) \ 60 | $(HEADERS) 61 | 62 | LDFLAGS += 63 | 64 | ifeq ($(BINARY),UNIVERSAL) 65 | CFLAGS += -arch arm64 -arch x86_64 66 | CXXFLAGS += -arch arm64 -arch x86_64 67 | LDFLAGS += -arch arm64 -arch x86_64 68 | endif 69 | 70 | LIBRARIES = -lpthread 71 | 72 | CHECKER = warning,information 73 | 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 -i vanilla.c 74 | ifeq ($(HUNTER),BUGS) 75 | CHECKER += --bug-hunting 76 | endif 77 | 78 | ifeq ($(XCTEST),FULL) 79 | TESTING = 80 | else 81 | TESTING = -only-testing Testing/Testing/testSmokeTest 82 | endif 83 | 84 | CXX = clang++ 85 | CC = clang 86 | LD = clang++ 87 | endif 88 | 89 | ifeq ($(current_OS),$(filter $(current_OS),Linux Cygwin)) # Linux, Cygwin - libserialcan.so 90 | 91 | CFLAGS += -O0 -g -Wall -Wextra -Wno-parentheses \ 92 | -fmessage-length=0 -fno-strict-aliasing \ 93 | $(DEFINES) \ 94 | $(HEADERS) 95 | 96 | CXXFLAGS += -O0 -g -Wall -Wextra -pthread \ 97 | $(DEFINES) \ 98 | $(HEADERS) 99 | 100 | LDFLAGS += 101 | 102 | LIBRARIES = -lpthread 103 | 104 | CXX = g++ 105 | CC = gcc 106 | LD = g++ 107 | endif 108 | 109 | RM = rm -f 110 | CP = cp -f 111 | 112 | OUTDIR = .objects 113 | 114 | 115 | .PHONY: info outdir 116 | 117 | 118 | all: info outdir $(TARGET) 119 | 120 | info: 121 | @echo $(CXX)" on "$(current_OS) 122 | @echo "target: "$(TARGET) 123 | @echo "install: "$(INSTALL) 124 | 125 | outdir: 126 | @mkdir -p $(OUTDIR) 127 | 128 | check: 129 | ifeq ($(current_OS),Darwin) # macOS - libSerialCAN.dylib 130 | cppcheck --enable=$(CHECKER) --suppressions-list=$(HOME_DIR)/suppress.txt \ 131 | -D__APPLE__ $(DEFINES) $(HEADERS) $(IGNORE) $(SOURCE_DIR) 132 | else 133 | echo "Please use Cppcheck GUI" 134 | endif 135 | 136 | clean: 137 | @-$(RM) $(TARGET) $(OUTDIR)/*.o $(OUTDIR)/*.d 138 | 139 | pristine: 140 | @-$(RM) $(TARGET) $(OUTDIR)/*.o $(OUTDIR)/*.d 141 | 142 | install: 143 | $(CP) $(TARGET) $(INSTALL) 144 | 145 | test: info outdir $(TARGET) 146 | ./$(TARGET) INFO EXIT 147 | 148 | xctest: 149 | xcodebuild clean build test -project SerialCAN.xcodeproj -scheme Testing $(TESTING) 150 | 151 | 152 | $(OUTDIR)/main.o: $(MAIN_DIR)/main.cpp 153 | $(CXX) $(CXXFLAGS) -MMD -MF $*.d -o $@ -c $< 154 | 155 | $(OUTDIR)/SerialCAN.o: $(SOURCE_DIR)/SerialCAN.cpp 156 | $(CXX) $(CXXFLAGS) -MMD -MF $*.d -o $@ -c $< 157 | 158 | $(OUTDIR)/can_api.o: $(WRAPPER_DIR)/can_api.c 159 | $(CC) $(CFLAGS) -MMD -MF $*.d -o $@ -c $< 160 | 161 | $(OUTDIR)/can_btr.o: $(CANAPI_DIR)/can_btr.c 162 | $(CC) $(CFLAGS) -MMD -MF $*.d -o $@ -c $< 163 | 164 | $(OUTDIR)/slcan.o: $(SERIAL_DIR)/slcan.c 165 | $(CC) $(CFLAGS) -MMD -MF $*.d -o $@ -c $< 166 | 167 | $(OUTDIR)/serial.o: $(SERIAL_DIR)/serial.c $(SERIAL_DIR)/serial_p.c 168 | $(CC) $(CFLAGS) -MMD -MF $*.d -o $@ -c $< 169 | 170 | $(OUTDIR)/buffer.o: $(SERIAL_DIR)/buffer.c $(SERIAL_DIR)/buffer_p.c 171 | $(CC) $(CFLAGS) -MMD -MF $*.d -o $@ -c $< 172 | 173 | $(OUTDIR)/queue.o: $(SERIAL_DIR)/queue.c $(SERIAL_DIR)/queue_p.c 174 | $(CC) $(CFLAGS) -MMD -MF $*.d -o $@ -c $< 175 | 176 | $(OUTDIR)/timer.o: $(SERIAL_DIR)/timer.c $(SERIAL_DIR)/timer_p.c 177 | $(CC) $(CFLAGS) -MMD -MF $*.d -o $@ -c $< 178 | 179 | $(OUTDIR)/logger.o: $(SERIAL_DIR)/logger.c $(SERIAL_DIR)/logger_p.c 180 | $(CC) $(CFLAGS) -MMD -MF $*.d -o $@ -c $< 181 | 182 | 183 | $(TARGET): $(OBJECTS) 184 | $(LD) $(LDFLAGS) -o $@ $(OBJECTS) $(LIBRARIES) 185 | ifeq ($(current_OS),Darwin) 186 | @lipo -archs $@ 187 | endif 188 | @echo "\033[1mTarget '"$@"' successfully build\033[0m" 189 | -------------------------------------------------------------------------------- /Trial/slc_test.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 17.0 47 | Win32Proj 48 | {6021dda0-8d58-4d58-b14e-c756e4fa3cbb} 49 | slctest 50 | 10.0 51 | 52 | 53 | 54 | Application 55 | true 56 | v143 57 | Unicode 58 | 59 | 60 | Application 61 | true 62 | v143 63 | Unicode 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | Level3 80 | true 81 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);OPTION_CAN_2_0_ONLY=1;OPTION_CANAPI_DRIVER=1;OPTION_CANAPI_RETVALS=0;OPTION_CANAPI_COMPANIONS=1;OPTION_CANAPI_DEBUG_LEVEL=0;OPTION_SLCAN_FAKE_COMMANDS=1;OPTION_SLCAN_DEBUG_LEVEL=1;OPTION_SERIAL_DEBUG_LEVEL=3 82 | true 83 | .\Sources;..\Sources;..\Sources\CANAPI;..\Sources\SLCAN;..\Sources\Wrapper;%(AdditionalIncludeDirectories) 84 | 85 | 86 | Console 87 | true 88 | 89 | 90 | 91 | 92 | Level3 93 | true 94 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions);OPTION_CAN_2_0_ONLY=1;OPTION_CANAPI_DRIVER=1;OPTION_CANAPI_RETVALS=0;OPTION_CANAPI_COMPANIONS=1;OPTION_CANAPI_DEBUG_LEVEL=0;OPTION_SLCAN_FAKE_COMMANDS=1;OPTION_SLCAN_DEBUG_LEVEL=1;OPTION_SERIAL_DEBUG_LEVEL=3 95 | true 96 | .\Sources;..\Sources;..\Sources\CANAPI;..\Sources\SLCAN;..\Sources\Wrapper;%(AdditionalIncludeDirectories) 97 | 98 | 99 | Console 100 | true 101 | 102 | 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /Trial/slc_test.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {7c3efe7d-f1b0-4acb-bc3f-31a291f4d0a9} 18 | 19 | 20 | {4357ffe9-613c-4500-af3e-34e33b44788d} 21 | 22 | 23 | {f578053c-79fd-4497-8b38-3bdb74236732} 24 | 25 | 26 | {f3f7440a-c957-4e1a-8636-5cabc1ce461d} 27 | 28 | 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files\CANAPI 38 | 39 | 40 | Source Files\CANAPI 41 | 42 | 43 | Source Files\SLCAN 44 | 45 | 46 | Source Files\SLCAN 47 | 48 | 49 | Source Files\SLCAN 50 | 51 | 52 | Source Files\SLCAN 53 | 54 | 55 | Source Files\SLCAN 56 | 57 | 58 | Source Files\SLCAN 59 | 60 | 61 | 62 | 63 | Header Files\SLCAN 64 | 65 | 66 | Header Files\SLCAN 67 | 68 | 69 | Header Files\SLCAN 70 | 71 | 72 | Header Files\SLCAN 73 | 74 | 75 | Header Files\SLCAN 76 | 77 | 78 | Header Files\SLCAN 79 | 80 | 81 | Header Files\CANAPI 82 | 83 | 84 | Header Files\CANAPI 85 | 86 | 87 | Header Files\CANAPI 88 | 89 | 90 | Header Files\CANAPI 91 | 92 | 93 | Header Files\CANAPI 94 | 95 | 96 | Header Files\CANAPI 97 | 98 | 99 | Header Files\CANAPI 100 | 101 | 102 | Header Files 103 | 104 | 105 | Header Files 106 | 107 | 108 | Header Files 109 | 110 | 111 | Header Files 112 | 113 | 114 | Header Files\SLCAN 115 | 116 | 117 | -------------------------------------------------------------------------------- /Trial/slc_test.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Trial/slc_test.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Trial/slc_test.xcodeproj/xcshareddata/xcschemes/SerialCAN.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 45 | 51 | 52 | 53 | 54 | 57 | 58 | 61 | 62 | 65 | 66 | 69 | 70 | 71 | 72 | 78 | 80 | 86 | 87 | 88 | 89 | 91 | 92 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /Trial/slc_test.xcodeproj/xcshareddata/xcschemes/Testing.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 53 | 54 | 60 | 61 | 67 | 68 | 69 | 70 | 72 | 73 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /Utilities/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # CAN Utilities for generic CAN Interfaces (CAN API V3) 3 | # 4 | # Copyright (c) 2005-2010 Uwe Vogt, UV Software, Friedrichshafen 5 | # Copyright (c) 2012-2024 Uwe Vogt, UV Software, Berlin (info@mac-can.com) 6 | # 7 | # These utilities are free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # These utilities is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with these utilities. If not, see . 19 | # 20 | all: 21 | @echo "\033[1mBuilding my beloved CAN Utilities...\033[0m" 22 | $(MAKE) -C can_test $@ 23 | $(MAKE) -C can_moni $@ 24 | 25 | clean: 26 | $(MAKE) -C can_test $@ 27 | $(MAKE) -C can_moni $@ 28 | 29 | pristine: 30 | $(MAKE) -C can_test $@ 31 | $(MAKE) -C can_moni $@ 32 | 33 | install: 34 | # $(MAKE) -C can_test $@ 35 | # $(MAKE) -C can_moni $@ 36 | -------------------------------------------------------------------------------- /Utilities/can_moni/Driver.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // 3 | // CAN Monitor for CAN-over-Serial-Line Interfaces (CAN API V3) 4 | // 5 | // Copyright (c) 2007,2012-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com) 6 | // 7 | // This program is free software: you can redistribute it and/or modify 8 | // it under the terms of the GNU General Public License as published by 9 | // the Free Software Foundation, either version 3 of the License, or 10 | // (at your option) any later version. 11 | // 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | // 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program. If not, see . 19 | // 20 | #ifndef DRIVER_H_INCLUDED 21 | #define DRIVER_H_INCLUDED 22 | 23 | #include "SerialCAN.h" 24 | 25 | #if (OPTION_CAN_2_0_ONLY != 0) 26 | #ifdef _MSC_VER 27 | #pragma message ( "Compilation with legacy CAN 2.0 frame format!" ) 28 | #else 29 | #warning Compilation with legacy CAN 2.0 frame format! 30 | #endif 31 | #else 32 | #define CAN_FD_SUPPORTED 0 // set to non-zero once CAN FD is supported 33 | #endif 34 | #define SERIAL_CAN_SUPPORTED 1 // requires additional parameter (COM port) 35 | 36 | #define MONITOR_INTERFACE "CAN-over-Serial-Line Interfaces" 37 | #define MONITOR_COPYRIGHT "2007,2012-2024 by Uwe Vogt, UV Software, Berlin" 38 | #if defined(_WIN32) || defined(_WIN64) 39 | #define MONITOR_PLATFORM "Windows" 40 | #define MONITOR_TTYNAME "\\\\.\\COM" 41 | #elif defined(__linux__) 42 | #define MONITOR_PLATFORM "Linux" 43 | #define MONITOR_TTYNAME "/dev/ttyUSB" 44 | #elif defined(__CYGWIN__) 45 | #define MONITOR_PLATFORM "Cygwin" 46 | #define MONITOR_TTYNAME "/dev/ttyS" 47 | #elif defined(__APPLE__) 48 | #define MONITOR_PLATFORM "Darwin" 49 | #define MONITOR_TTYNAME "/dev/tty.usbserial-" 50 | #endif 51 | #define MONITOR_ALIASNAME "SLC:" 52 | 53 | #define BITRATE_1M(x) DEFAULT_CAN_BR_1M(x) 54 | #define BITRATE_800K(x) DEFAULT_CAN_BR_800K(x) 55 | #define BITRATE_500K(x) DEFAULT_CAN_BR_500K(x) 56 | #define BITRATE_250K(x) DEFAULT_CAN_BR_250K(x) 57 | #define BITRATE_125K(x) DEFAULT_CAN_BR_125K(x) 58 | #define BITRATE_100K(x) DEFAULT_CAN_BR_100K(x) 59 | #define BITRATE_50K(x) DEFAULT_CAN_BR_50K(x) 60 | #define BITRATE_20K(x) DEFAULT_CAN_BR_20K(x) 61 | #define BITRATE_10K(x) DEFAULT_CAN_BR_10K(x) 62 | 63 | #if (CAN_FD_SUPPORTED != 0) 64 | #define BITRATE_FD_1M(x) DEFAULT_CAN_FD_BR_1M(x) 65 | #define BITRATE_FD_500K(x) DEFAULT_CAN_FD_BR_500K(x) 66 | #define BITRATE_FD_250K(x) DEFAULT_CAN_FD_BR_250K(x) 67 | #define BITRATE_FD_125K(x) DEFAULT_CAN_FD_BR_125K(x) 68 | #define BITRATE_FD_1M8M(x) DEFAULT_CAN_FD_BR_1M8M(x) 69 | #define BITRATE_FD_500K4M(x) DEFAULT_CAN_FD_BR_500K4M(x) 70 | #define BITRATE_FD_250K2M(x) DEFAULT_CAN_FD_BR_250K2M(x) 71 | #define BITRATE_FD_125K1M(x) DEFAULT_CAN_FD_BR_125K1M(x) 72 | #endif 73 | 74 | typedef CSerialCAN CCanDriver; 75 | 76 | #endif // DRIVER_H_INCLUDED 77 | -------------------------------------------------------------------------------- /Utilities/can_moni/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # CAN Monitor for CAN-over-Serial-Line Interfaces (CAN API V3) 3 | # 4 | # Copyright (c) 2007 by Uwe Vogt, UV Software, Friedrichshafen 5 | # Copyright (c) 2012-2024 Uwe Vogt, UV Software, Berlin (info@uv-software.com) 6 | # 7 | # This program is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program If not, see . 19 | # 20 | current_OS := $(shell sh -c 'uname 2>/dev/null || echo Unknown OS') 21 | current_OS := $(patsubst CYGWIN%,Cygwin,$(current_OS)) 22 | current_OS := $(patsubst MINGW%,MinGW,$(current_OS)) 23 | current_OS := $(patsubst MSYS%,MinGW,$(current_OS)) 24 | 25 | 26 | ifeq ($(current_OS),$(filter $(current_OS),Linux Darwin)) 27 | TARGET = can_moni 28 | else 29 | TARGET = can_moni.exe 30 | endif 31 | INSTALL = ~/bin 32 | 33 | PROJ_DIR = ../.. 34 | HOME_DIR = . 35 | MAIN_DIR = ./Sources 36 | 37 | DRIVER_DIR = $(PROJ_DIR)/Sources 38 | CANAPI_DIR = $(PROJ_DIR)/Sources/CANAPI 39 | 40 | OBJECTS = $(OUTDIR)/main.o $(OUTDIR)/Options.o $(OUTDIR)/Timer.o \ 41 | $(OUTDIR)/Message.o $(OUTDIR)/can_msg.o 42 | 43 | DEFINES = -DOPTION_CANAPI_DRIVER=1 \ 44 | -DOPTION_CANAPI_COMPANIONS=1 45 | 46 | HEADERS = -I$(MAIN_DIR) \ 47 | -I$(HOME_DIR) \ 48 | -I$(DRIVER_DIR) \ 49 | -I$(CANAPI_DIR) 50 | 51 | 52 | ifeq ($(current_OS),Darwin) # macOS - libSerialCAN.dylib 53 | 54 | OBJECTS += $(BINDIR)/libSerialCAN.a 55 | 56 | CFLAGS += -O2 -Wall -Wextra -Wno-parentheses \ 57 | -fno-strict-aliasing \ 58 | $(DEFINES) \ 59 | $(HEADERS) 60 | 61 | CXXFLAGS += -O2 -g -Wall -Wextra -pthread \ 62 | $(DEFINES) \ 63 | $(HEADERS) 64 | 65 | LDFLAGS += -rpath /usr/local/lib 66 | 67 | ifeq ($(BINARY),UNIVERSAL) 68 | CFLAGS += -arch arm64 -arch x86_64 69 | CXXFLAGS += -arch arm64 -arch x86_64 70 | LDFLAGS += -arch arm64 -arch x86_64 71 | endif 72 | 73 | LIBRARIES = -lpthread 74 | 75 | CXX = clang++ 76 | CC = clang 77 | LD = clang++ 78 | endif 79 | 80 | ifeq ($(current_OS),$(filter $(current_OS),Linux Cygwin)) # linux - libserialcan.so 81 | 82 | OBJECTS += $(BINDIR)/libserialcan.a 83 | 84 | CFLAGS += -O2 -Wall -Wextra -Wno-parentheses \ 85 | -fno-strict-aliasing \ 86 | $(DEFINES) \ 87 | $(HEADERS) 88 | 89 | CXXFLAGS += -O2 -g -Wall -Wextra -pthread \ 90 | $(DEFINES) \ 91 | $(HEADERS) 92 | 93 | LDFLAGS += 94 | 95 | LIBRARIES = -lpthread 96 | 97 | CXX = g++ 98 | CC = gcc 99 | LD = g++ 100 | endif 101 | 102 | RM = rm -f 103 | CP = cp -f 104 | 105 | OUTDIR = .objects 106 | BINDIR = $(PROJ_DIR)/Binaries 107 | INCDIR = $(PROJ_DIR)/Includes 108 | 109 | .PHONY: info outdir bindir incdir 110 | 111 | 112 | all: info outdir bindir incdir $(TARGET) 113 | 114 | info: 115 | @echo $(CXX)" on "$(current_OS) 116 | @echo "target: "$(TARGET) 117 | @echo "install: "$(INSTALL) 118 | 119 | outdir: 120 | @mkdir -p $(OUTDIR) 121 | 122 | bindir: 123 | @mkdir -p $(BINDIR) 124 | 125 | incdir: 126 | @mkdir -p $(INCDIR) 127 | 128 | clean: 129 | @-$(RM) $(TARGET) $(OUTDIR)/*.o $(OUTDIR)/*.d 130 | 131 | pristine: 132 | @-$(RM) $(TARGET) $(OUTDIR)/*.o $(OUTDIR)/*.d 133 | @-$(RM) $(BINDIR)/$(TARGET) 134 | 135 | install: 136 | @echo "Copying binary file..." 137 | $(CP) $(TARGET) $(INSTALL) 138 | 139 | 140 | $(OUTDIR)/main.o: $(MAIN_DIR)/main.cpp 141 | $(CXX) $(CXXFLAGS) -MMD -MF $*.d -o $@ -c $< 142 | 143 | $(OUTDIR)/Options.o: $(MAIN_DIR)/Options_p.cpp 144 | $(CXX) $(CXXFLAGS) -MMD -MF $*.d -o $@ -c $< 145 | 146 | $(OUTDIR)/Timer.o: $(MAIN_DIR)/Timer.cpp 147 | $(CXX) $(CXXFLAGS) -MMD -MF $*.d -o $@ -c $< 148 | 149 | $(OUTDIR)/Message.o: $(MAIN_DIR)/Message.cpp 150 | $(CXX) $(CXXFLAGS) -MMD -MF $*.d -o $@ -c $< 151 | 152 | $(OUTDIR)/can_msg.o: $(CANAPI_DIR)/can_msg.c 153 | $(CC) $(CFLAGS) -MMD -MF $*.d -o $@ -c $< 154 | 155 | 156 | $(TARGET): $(OBJECTS) 157 | $(LD) $(LDFLAGS) -o $@ $(OBJECTS) $(LIBRARIES) 158 | $(CP) $(TARGET) $(BINDIR) 159 | ifeq ($(current_OS),Darwin) 160 | @lipo -archs $@ 161 | endif 162 | @echo "\033[1mTarget '"$@"' successfully build\033[0m" 163 | -------------------------------------------------------------------------------- /Utilities/can_moni/README.md: -------------------------------------------------------------------------------- 1 | __CAN Monitor for CAN-over-Serial-Line Interfaces, Version 0.3__ \ 2 | Copyright © 2007,2012-2024 by Uwe Vogt, UV Software, Berlin 3 | 4 | ``` 5 | Usage: can_moni [