add high speed serial mode

This commit is contained in:
John
2022-04-10 16:37:54 +02:00
parent 5777af8b03
commit aa50e2388c
3 changed files with 12 additions and 5 deletions
+2 -1
View File
@@ -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 },
+3 -2
View File
@@ -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
+7 -2
View File
@@ -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;
};