mirror of
				https://github.com/thelsing/knx.git
				synced 2025-10-26 10:26:25 +01:00 
			
		
		
		
	-bugfix Arduino set knxUart
This commit is contained in:
		
							parent
							
								
									36c2cc2e29
								
							
						
					
					
						commit
						e4dbda5f16
					
				@ -3,9 +3,9 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include <Arduino.h>
 | 
					#include <Arduino.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Stream& ArduinoPlatform::SerialDebug = Serial;
 | 
					Stream& ArduinoPlatform::SerialDebug = SerialUSB;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ArduinoPlatform::ArduinoPlatform(HardwareSerial& knxSerial) : _knxSerial(knxSerial)
 | 
					ArduinoPlatform::ArduinoPlatform(HardwareSerial* knxSerial) : _knxSerial(knxSerial)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -68,19 +68,21 @@ int ArduinoPlatform::readBytes(uint8_t * buffer, uint16_t maxLen)
 | 
				
			|||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ArduinoPlatform::knxUart( HardwareSerial& serial )
 | 
					void ArduinoPlatform::knxUart( HardwareSerial* serial )
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    closeUart();
 | 
				
			||||||
    _knxSerial = serial;
 | 
					    _knxSerial = serial;
 | 
				
			||||||
 | 
					    setupUart();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
HardwareSerial& ArduinoPlatform::knxUart()
 | 
					HardwareSerial* ArduinoPlatform::knxUart()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    return _knxSerial;
 | 
					    return _knxSerial;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ArduinoPlatform::setupUart()
 | 
					void ArduinoPlatform::setupUart()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    _knxSerial.begin(19200, SERIAL_8E1);
 | 
					    _knxSerial->begin(19200, SERIAL_8E1);
 | 
				
			||||||
    while (!_knxSerial) 
 | 
					    while (!_knxSerial) 
 | 
				
			||||||
        ;
 | 
					        ;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -88,33 +90,33 @@ void ArduinoPlatform::setupUart()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void ArduinoPlatform::closeUart()
 | 
					void ArduinoPlatform::closeUart()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    _knxSerial.end();
 | 
					    _knxSerial->end();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int ArduinoPlatform::uartAvailable()
 | 
					int ArduinoPlatform::uartAvailable()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    return _knxSerial.available();
 | 
					    return _knxSerial->available();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
size_t ArduinoPlatform::writeUart(const uint8_t data)
 | 
					size_t ArduinoPlatform::writeUart(const uint8_t data)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    //printHex("<p", &data, 1);
 | 
					    //printHex("<p", &data, 1);
 | 
				
			||||||
    return _knxSerial.write(data);
 | 
					    return _knxSerial->write(data);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
size_t ArduinoPlatform::writeUart(const uint8_t *buffer, size_t size)
 | 
					size_t ArduinoPlatform::writeUart(const uint8_t *buffer, size_t size)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    //printHex("<p", buffer, size);
 | 
					    //printHex("<p", buffer, size);
 | 
				
			||||||
    return _knxSerial.write(buffer, size);
 | 
					    return _knxSerial->write(buffer, size);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int ArduinoPlatform::readUart()
 | 
					int ArduinoPlatform::readUart()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int val = _knxSerial.read();
 | 
					    int val = _knxSerial->read();
 | 
				
			||||||
    //if(val > 0)
 | 
					    //if(val > 0)
 | 
				
			||||||
    //    printHex("p>", (uint8_t*)&val, 1);
 | 
					    //    printHex("p>", (uint8_t*)&val, 1);
 | 
				
			||||||
    return val;
 | 
					    return val;
 | 
				
			||||||
@ -127,7 +129,7 @@ size_t ArduinoPlatform::readBytesUart(uint8_t *buffer, size_t length)
 | 
				
			|||||||
    uint8_t* pos = buffer;
 | 
					    uint8_t* pos = buffer;
 | 
				
			||||||
    while (toRead > 0)
 | 
					    while (toRead > 0)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        size_t val = _knxSerial.readBytes(pos, toRead);
 | 
					        size_t val = _knxSerial->readBytes(pos, toRead);
 | 
				
			||||||
        pos += val;
 | 
					        pos += val;
 | 
				
			||||||
        toRead -= val;
 | 
					        toRead -= val;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -7,7 +7,7 @@ extern Stream& _serialDBG;
 | 
				
			|||||||
class ArduinoPlatform : public Platform
 | 
					class ArduinoPlatform : public Platform
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  public:
 | 
					  public:
 | 
				
			||||||
    ArduinoPlatform(HardwareSerial& knxSerial);
 | 
					    ArduinoPlatform(HardwareSerial* knxSerial);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // ip stuff
 | 
					    // ip stuff
 | 
				
			||||||
    uint32_t currentIpAddress();
 | 
					    uint32_t currentIpAddress();
 | 
				
			||||||
