diff --git a/src/ebusd/main.cpp b/src/ebusd/main.cpp index a2de1477..73c23156 100644 --- a/src/ebusd/main.cpp +++ b/src/ebusd/main.cpp @@ -197,7 +197,8 @@ static const char argpdoc[] = static const struct argp_option argpoptions[] = { {nullptr, 0, nullptr, 0, "Device options:", 1 }, {"device", 'd', "DEV", 0, "Use DEV as eBUS device (" - "\"enh:DEVICE\" or \"enh:IP:PORT\" for enhanced device," + "\"enh:DEVICE\" or \"enh:IP:PORT\" for enhanced device, " + "\"ens:DEVICE\" for enhanced high speed serial device, " "\"DEVICE\" for serial device, or \"[udp:]IP:PORT\" for network device) [/dev/ttyUSB0]", 0 }, {"nodevicecheck", 'n', nullptr, 0, "Skip serial eBUS device test", 0 }, {"readonly", 'r', nullptr, 0, "Only read from device, never write to it", 0 }, diff --git a/src/lib/ebus/device.cpp b/src/lib/ebus/device.cpp index d5ab9f82..9c72be49 100755 --- a/src/lib/ebus/device.cpp +++ b/src/lib/ebus/device.cpp @@ -97,7 +97,8 @@ Device::~Device() { } Device* Device::create(const char* name, unsigned int extraLatency, bool checkDevice, bool readOnly, bool initialSend) { - bool enhanced = strncmp(name, "enh:", 4) == 0; + bool highSpeed = strncmp(name, "ens:", 4) == 0; + bool enhanced = highSpeed || strncmp(name, "enh:", 4) == 0; if (enhanced) { name += 4; } @@ -762,7 +763,7 @@ result_t SerialDevice::open() { // create new settings memset(&newSettings, 0, sizeof(newSettings)); - cfsetspeed(&newSettings, m_enhancedProto ? B9600 : B2400); + cfsetspeed(&newSettings, m_enhancedProto ? (m_enhancedHighSpeed ? B115200 : B9600) : B2400); newSettings.c_cflag |= (CS8 | CLOCAL | CREAD); newSettings.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); // non-canonical mode newSettings.c_iflag |= IGNPAR; // ignore parity errors diff --git a/src/lib/ebus/device.h b/src/lib/ebus/device.h index f1454f21..e77312a3 100755 --- a/src/lib/ebus/device.h +++ b/src/lib/ebus/device.h @@ -346,10 +346,12 @@ class SerialDevice : public Device { * @param readOnly whether to allow read access to the device only. * @param initialSend whether to send an initial @a ESC symbol in @a open(). * @param enhancedProto whether to use the ebusd enhanced protocol. + * @param enhancedHighSpeed whether to use ebusd enhanced protocol in high speed mode. */ SerialDevice(const char* name, bool checkDevice, unsigned int extraLatency, bool readOnly, bool initialSend, - bool enhancedProto = false) - : Device(name, checkDevice, extraLatency, readOnly, initialSend, enhancedProto) {} + bool enhancedProto = false, bool enhancedHighSpeed = false) + : Device(name, checkDevice, extraLatency, readOnly, initialSend, enhancedProto), m_enhancedHighSpeed(enhancedHighSpeed) { + } // @copydoc result_t open() override; @@ -364,6 +366,9 @@ class SerialDevice : public Device { private: + /** whether to use ebusd enhanced protocol in high speed mode. */ + bool m_enhancedHighSpeed; + /** the previous settings of the device for restoring. */ termios m_oldSettings; };