diff --git a/.mailmap b/.mailmap index 65a6b7e3..1e51895b 100644 --- a/.mailmap +++ b/.mailmap @@ -1,5 +1,5 @@ Stefan Hoffmeister -Michael Markstaller +Michael Markstaller Joerg Mattiello Patrik Pfaffenbauer Timo Wingender diff --git a/AUTHORS b/AUTHORS index ee296597..dd3cc609 100644 --- a/AUTHORS +++ b/AUTHORS @@ -39,7 +39,6 @@ Harald Leithner Tobias Lorenz MagicBear Michael Markstaller -Michael Markstaller Joerg Mattiello Race666 Sebastian diff --git a/src/backend/ft12.cpp b/src/backend/ft12.cpp index 75d74d43..347a5f34 100644 --- a/src/backend/ft12.cpp +++ b/src/backend/ft12.cpp @@ -44,7 +44,7 @@ class FT12serial : public LLserial void termios_settings (struct termios &t1) { t1.c_cflag = CS8 | CLOCAL | CREAD | PARENB; - t1.c_iflag = IGNBRK | INPCK | ISIG; + t1.c_iflag = IGNBRK | ISIG; t1.c_oflag = 0; t1.c_lflag = 0; t1.c_cc[VTIME] = 1; @@ -120,7 +120,8 @@ FT12wrap::setup() ERRORPRINTF (t, E_ERROR | 5, "Don't specify both device and IP options!"); return false; } - iface = new FT12serial(this, cfg); + ll_serial = new FT12serial(this, cfg); + iface = ll_serial; } else { @@ -325,6 +326,10 @@ FT12wrap::process_read(bool is_timeout) const uint8_t reset[1] = { 0xA0 }; CArray c = CArray (reset, sizeof (reset)); t->TracePacket (0, "RecvReset", c); + if (ll_serial != nullptr) + { + ll_serial->enable_input_parity_check(); + } LowLevelFilter::recv_Data (c); } akt.deletepart (0, 4); @@ -444,5 +449,3 @@ FT12CEMIDriver::cmdOpen() const uint8_t t1[] = { 0xF6, 0x00, 0x08, 0x01, 0x34, 0x10, 0x01, 0x00 }; send_Local (CArray (t1, sizeof (t1)),1); } - - diff --git a/src/backend/ft12.h b/src/backend/ft12.h index fc8d5803..5209d2a1 100644 --- a/src/backend/ft12.h +++ b/src/backend/ft12.h @@ -24,6 +24,7 @@ #include "iobuf.h" #include "lowlevel.h" +#include "llserial.h" #include "emi_common.h" #include "lowlatency.h" #include "link.h" @@ -125,6 +126,9 @@ class FT12wrap : public LowLevelFilter void do_send_Local (CArray& l, int raw = 0); void sendReset(); + +private: + LLserial *ll_serial = nullptr; }; #endif diff --git a/src/backend/ncn5120.cpp b/src/backend/ncn5120.cpp index d47d45d8..d8f834a7 100644 --- a/src/backend/ncn5120.cpp +++ b/src/backend/ncn5120.cpp @@ -34,7 +34,7 @@ class NCN5120wrap : public TPUARTwrap void setstate(enum TSTATE state); void RecvLPDU (const uint8_t * data, int len); - virtual FDdriver * create_serial(LowLevelIface* parent, IniSectionPtr& s); + virtual LLserial * create_serial(LowLevelIface* parent, IniSectionPtr& s); }; class NCN5120serial : public LLserial @@ -54,7 +54,7 @@ class NCN5120serial : public LLserial void termios_settings(struct termios &t1) { t1.c_cflag = CS8 | CLOCAL | CREAD; - t1.c_iflag = IGNBRK | INPCK | ISIG; + t1.c_iflag = IGNBRK | ISIG; t1.c_oflag = 0; t1.c_lflag = 0; t1.c_cc[VTIME] = 1; @@ -69,11 +69,10 @@ NCN5120::create_wrapper(LowLevelIface* parent, IniSectionPtr& s, LowLevelDriver* } -FDdriver * +LLserial * NCN5120wrap::create_serial(LowLevelIface* parent, IniSectionPtr& s) { - fd_driver = new NCN5120serial(parent,s); - return fd_driver; + return new NCN5120serial(parent, s); } void NCN5120wrap::RecvLPDU (const uint8_t * data, int len) @@ -94,4 +93,3 @@ NCN5120wrap::setstate(enum TSTATE new_state) } TPUARTwrap::setstate(new_state); } - diff --git a/src/backend/tpuart.cpp b/src/backend/tpuart.cpp index 7abf5787..7e8c9fe6 100644 --- a/src/backend/tpuart.cpp +++ b/src/backend/tpuart.cpp @@ -64,11 +64,10 @@ TPUART::create_wrapper(LowLevelIface* parent, IniSectionPtr& s, LowLevelDriver* return new TPUARTwrap(parent,s, i); } -FDdriver * +LLserial * TPUARTwrap::create_serial(LowLevelIface* parent, IniSectionPtr& s) { - fd_driver = new TPUARTserial(parent,s); - return fd_driver; + return new TPUARTserial(parent, s); } @@ -136,7 +135,8 @@ TPUARTwrap::setup() ERRORPRINTF (t, E_ERROR | 25, "Don't specify both device and IP options!"); return false; } - iface = create_serial(this, cfg); + ll_serial = create_serial(this, cfg); + iface = ll_serial; } else { @@ -363,36 +363,17 @@ TPUARTwrap::timer_cb(ev::timer &, int) } int -TPUARTwrap::enableInputParityCheck() +TPUARTwrap::enable_input_parity_check() { - struct termios t1; - - if (fd_driver == nullptr) + if (ll_serial == nullptr) { // Not possible and not necessary to enable on TCP connections, so just continue. return 0; } - TRACEPRINTF (t, 8, "Enabling input parity check on fd %d\n", fd_driver->get_fd()); - - if (tcgetattr (fd_driver->get_fd(), &t1)) - { - ERRORPRINTF (t, E_ERROR | 70, "tcgetattr failed: %s", strerror(errno)); - return -1; - } - - t1.c_iflag = t1.c_iflag | INPCK; - - if (tcsetattr (fd_driver->get_fd(), TCSANOW, &t1)) - { - ERRORPRINTF (t, E_ERROR | 70, "tcsetattr failed: %s", strerror(errno)); - return -2; - } - - return 0; + return ll_serial->enable_input_parity_check(); } - void TPUARTwrap::in_check() { @@ -479,7 +460,7 @@ TPUARTwrap::recv_Data(CArray &c) if (state == T_in_reset) { TRACEPRINTF (t, 8, "RESET_ACK"); - if (enableInputParityCheck()>=0) + if (enable_input_parity_check() >= 0) setstate(T_in_setaddr); // else time out } diff --git a/src/backend/tpuart.h b/src/backend/tpuart.h index a7e4a1cb..108526b3 100644 --- a/src/backend/tpuart.h +++ b/src/backend/tpuart.h @@ -24,6 +24,7 @@ #include "link.h" #include "lpdu.h" #include "lowlevel.h" +#include "llserial.h" // also update SN() in tpuart.cpp enum TSTATE @@ -107,11 +108,11 @@ class TPUARTwrap : public LowLevelFilter void send_L_Data (LDataPtr l); protected: - virtual FDdriver * create_serial(LowLevelIface* parent, IniSectionPtr& s); - FDdriver *fd_driver = NULL; + virtual LLserial * create_serial(LowLevelIface* parent, IniSectionPtr& s); private: - int enableInputParityCheck(); + LLserial *ll_serial = nullptr; + int enable_input_parity_check(); }; #endif diff --git a/src/libserver/emi2.cpp b/src/libserver/emi2.cpp index b2a082bd..f84f4a27 100644 --- a/src/libserver/emi2.cpp +++ b/src/libserver/emi2.cpp @@ -25,6 +25,7 @@ EMI2Driver::EMI2Driver (LowLevelIface* c, IniSectionPtr& s, LowLevelDriver *i) : { t->setAuxName("EMI2"); sendLocal_done.set(this); + reset_timer.set(this); } void diff --git a/src/libserver/llserial.cpp b/src/libserver/llserial.cpp index 8cb56ed9..01f27f14 100644 --- a/src/libserver/llserial.cpp +++ b/src/libserver/llserial.cpp @@ -149,3 +149,26 @@ LLserial::stop(bool err) FDdriver::stop(err); } +int +LLserial::enable_input_parity_check() +{ + struct termios t1; + + TRACEPRINTF (t, 8, "Enabling input parity check on fd %d\n", fd); + + if (tcgetattr (fd, &t1)) + { + ERRORPRINTF (t, E_ERROR | 70, "tcgetattr failed: %s", strerror(errno)); + return -1; + } + + t1.c_iflag = t1.c_iflag | INPCK; + + if (tcsetattr (fd, TCSANOW, &t1)) + { + ERRORPRINTF (t, E_ERROR | 70, "tcsetattr failed: %s", strerror(errno)); + return -2; + } + + return 0; +} diff --git a/src/libserver/llserial.h b/src/libserver/llserial.h index 05ab8488..a0530731 100644 --- a/src/libserver/llserial.h +++ b/src/libserver/llserial.h @@ -47,6 +47,7 @@ class LLserial:public FDdriver bool setup(); void start(); void stop(bool err); + int enable_input_parity_check(); private: low_latency_save sold; diff --git a/src/libserver/lowlevel.cpp b/src/libserver/lowlevel.cpp index bb3cc2e7..03a8b746 100644 --- a/src/libserver/lowlevel.cpp +++ b/src/libserver/lowlevel.cpp @@ -232,8 +232,3 @@ HWBusDriver::setup() return false; return true; } - -int FDdriver::get_fd() -{ - return fd; -} diff --git a/src/libserver/lowlevel.h b/src/libserver/lowlevel.h index d22de045..6a491865 100644 --- a/src/libserver/lowlevel.h +++ b/src/libserver/lowlevel.h @@ -281,7 +281,6 @@ class FDdriver:public LowLevelDriver bool setup(); void start(); void stop(bool err); - int get_fd(); protected: /** device connection */