diff --git a/.github/workflows/arduino-ci.yml b/.github/workflows/arduino-ci.yml new file mode 100644 index 0000000..7b726b3 --- /dev/null +++ b/.github/workflows/arduino-ci.yml @@ -0,0 +1,67 @@ +name: Arduino Examples CI + +on: + push: + paths-ignore: + - '**.md' + pull_request: + +jobs: + compile-examples: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + board: + - name: "Arduino Uno" + fqbn: "arduino:avr:uno" + platform: "arduino:avr" + - name: "ESP32 Dev Module" + fqbn: "esp32:esp32:esp32" + platform: "esp32:esp32" + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Arduino CLI + uses: arduino/setup-arduino-cli@v1 + + - name: Configure ESP32 Board Manager + if: matrix.board.platform == 'esp32:esp32' + run: | + arduino-cli config init + arduino-cli config add board_manager.additional_urls https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json + + - name: Install Board Platform + run: | + arduino-cli core update-index + arduino-cli core install ${{ matrix.board.platform }} + + - name: Install AVR Dependencies + if: matrix.board.platform == 'arduino:avr' + run: | + arduino-cli lib install "AltSoftSerial" + + - name: Compile Library Examples + run: | + # Setup local library link + mkdir -p $HOME/Arduino/libraries + ln -s $GITHUB_WORKSPACE $HOME/Arduino/libraries/OBD2_KLine + + # Find and compile each .ino file + find examples -name "*.ino" -print0 | while IFS= read -r -d '' ino_file; do + sketch_dir=$(dirname "$ino_file") + echo "------------------------------------------------" + echo "Processing: $sketch_dir" + echo "Board: ${{ matrix.board.name }}" + arduino-cli compile --fqbn ${{ matrix.board.fqbn }} --library . "$sketch_dir" + if [ $? -ne 0 ]; then + echo "Compilation failed for $sketch_dir" + exit 1 + fi + done + + - name: Summary + run: echo "All examples compiled successfully for ${{ matrix.board.name }}." diff --git a/examples/Car Specific/Honda/Honda.ino b/examples/Car Specific/Honda/Honda.ino index 4b93142..591c492 100644 --- a/examples/Car Specific/Honda/Honda.ino +++ b/examples/Car Specific/Honda/Honda.ino @@ -1,11 +1,15 @@ #include "OBD2_KLine.h" // Include the library for OBD2 K-Line communication #include "Honda_CR-V_2003.h" -// #include // Optional alternative software serial (not used here) -// AltSoftSerial Alt_Serial; // Create an alternative serial object (commented out) -// ---------------- Create an OBD2_KLine object for communication. +#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega2560__) +#include +AltSoftSerial Alt_Serial; +OBD2_KLine KLine(Alt_Serial, 10400, 8, 9); // Uses AltSoftSerial at 10400 baud, with RX on pin 8 and TX on pin 9. +#elif defined(ESP32) OBD2_KLine KLine(Serial1, 10400, 10, 11); // Uses Hardware Serial (Serial1) at 10400 baud, with RX on pin 10 and TX on pin 11. -//OBD2_KLine KLine(Alt_Serial, 10400, 8, 9); // Uses AltSoftSerial at 10400 baud, with RX on pin 8 and TX on pin 9. +#else +#error "Unsupported board! This library currently supports Arduino Uno, Nano, Mega, and ESP32. Please select a compatible board in your IDE." +#endif void setup() { Serial.begin(115200); // Start the default serial (for logging/debugging) diff --git a/examples/Car Specific/Opel/Opel.ino b/examples/Car Specific/Opel/Opel.ino index b9345f9..ccecab1 100644 --- a/examples/Car Specific/Opel/Opel.ino +++ b/examples/Car Specific/Opel/Opel.ino @@ -1,11 +1,15 @@ #include "OBD2_KLine.h" // Include the library for OBD2 K-Line communication #include "Opel_Vectra_B_2001_Codes.h" -//#include // Optional alternative software serial (not used here) -//AltSoftSerial Alt_Serial; // Create an alternative serial object (commented out) -// ---------------- Create an OBD2_KLine object for communication. +#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega2560__) +#include +AltSoftSerial Alt_Serial; +OBD2_KLine KLine(Alt_Serial, 10400, 8, 9); // Uses AltSoftSerial at 10400 baud, with RX on pin 8 and TX on pin 9. +#elif defined(ESP32) OBD2_KLine KLine(Serial1, 10400, 10, 11); // Uses Hardware Serial (Serial1) at 10400 baud, with RX on pin 10 and TX on pin 11. -//OBD2_KLine KLine(Alt_Serial, 10400, 8, 9); // Uses AltSoftSerial at 10400 baud, with RX on pin 8 and TX on pin 9. +#else +#error "Unsupported board! This library currently supports Arduino Uno, Nano, Mega, and ESP32. Please select a compatible board in your IDE." +#endif bool connectionStatus = false; int kw81_Stage = 0; diff --git a/examples/Car Specific/Yamaha/Yamaha.ino b/examples/Car Specific/Yamaha/Yamaha.ino index 7b19a27..c218035 100644 --- a/examples/Car Specific/Yamaha/Yamaha.ino +++ b/examples/Car Specific/Yamaha/Yamaha.ino @@ -1,11 +1,15 @@ #include "OBD2_KLine.h" // Include the library for OBD2 K-Line communication #include "Yamaha_F70.h" -//#include // Optional alternative software serial (not used here) -//AltSoftSerial Alt_Serial; // Create an alternative serial object (commented out) -// ---------------- Create an OBD2_KLine object for communication. +#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega2560__) +#include +AltSoftSerial Alt_Serial; +OBD2_KLine KLine(Alt_Serial, 10400, 8, 9); // Uses AltSoftSerial at 10400 baud, with RX on pin 8 and TX on pin 9. +#elif defined(ESP32) OBD2_KLine KLine(Serial1, 10400, 10, 11); // Uses Hardware Serial (Serial1) at 10400 baud, with RX on pin 10 and TX on pin 11. -//OBD2_KLine KLine(Alt_Serial, 10400, 8, 9); // Uses AltSoftSerial at 10400 baud, with RX on pin 8 and TX on pin 9. +#else +#error "Unsupported board! This library currently supports Arduino Uno, Nano, Mega, and ESP32. Please select a compatible board in your IDE." +#endif int counter1 = 0; @@ -32,14 +36,14 @@ void Yamaha_Simulator() { // delay(300); // writeRawData(yamahaEngineNO_Response, sizeof(yamahaEngineNO_Response), 0); } - if (KLine.resultBuffer[0] == 0xE5) { - //delay(100); - KLine.writeRawData(yamahaLiveData1_Response, sizeof(yamahaLiveData1_Response), 0); + // if (KLine.resultBuffer[0] == 0xE5) { + // delay(100); + // KLine.writeRawData(yamahaLiveData1_Response, sizeof(yamahaLiveData1_Response), 0); // counter1++; // if (counter1 == 2) { // delay(10); // writeRawData(yamahaInit_Response2, sizeof(yamahaInit_Response2), 0); // } - } + // } } } diff --git a/examples/OBD2 Standard/ClearDTC/ClearDTC.ino b/examples/OBD2 Standard/ClearDTC/ClearDTC.ino index 1ce3e5f..939dd78 100644 --- a/examples/OBD2 Standard/ClearDTC/ClearDTC.ino +++ b/examples/OBD2 Standard/ClearDTC/ClearDTC.ino @@ -1,10 +1,14 @@ #include "OBD2_KLine.h" // Include the library for OBD2 K-Line communication -// #include // Optional alternative software serial (not used here) -// AltSoftSerial Alt_Serial; // Create an alternative serial object (commented out) -// ---------------- Create an OBD2_KLine object for communication. -OBD2_KLine KLine(Serial1, 10400, 10, 11); // Uses Hardware Serial (Serial1) at 10400 baud, with RX on pin 10 and TX on pin 11. -// OBD2_KLine KLine(Alt_Serial, 10400, 8, 9); // Uses AltSoftSerial at 10400 baud, with RX on pin 8 and TX on pin 9. +#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega2560__) +#include +AltSoftSerial Alt_Serial; +OBD2_KLine KLine(Alt_Serial, 10400, 8, 9); // Uses AltSoftSerial at 10400 baud, with RX on pin 8 and TX on pin 9. +#elif defined(ESP32) +OBD2_KLine KLine(Serial1, 10400, 10, 11); // Uses Hardware Serial (Serial1) at 10400 baud, with RX on pin 10 and TX on pin 11. +#else +#error "Unsupported board! This library currently supports Arduino Uno, Nano, Mega, and ESP32. Please select a compatible board in your IDE." +#endif void setup() { Serial.begin(115200); // Start the default serial (for logging/debugging) diff --git a/examples/OBD2 Standard/GetFreezeFrame/GetFreezeFrame.ino b/examples/OBD2 Standard/GetFreezeFrame/GetFreezeFrame.ino index 99e3ad0..b390cc9 100644 --- a/examples/OBD2 Standard/GetFreezeFrame/GetFreezeFrame.ino +++ b/examples/OBD2 Standard/GetFreezeFrame/GetFreezeFrame.ino @@ -1,10 +1,14 @@ #include "OBD2_KLine.h" // Include the library for OBD2 K-Line communication -//#include // Optional alternative software serial (not used here) -//AltSoftSerial Alt_Serial; // Create an alternative serial object (commented out) -// ---------------- Create an OBD2_KLine object for communication. +#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega2560__) +#include +AltSoftSerial Alt_Serial; +OBD2_KLine KLine(Alt_Serial, 10400, 8, 9); // Uses AltSoftSerial at 10400 baud, with RX on pin 8 and TX on pin 9. +#elif defined(ESP32) OBD2_KLine KLine(Serial1, 10400, 10, 11); // Uses Hardware Serial (Serial1) at 10400 baud, with RX on pin 10 and TX on pin 11. -//OBD2_KLine KLine(Alt_Serial, 10400, 8, 9); // Uses AltSoftSerial at 10400 baud, with RX on pin 8 and TX on pin 9. +#else +#error "Unsupported board! This library currently supports Arduino Uno, Nano, Mega, and ESP32. Please select a compatible board in your IDE." +#endif void setup() { Serial.begin(115200); // Start the default serial (for logging/debugging) diff --git a/examples/OBD2 Standard/GetLiveData/GetLiveData.ino b/examples/OBD2 Standard/GetLiveData/GetLiveData.ino index ea05487..86974b7 100644 --- a/examples/OBD2 Standard/GetLiveData/GetLiveData.ino +++ b/examples/OBD2 Standard/GetLiveData/GetLiveData.ino @@ -1,10 +1,14 @@ #include "OBD2_KLine.h" // Include the library for OBD2 K-Line communication -//#include // Optional alternative software serial (not used here) -//AltSoftSerial Alt_Serial; // Create an alternative serial object (commented out) -// ---------------- Create an OBD2_KLine object for communication. +#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega2560__) +#include +AltSoftSerial Alt_Serial; +OBD2_KLine KLine(Alt_Serial, 10400, 8, 9); // Uses AltSoftSerial at 10400 baud, with RX on pin 8 and TX on pin 9. +#elif defined(ESP32) OBD2_KLine KLine(Serial1, 10400, 10, 11); // Uses Hardware Serial (Serial1) at 10400 baud, with RX on pin 10 and TX on pin 11. -//OBD2_KLine KLine(Alt_Serial, 10400, 8, 9); // Uses AltSoftSerial at 10400 baud, with RX on pin 8 and TX on pin 9. +#else +#error "Unsupported board! This library currently supports Arduino Uno, Nano, Mega, and ESP32. Please select a compatible board in your IDE." +#endif void setup() { Serial.begin(115200); // Start the default serial (for logging/debugging) diff --git a/examples/OBD2 Standard/GetSupportedPIDs/GetSupportedPIDs.ino b/examples/OBD2 Standard/GetSupportedPIDs/GetSupportedPIDs.ino index b0f4288..e8176a5 100644 --- a/examples/OBD2 Standard/GetSupportedPIDs/GetSupportedPIDs.ino +++ b/examples/OBD2 Standard/GetSupportedPIDs/GetSupportedPIDs.ino @@ -1,10 +1,14 @@ #include "OBD2_KLine.h" // Include the library for OBD2 K-Line communication -// #include // Optional alternative software serial (not used here) -// AltSoftSerial Alt_Serial; // Create an alternative serial object (commented out) -// ---------------- Create an OBD2_KLine object for communication. +#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega2560__) +#include +AltSoftSerial Alt_Serial; +OBD2_KLine KLine(Alt_Serial, 10400, 8, 9); // Uses AltSoftSerial at 10400 baud, with RX on pin 8 and TX on pin 9. +#elif defined(ESP32) OBD2_KLine KLine(Serial1, 10400, 10, 11); // Uses Hardware Serial (Serial1) at 10400 baud, with RX on pin 10 and TX on pin 11. -// OBD2_KLine KLine(Alt_Serial, 10400, 8, 9); // Uses AltSoftSerial at 10400 baud, with RX on pin 8 and TX on pin 9. +#else +#error "Unsupported board! This library currently supports Arduino Uno, Nano, Mega, and ESP32. Please select a compatible board in your IDE." +#endif void setup() { Serial.begin(115200); // Start the default serial (for logging/debugging) diff --git a/examples/OBD2 Standard/GetVehicleInfo/GetVehicleInfo.ino b/examples/OBD2 Standard/GetVehicleInfo/GetVehicleInfo.ino index 10e86fe..7b46665 100644 --- a/examples/OBD2 Standard/GetVehicleInfo/GetVehicleInfo.ino +++ b/examples/OBD2 Standard/GetVehicleInfo/GetVehicleInfo.ino @@ -1,10 +1,14 @@ #include "OBD2_KLine.h" // Include the library for OBD2 K-Line communication -// #include // Optional alternative software serial (not used here) -// AltSoftSerial Alt_Serial; // Create an alternative serial object (commented out) -// ---------------- Create an OBD2_KLine object for communication. +#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega2560__) +#include +AltSoftSerial Alt_Serial; +OBD2_KLine KLine(Alt_Serial, 10400, 8, 9); // Uses AltSoftSerial at 10400 baud, with RX on pin 8 and TX on pin 9. +#elif defined(ESP32) OBD2_KLine KLine(Serial1, 10400, 10, 11); // Uses Hardware Serial (Serial1) at 10400 baud, with RX on pin 10 and TX on pin 11. -// OBD2_KLine KLine(Alt_Serial, 10400, 8, 9); // Uses AltSoftSerial at 10400 baud, with RX on pin 8 and TX on pin 9. +#else +#error "Unsupported board! This library currently supports Arduino Uno, Nano, Mega, and ESP32. Please select a compatible board in your IDE." +#endif void setup() { Serial.begin(115200); // Start the default serial (for logging/debugging) diff --git a/examples/OBD2 Standard/ReadDTC/ReadDTC.ino b/examples/OBD2 Standard/ReadDTC/ReadDTC.ino index e6ef197..09a5eef 100644 --- a/examples/OBD2 Standard/ReadDTC/ReadDTC.ino +++ b/examples/OBD2 Standard/ReadDTC/ReadDTC.ino @@ -1,10 +1,14 @@ #include "OBD2_KLine.h" // Include the library for OBD2 K-Line communication -// #include // Optional alternative software serial (not used here) -// AltSoftSerial Alt_Serial; // Create an alternative serial object (commented out) -// ---------------- Create an OBD2_KLine object for communication. +#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega2560__) +#include +AltSoftSerial Alt_Serial; +OBD2_KLine KLine(Alt_Serial, 10400, 8, 9); // Uses AltSoftSerial at 10400 baud, with RX on pin 8 and TX on pin 9. +#elif defined(ESP32) OBD2_KLine KLine(Serial1, 10400, 10, 11); // Uses Hardware Serial (Serial1) at 10400 baud, with RX on pin 10 and TX on pin 11. -// OBD2_KLine KLine(Alt_Serial, 10400, 8, 9); // Uses AltSoftSerial at 10400 baud, with RX on pin 8 and TX on pin 9. +#else +#error "Unsupported board! This library currently supports Arduino Uno, Nano, Mega, and ESP32. Please select a compatible board in your IDE." +#endif void setup() { Serial.begin(115200); // Start the default serial (for logging/debugging)