diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml new file mode 100644 index 0000000..411531b --- /dev/null +++ b/.github/workflows/compile.yml @@ -0,0 +1,138 @@ +name: CompileTests + +on: + push: + branches: [ "main", "dev" ] + pull_request: + branches: [ "main" ] + +jobs: + + buildAllExamples: + runs-on: ubuntu-latest + strategy: + matrix: + board: + - uno + example: + - ./examples/BAE910_device/BAE910_device.ino +# - ./examples/DS18B20_asInterface/DS18B20_asInterface.ino # needs I2C + - ./examples/DS18B20_thermometer/DS18B20_thermometer.ino + - ./examples/DS2401_serial/DS2401_serial.ino + - ./examples/DS2405_switch/DS2405_switch.ino + - ./examples/DS2408_switch/DS2408_switch.ino + - ./examples/DS2413_switch/DS2413_switch.ino + - ./examples/DS2423_RAM/DS2423_RAM.ino + - ./examples/DS2430_EEPROM/DS2430_EEPROM.ino + - ./examples/DS2431_EEPROM/DS2431_EEPROM.ino + - ./examples/DS2433_EEPROM/DS2433_EEPROM.ino + - ./examples/DS2434_IBM701c/DS2434_IBM701c.ino + - ./examples/DS2438_battMon/DS2438_battMon.ino + - ./examples/DS2450_ADC/DS2450_ADC.ino + - ./examples/DS2502_DELLCHG/DS2502_DELLCHG.ino + - ./examples/DS2502_EEPROM/DS2502_EEPROM.ino + - ./examples/DS2506_EEPROM/DS2506_EEPROM.ino + - ./examples/DS2890_poti/DS2890_poti.ino + - ./examples/OneWireHubTest/OneWireHubTest.ino + + steps: + - name: Checkout ๐Ÿ›Ž๏ธ + uses: actions/checkout@v3 + - name: Set up Python ๐Ÿ + uses: actions/setup-python@v4 + with: + python-version: '3.x' + - name: Install dependencies ๐Ÿ”ง + run: sudo apt install cmake build-essential + - name: Install platformio ๐Ÿ”ง + run: pip install -U platformio + + - name: compile "${{ matrix.example }} for "${{ matrix.board }}" ๐Ÿงฑ + run: "platformio ci --lib='.' -b ${{ matrix.board }} ${{ matrix.example }}" + + build4TargetsBig: + runs-on: ubuntu-latest + strategy: + matrix: + board: + - uno + #- teensy20 + - teensy30 + - teensy36 + - esp01 + - nodemcuv2 + - espduino + #- espino32 # not capable of c++11? + #- esp32dev # not capable of c++11? + +### Travis - LIST - TODO: find more and extend +# due # arduino due -> current tick-counting implementation not compatible +# zero # arduino zero -> current tick-counting implementation not compatible +# teensy30 teensy31 teensy35 teensy36 # teensy 3 +# teensy20 teensy20pp # teensy 2 -> crc-lib has linker problem in platformIO but works in arduino-sw +# esp01 nodemcuv2 espduino # esp8266 +# espino32 esp32dev # esp8266 +# rfduino # nrf51 -> will probably fail due to old gcc 4.8.3 with artificial limit to c++98 +# lenny uno_pic32 # pic32mx -> error: pic32-g++ not found +# genuino101 # intel curie -> value_ipl is unknown for this hardware +# attiny88 attiny84 # attiny -> linker error for unknown virtual function +# digispark-tiny # attiny + + example: + - ./examples/OneWireHubTest/OneWireHubTest.ino + + steps: + - name: Checkout ๐Ÿ›Ž๏ธ + uses: actions/checkout@v3 + - name: Set up Python ๐Ÿ + uses: actions/setup-python@v4 + with: + python-version: '3.x' + - name: Install dependencies ๐Ÿ”ง + run: sudo apt install cmake build-essential + - name: Install platformio ๐Ÿ”ง + run: pip install -U platformio + + - name: compile "${{ matrix.example }} for "${{ matrix.board }}" ๐Ÿงฑ + run: "platformio ci --lib='.' -b ${{ matrix.board }} ${{ matrix.example }}" + + build4TargetsSmall: + runs-on: ubuntu-latest + strategy: + matrix: + board: + - digispark-tiny + example: + - ./examples/DS2401_serial/DS2401_serial.ino + + steps: + - name: Checkout ๐Ÿ›Ž๏ธ + uses: actions/checkout@v3 + - name: Set up Python ๐Ÿ + uses: actions/setup-python@v4 + with: + python-version: '3.x' + - name: Install dependencies ๐Ÿ”ง + run: sudo apt install cmake build-essential + - name: Install platformio ๐Ÿ”ง + run: pip install -U platformio + + - name: compile "${{ matrix.example }} for "${{ matrix.board }}" ๐Ÿงฑ + run: "platformio ci --lib='.' -b ${{ matrix.board }} ${{ matrix.example }}" + + testsuite: + runs-on: ubuntu-latest + + steps: + - name: Checkout ๐Ÿ›Ž๏ธ + uses: actions/checkout@v3 + - name: Install dependencies ๐Ÿ”ง + run: sudo apt install cmake build-essential + + - name: Run primitive testsuite ๐Ÿงฑ + run: | + mkdir build + cd ./build + cmake .. + make + ./OneWireHub diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 15780a6..0000000 --- a/.travis.yml +++ /dev/null @@ -1,68 +0,0 @@ -os: linux -dist: trusty -group: edge -sudo: false - -language: python - -python: - - "2.7" - -cache: - pip: true - apt: true - directories: - - "~/.platformio" - -before_cache: - - rm -f $HOME/.cache/pip/log/debug.log - -before_install: - - pip install -U platformio - -addons: - apt: - packages: - - cmake - - build-essential - -env: - - PIO_BRD: "'-b uno'" # arduino uno -# - PIO_BRD: "'-b due'" # arduino due -> current tick-counting implementation not compatible -# - PIO_BRD: "'-b zero'" # arduino zero -> current tick-counting implementation not compatible - - PIO_BRD: "'-b teensy30 -b teensy31 -b teensy35 -b teensy36'" # teensy 3 -# - PIO_BRD: "'-b teensy20 -b teensy20pp'" # teensy 2 -> crc-lib has linker problem in platformIO but works in arduino-sw - - PIO_BRD: "'-b esp01 -b nodemcuv2 -b espduino'" # esp8266 - - PIO_BRD: "'-b espino32 -b esp32dev'" # esp8266 -# - PIO_BRD: "'-b rfduino'" # nrf51 -> will probably fail due to old gcc 4.8.3 with artificial limit to c++98 -# - PIO_BRD: "'-b lenny -b uno_pic32'" # pic32mx -> error: pic32-g++ not found -# - PIO_BRD: "'-b genuino101'" # intel curie -> value_ipl is unknown for this hardware -# - PIO_BRD: "'-b attiny88 -b attiny84'" # attiny -> linker error for unknown virtual function - - PIO_BRD: "'-b digispark-tiny'" # attiny - -before_script: - - platformio init $PIO_BRD - -script: - - platformio ci --lib="." $PIO_BRD ./examples/BAE910_device/BAE910_device.ino -# - platformio ci --lib="." $PIO_BRD ./examples/DS18B20_asInterface/DS18B20_asInterface.ino - - platformio ci --lib="." $PIO_BRD ./examples/DS18B20_thermometer/DS18B20_thermometer.ino - - platformio ci --lib="." $PIO_BRD ./examples/DS2401_serial/DS2401_serial.ino - - platformio ci --lib="." $PIO_BRD ./examples/DS2405_switch/DS2405_switch.ino - - platformio ci --lib="." $PIO_BRD ./examples/DS2408_switch/DS2408_switch.ino - - platformio ci --lib="." $PIO_BRD ./examples/DS2413_switch/DS2413_switch.ino - - platformio ci --lib="." $PIO_BRD ./examples/DS2423_RAM/DS2423_RAM.ino - - platformio ci --lib="." $PIO_BRD ./examples/DS2431_EEPROM/DS2431_EEPROM.ino - - platformio ci --lib="." $PIO_BRD ./examples/DS2433_EEPROM/DS2433_EEPROM.ino - - platformio ci --lib="." $PIO_BRD ./examples/DS2438_battMon/DS2438_battMon.ino - - platformio ci --lib="." $PIO_BRD ./examples/DS2450_ADC/DS2450_ADC.ino - - platformio ci --lib="." $PIO_BRD ./examples/DS2502_DELLCHG/DS2502_DELLCHG.ino - - platformio ci --lib="." $PIO_BRD ./examples/DS2502_EEPROM/DS2502_EEPROM.ino - - platformio ci --lib="." $PIO_BRD ./examples/DS2506_EEPROM/DS2506_EEPROM.ino - - platformio ci --lib="." $PIO_BRD ./examples/DS2890_poti/DS2890_poti.ino - - platformio ci --lib="." $PIO_BRD ./examples/OneWireHubTest/OneWireHubTest.ino - - mkdir build - - cd ./build - - cmake .. - - make - - ./OneWireHub diff --git a/CMakeLists.txt b/CMakeLists.txt index 41c886d..6135636 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,8 +15,10 @@ set(SOURCE_FILES src/DS2408.cpp src/DS2413.cpp src/DS2423.cpp + src/DS2430.cpp src/DS2431.cpp src/DS2433.cpp + src/DS2434.cpp src/DS2438.cpp src/DS2450.cpp src/DS2502.cpp @@ -26,6 +28,6 @@ set(SOURCE_FILES src/OneWireHub_config.h src/OneWireItem.cpp src/platform.cpp - ) + ) # TODO: this does not have to be manual add_executable(OneWireHub ${SOURCE_FILES}) \ No newline at end of file diff --git a/README.md b/README.md index 56c50dd..77f9142 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ OneWireHub The OneWireHub is a sleek Arduino compatible (and many more platforms) library to emulate OneWire-Slaves with support for various devices. The motivation is to offer a shared code base for all OneWire-Slaves. With a small overhead one ยตC can emulate up to 32 ICs simultaneously. The main goal is to use modern sensors (mainly [I2C](https://github.com/orgua/iLib) or SPI interface) and transfer their measurements into one or more emulated ds2438 which have 4x16bit registers for values. This feature removes the limitations of modern house-automation-systems. Add humidity, light and other sensors easy to your home automation environment. -[![Build Status](https://travis-ci.org/orgua/OneWireHub.svg?branch=master)](https://travis-ci.org/orgua/OneWireHub) +[![CompileTests](https://github.com/orgua/OneWireHub/actions/workflows/compile.yml/badge.svg)](https://github.com/orgua/OneWireHub/actions/workflows/compile.yml) ### Implemented Slaves @@ -24,7 +24,7 @@ The main goal is to use modern sensors (mainly [I2C](https://github.com/orgua/iL - **DS2431 (0x2D) 1kbit protected EEPROM** (also known as DS1972 or DS28E07, same FC) - DS2432 (0x33) 1kbit protected EEPROM (basically a ds2431 with extra sha-engine) - **DS2433 (0x23) 4Kbit EEPROM** (also known as DS1973) -- DS2434 (0x1B ???) BatteryManagement used in some IBM Notebook-Batteries (similar to DS2436 (x1B), with one less cmd) +- DS2434 (0x1B ???) BatteryManagement used in some IBM Notebook-Batteries (similar to DS2436 (x1B), but without multidrop and one less cmd) - **DS2438 (0x26) Smart Battery Monitor, measures temperature, 2x voltage and current, 10bit** - **DS2450 (0x20) 4 channel A/D** - **DS2501 (0x11, 0x91) 512bit EEPROM** -> use DS2502 with different family code @@ -45,9 +45,9 @@ Note: **Bold printed devices are feature-complete and were mostly tested with a - support for most onewire-features: MATCH ROM (0x55), SKIP ROM (0xCC), READ ROM (0x0F,0x33), RESUME COMMAND (0xA5) - **OVERDRIVE-Mode**: Master can issue OD SKIP ROM (0x13) or OD MATCH ROM (0x69) and slave stays in this mode till it sees a long reset -> OD-feature must be activated in config - ALARM SEARCH (0xEC) is NOT implemented yet! -- cleaner, faster code with c++11 features **(requires arduino sw 1.6.x or higher, >=1.6.10 recommended)** +- cleaner, faster code with c++11 features **(requires arduino sw 1.6.x or higher, >=2.0.0 recommended)** - use of constexpr instead of #define for better compiler-messages and cleaner code - - use static-assertions for plausibility checks + - use static-assertions for compile-time plausibility checks - user defined literals convert constants into needed format / unit - hardware-dependencies are combined in "platform.h", synced with [Onewire-Lib](https://github.com/PaulStoffregen/OneWire) - supported: arduino zero, teensy, pic32, [ATtiny](https://github.com/damellis/attiny), esp8266, esp32, raspberry (...) @@ -115,7 +115,7 @@ Note: **Bold printed devices are feature-complete and were mostly tested with a ### HELP - What to do if things don't work as expected? - check if your arduino software up to date (>v1.8.0) -- update this lib to the latest release (v2.2.2) +- update this lib to the latest release (v2.2.3) - if you use an uncalibrated architecture the compilation-process will fail with an error, look at ./examples/debug/calibrate_by_bus_timing for an explanation - check if clock-speed of the ยตC is set correctly (if possible) - test with simple blink example, 1sec ON should really need 1sec. timing is critical - begin with a simple example like the ds18b20 (if possible). the ds18b20 doesn't support overdrive, so the master won't switch to higher data rates diff --git a/examples/DS2434_IBM701c/DS2434_IBM701c.ino b/examples/DS2434_IBM701c/DS2434_IBM701c.ino index 6c4dbb7..07ad40f 100644 --- a/examples/DS2434_IBM701c/DS2434_IBM701c.ino +++ b/examples/DS2434_IBM701c/DS2434_IBM701c.ino @@ -21,15 +21,16 @@ void setup() // add default-data constexpr uint8_t mem1[24] = {0x14, 0x10, 0x90, 0xd0, 0x03, 0x32, 0x4b, 0x3c, 0xff, 0x04, 0x64, 0x04, 0x9e, 0x9a, 0x3a, 0xf0, - 0x20, 0x20, 0x04, 0xee, 0x77, 0x66, 0x55, 0x44 }; // last 4 Byte seem to be Serial + 0x20, 0x20, 0x04, 0xee, 0x63, 0xB8, 0x3E, 0x63 }; // last 4 Byte seem to be Serial ds2434.writeMemory(reinterpret_cast(mem1),sizeof(mem1),0x00); - constexpr uint8_t mem2[8] = {0x34, 0x39, 0x29, 0xc4, 0x9e, 0xd0, 0x81, 0xb6 }; + constexpr uint8_t mem2[8] = {0x33, 0x2e, 0x33, 0x2e, 0x9e, 0x10, 0x3f, 0x50 }; ds2434.writeMemory(reinterpret_cast(mem2),sizeof(mem2),0x20); ds2434.lockNV1(); ds2434.setID(0xCABDu); - ds2434.setBatteryCounter(1234u); + ds2434.setBatteryCounter(0x0123u); + ds2434.setTemperature(22u); } void loop() diff --git a/library.json b/library.json index c7a97a1..68b1f57 100644 --- a/library.json +++ b/library.json @@ -1,7 +1,7 @@ { "name": "OneWireHub", "frameworks": "Arduino", -"keywords": "onewire, 1-wire, bus, slave, sensor, temperature, voltage, current, memory, BAE910, DS1822, DS18B20, DS18S20, DS1990, DS2401, DS2405, DS2408, DS2411, DS2413, DS2423, DS2431, DS2432, DS2433, DS2438, DS2450, DS2501, DS2502, DS2503, DS2505, DS2506, DS2890", +"keywords": "onewire, 1-wire, bus, slave, sensor, temperature, voltage, current, memory, BAE910, DS1822, DS18B20, DS18S20, DS1990, DS2401, DS2405, DS2408, DS2411, DS2413, DS2423, DS2430, DS2431, DS2432, DS2433, DS2434, DS2438, DS2450, DS2501, DS2502, DS2503, DS2505, DS2506, DS2890", "description": "OneWire slave device emulator with support for up to 32 simultaneous devices", "authors": [ @@ -22,7 +22,7 @@ "type": "git", "url": "https://github.com/orgua/OneWireHub" }, - "version": "2.2.2", + "version": "2.2.3", "examples": [ "examples/*/*.ino" ] diff --git a/library.properties b/library.properties index 8d3412c..e7e18af 100644 --- a/library.properties +++ b/library.properties @@ -1,9 +1,9 @@ name=OneWireHub -version=2.2.2 +version=2.2.3 author=Ingmar Splitt, orgua, MarkusLange, Shagrat2 maintainer=orgua sentence=OneWire slave device emulator with support for up to 32 simultaneous 1wire devices. -paragraph=supported sensors: BAE910, DS1822, DS18B20, DS18S20, DS1990, DS2401, DS2405, DS2408, DS2411, DS2413, DS2423, DS2431, DS2432, DS2433, DS2438, DS2450, DS2501, DS2502, DS2503, DS2505, DS2506, DS2890 +paragraph=supported sensors: BAE910, DS1822, DS18B20, DS18S20, DS1990, DS2401, DS2405, DS2408, DS2411, DS2413, DS2423, DS2430, DS2431, DS2432, DS2433, DS2434, DS2438, DS2450, DS2501, DS2502, DS2503, DS2505, DS2506, DS2890 category=Sensors url=https://github.com/orgua/OneWireHub architectures=* \ No newline at end of file diff --git a/main.cpp b/main.cpp index f76fa98..7e92dd7 100644 --- a/main.cpp +++ b/main.cpp @@ -20,6 +20,7 @@ using namespace std; #include "src/DS2423.h" // 4kb 1-Wire RAM with Counter #include "src/DS2431.h" // 1kb 1-Wire EEPROM #include "src/DS2433.h" // 4Kb 1-Wire EEPROM +#include "src/DS2434.h" // 1-Wire EEPROM #include "src/DS2438.h" // Smart Battery Monitor #include "src/DS2450.h" // 4 channel A/D #include "src/DS2502.h" // 1kb EEPROM @@ -87,6 +88,7 @@ int main() auto hubA = OneWireHub(OneWire_PIN); auto hubB = OneWireHub(OneWire_PIN); auto hubC = OneWireHub(OneWire_PIN); + auto hubD = OneWireHub(OneWire_PIN); auto ds1822 = DS18B20(0x22, 0x0D, 0x01, 0x08, 0x02, 0x00, 0x00); auto ds18B20 = DS18B20(0x28, 0x0D, 0x01, 0x08, 0x0B, 0x02, 0x00); // Work - Digital Thermometer @@ -116,6 +118,8 @@ int main() auto ds2890C = DS2890( 0x2C, 0x0D, 0x02, 0x08, 0x09, 0x00, 0x0C ); auto bae910 = BAE910(BAE910::family_code, 0x00, 0x00, 0x10, 0xE9, 0xBA, 0x00); + auto ds2434 = DS2434(0x1B, 0x01, 0x02, 0x12, 0x34, 0x56, 0x78); + cout << "- attach devices to hubs" << endl; // Setup OneWire @@ -145,6 +149,8 @@ int main() hubC.attach(ds2890C); hubC.attach(bae910); + hubD.attach(ds2434); + cout << "- use every device-function at least once and do some unit-testing" << endl; // TODO: maybe put the code in src_files to the depending device_unittest.h @@ -636,6 +642,23 @@ int main() test_eq(ds2890A.getRegFeat(), 255_u8, "DS2890 feature register preset"); } + { + // DS2434 + // add default-data + constexpr uint8_t mem1[24] = {0x14, 0x10, 0x90, 0xd0, 0x03, 0x32, 0x4b, 0x3c, + 0xff, 0x04, 0x64, 0x04, 0x9e, 0x9a, 0x3a, 0xf0, + 0x20, 0x20, 0x04, 0xee, 0x63, 0xB8, 0x3E, 0x63 }; // last 4 Byte seem to be Serial + ds2434.writeMemory(reinterpret_cast(mem1),sizeof(mem1),0x00); + + constexpr uint8_t mem2[8] = {0x33, 0x2e, 0x33, 0x2e, 0x9e, 0x10, 0x3f, 0x50 }; + ds2434.writeMemory(reinterpret_cast(mem2),sizeof(mem2),0x20); + + ds2434.lockNV1(); + ds2434.setID(0xCABDu); + ds2434.setBatteryCounter(0x0123u); + ds2434.setTemperature(22); + } + cout << "- test the hub" << endl; diff --git a/src/BAE910.cpp b/src/BAE910.cpp index 5fd32b1..d296195 100644 --- a/src/BAE910.cpp +++ b/src/BAE910.cpp @@ -7,6 +7,11 @@ BAE910::BAE910(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, // clear memory memset(&memory.bytes[0], static_cast(0x00), BAE910_MEMORY_SIZE); + + // disable bus-features: + // TODO: test, as datasheet does not clear this up -> this settings keeps the previous behavior + fast_read_rom = false; + fast_search_rom = false; } diff --git a/src/DS18B20.cpp b/src/DS18B20.cpp index 675b1cb..2ce15d9 100644 --- a/src/DS18B20.cpp +++ b/src/DS18B20.cpp @@ -15,6 +15,9 @@ DS18B20::DS18B20(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5 updateCRC(); // update scratchpad[8] ds18s20_mode = (ID1 == 0x10); // different tempRegister + + // disable bus-features: + fast_search_rom = false; } void DS18B20::updateCRC() diff --git a/src/DS18B20.h b/src/DS18B20.h index e183a38..a089d6f 100644 --- a/src/DS18B20.h +++ b/src/DS18B20.h @@ -22,7 +22,7 @@ class DS18B20 : public OneWireItem public: - static constexpr uint8_t family_code { 0x28 }; // is compatible to ds1822 (0x22) and ds18S20 (0x10) + static constexpr uint8_t family_code { 0x28 }; // is compatible to ds1822 (0x22) and ds18S20 (0x10) DS18B20(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, uint8_t ID7); diff --git a/src/DS2401.cpp b/src/DS2401.cpp index 2fb0467..6820e04 100644 --- a/src/DS2401.cpp +++ b/src/DS2401.cpp @@ -2,6 +2,9 @@ DS2401::DS2401(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, uint8_t ID7) : OneWireItem(ID1, ID2, ID3, ID4, ID5, ID6, ID7) { + // disable bus-features: + fast_read_rom = false; + fast_search_rom = false; } void DS2401::duty(OneWireHub * const hub) diff --git a/src/DS2405.h b/src/DS2405.h index 5d636a5..fd91015 100644 --- a/src/DS2405.h +++ b/src/DS2405.h @@ -16,7 +16,7 @@ class DS2405 : public OneWireItem public: - static constexpr uint8_t family_code { 0x05 }; + static constexpr uint8_t family_code { 0x05 }; DS2405(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, uint8_t ID7); diff --git a/src/DS2434.cpp b/src/DS2434.cpp index 10ee6f1..7a25a5c 100644 --- a/src/DS2434.cpp +++ b/src/DS2434.cpp @@ -2,13 +2,15 @@ DS2434::DS2434(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, uint8_t ID7) : OneWireItem(ID1, ID2, ID3, ID4, ID5, ID6, ID7) { + // disable bus-features: + // The DS2434 is NOT compatible with multidrop -> only one device on bus! + skip_multidrop = true; + clearMemory(); clearScratchpad(); - // TODO: ID-Order is just an assumption - scratchpad[80] = ID1; - scratchpad[81] = ID2; } +// As this device is not multidrop, it needs to handle ALL commands from the master void DS2434::duty(OneWireHub * const hub) { uint8_t start_byte, cmd, data; diff --git a/src/DS2434.h b/src/DS2434.h index 7fbfb28..9cbf2f5 100644 --- a/src/DS2434.h +++ b/src/DS2434.h @@ -58,7 +58,7 @@ class DS2434 : public OneWireItem public: - static constexpr uint8_t family_code { 0x53 }; // TODO: 1B seems to be right + static constexpr uint8_t family_code { 0x53 }; // TODO: 1B seems to be right (for ds2436) DS2434(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, uint8_t ID7); diff --git a/src/OneWireHub.cpp b/src/OneWireHub.cpp index 761ca08..581edaa 100644 --- a/src/OneWireHub.cpp +++ b/src/OneWireHub.cpp @@ -402,6 +402,20 @@ void OneWireHub::searchIDTree(void) bool OneWireHub::recvAndProcessCmd(void) { + + // If the only slave is not multidrop compatible, pass all data handling to the slave + if(slave_count == 1u){ + + slave_selected = slave_list[getIndexOfNextSensorInList()]; + // TODO: this might be expensive for weak uC and OW in Overdrive and only one device emulated + // -> look into optimizations (i.e. preselect when only one device present?) + + if( slave_selected->skip_multidrop ){ + slave_selected->duty(this); + return (_error != Error::NO_ERROR); + } + } + uint8_t address[8], cmd; bool flag = false; @@ -418,8 +432,13 @@ bool OneWireHub::recvAndProcessCmd(void) noInterrupts(); searchIDTree(); interrupts(); - // slave_selected->duty(this); - // TODO: some ICs like DS2430 allow going for duty() right after search + + // most ICs allow going for duty() right after search + if ((_error == Error::NO_ERROR) && (slave_selected != nullptr) && slave_selected->fast_search_rom) + { + slave_selected->duty(this); + } + return false; // always trigger a re-init after searchIDTree case 0x69: // overdrive MATCH ROM @@ -507,6 +526,12 @@ bool OneWireHub::recvAndProcessCmd(void) if (slave_selected != nullptr) { slave_selected->sendID(this); + + // most ICs allow to go to duty() without reset + if ((_error == Error::NO_ERROR) && slave_selected->fast_read_rom) + { + slave_selected->duty(this); + } } return false; diff --git a/src/OneWireItem.h b/src/OneWireItem.h index 3edd9ca..d1550d1 100644 --- a/src/OneWireItem.h +++ b/src/OneWireItem.h @@ -27,6 +27,16 @@ class OneWireItem OneWireItem& operator=(const OneWireItem& owItem) = delete; // disallow copy assignment OneWireItem& operator=(OneWireItem&& owItem) = delete; // disallow move assignment + // DEFAULT BUS-FEATURES: + // Specify if the device can be used on a bus with other 1-wire devices + // If FALSE all commands will be passed through directly to the duty() call of the device + // NOTE: there can be only one device on the bus (beside the controller) + bool skip_multidrop { false }; + // skip reboot after a search-rom command -> feature normal, except ds2401 & ds18b20 + bool fast_search_rom { true }; + // skip reboot after a read-rom command -> feature normal, except ds2401 + bool fast_read_rom { true }; + uint8_t ID[8]; void sendID(OneWireHub * hub) const;