@ -25,8 +25,8 @@ class ArduinoPlatform : public Platform
 | 
				
			|||||||
    int readBytes(uint8_t* buffer, uint16_t maxLen);
 | 
					    int readBytes(uint8_t* buffer, uint16_t maxLen);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //uart
 | 
					    //uart
 | 
				
			||||||
    virtual void knxUart( HardwareSerial& serial );
 | 
					    virtual void knxUart( HardwareSerial* serial);
 | 
				
			||||||
    virtual HardwareSerial& knxUart();
 | 
					    virtual HardwareSerial* knxUart();
 | 
				
			||||||
    virtual void setupUart();
 | 
					    virtual void setupUart();
 | 
				
			||||||
    virtual void closeUart();
 | 
					    virtual void closeUart();
 | 
				
			||||||
    virtual int uartAvailable();
 | 
					    virtual int uartAvailable();
 | 
				
			||||||
@ -40,5 +40,5 @@ class ArduinoPlatform : public Platform
 | 
				
			|||||||
  protected:
 | 
					  protected:
 | 
				
			||||||
    uint32_t _mulitcastAddr;
 | 
					    uint32_t _mulitcastAddr;
 | 
				
			||||||
    uint16_t _mulitcastPort;
 | 
					    uint16_t _mulitcastPort;
 | 
				
			||||||
    HardwareSerial& _knxSerial;
 | 
					    HardwareSerial* _knxSerial;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
				
			|||||||
@ -6,11 +6,11 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "knx/bits.h"
 | 
					#include "knx/bits.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Esp32Platform::Esp32Platform() : ArduinoPlatform(Serial1)
 | 
					Esp32Platform::Esp32Platform() : ArduinoPlatform(&Serial1)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Esp32Platform::Esp32Platform( HardwareSerial& s) : ArduinoPlatform(s)
 | 
					Esp32Platform::Esp32Platform( HardwareSerial* s) : ArduinoPlatform(s)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -36,7 +36,7 @@ void Esp32Platform::macAddress(uint8_t * addr)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void Esp32Platform::restart()
 | 
					void Esp32Platform::restart()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    Serial.println("restart");
 | 
					    ArduinoPlatform::SerialDebug.println("restart");
 | 
				
			||||||
    ESP.restart();
 | 
					    ESP.restart();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -3,7 +3,6 @@
 | 
				
			|||||||
#include <WiFi.h>
 | 
					#include <WiFi.h>
 | 
				
			||||||
#include <WiFiUdp.h>
 | 
					#include <WiFiUdp.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define SerialDBG Serial
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Esp32Platform : public ArduinoPlatform
 | 
					class Esp32Platform : public ArduinoPlatform
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
				
			|||||||
@ -7,11 +7,11 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "knx/bits.h"
 | 
					#include "knx/bits.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
EspPlatform::EspPlatform() : ArduinoPlatform(Serial)
 | 
					EspPlatform::EspPlatform() : ArduinoPlatform(&Serial)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
EspPlatform::EspPlatform( HardwareSerial& s) : ArduinoPlatform(s)
 | 
					EspPlatform::EspPlatform( HardwareSerial* s) : ArduinoPlatform(s)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -37,7 +37,7 @@ void EspPlatform::macAddress(uint8_t * addr)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void EspPlatform::restart()
 | 
					void EspPlatform::restart()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    Serial.println("restart");
 | 
					    ArduinoPlatform::SerialDebug.println("restart");
 | 
				
			||||||
    ESP.reset();
 | 
					    ESP.reset();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -3,7 +3,6 @@
 | 
				
			|||||||
#include <ESP8266WiFi.h>
 | 
					#include <ESP8266WiFi.h>
 | 
				
			||||||
#include <WiFiUdp.h>
 | 
					#include <WiFiUdp.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define SerialDBG Serial
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
class EspPlatform : public ArduinoPlatform
 | 
					class EspPlatform : public ArduinoPlatform
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
				
			|||||||
@ -6,17 +6,17 @@
 | 
				
			|||||||
#include <Arduino.h>
 | 
					#include <Arduino.h>
 | 
				
			||||||
#include <FlashAsEEPROM.h>
 | 
					#include <FlashAsEEPROM.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SamdPlatform::SamdPlatform() : ArduinoPlatform(Serial1)
 | 
					SamdPlatform::SamdPlatform() : ArduinoPlatform(&Serial1)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SamdPlatform::SamdPlatform( HardwareSerial& s) : ArduinoPlatform(s)
 | 
					SamdPlatform::SamdPlatform( HardwareSerial* s) : ArduinoPlatform(s)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void SamdPlatform::restart()
 | 
					void SamdPlatform::restart()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    SerialDBG.println("restart");
 | 
					    ArduinoPlatform::SerialDebug.println("restart");
 | 
				
			||||||
    NVIC_SystemReset();
 | 
					    NVIC_SystemReset();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -4,13 +4,11 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#ifdef ARDUINO_ARCH_SAMD
 | 
					#ifdef ARDUINO_ARCH_SAMD
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define SerialDBG SerialUSB
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class SamdPlatform : public ArduinoPlatform
 | 
					class SamdPlatform : public ArduinoPlatform
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
    SamdPlatform();
 | 
					    SamdPlatform();
 | 
				
			||||||
    SamdPlatform( HardwareSerial& s);
 | 
					    SamdPlatform( HardwareSerial* s);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void restart();
 | 
					    void restart();
 | 
				
			||||||
    uint8_t* getEepromBuffer(uint16_t size);
 | 
					    uint8_t* getEepromBuffer(uint16_t size);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user