[posix-host] add hardware flow control capability to hdlc interface (#4518)
diff --git a/src/posix/platform/hdlc_interface.cpp b/src/posix/platform/hdlc_interface.cpp
index fd1b873..0b90864 100644
--- a/src/posix/platform/hdlc_interface.cpp
+++ b/src/posix/platform/hdlc_interface.cpp
@@ -417,6 +417,7 @@
int speed = 115200;
int cstopb = 1;
char parity = 'N';
+ char flow = 'N';
VerifyOrExit((rval = tcgetattr(fd, &tios)) == 0);
@@ -424,10 +425,10 @@
tios.c_cflag = CS8 | HUPCL | CREAD | CLOCAL;
- // example: 115200N1
+ // example: 115200N1H
if (aConfig != NULL)
{
- sscanf(aConfig, "%u%c%d", &speed, &parity, &cstopb);
+ sscanf(aConfig, "%u%c%d%c", &speed, &parity, &cstopb, &flow);
}
switch (parity)
@@ -442,7 +443,6 @@
break;
default:
// not supported
- assert(false);
DieNow(OT_EXIT_INVALID_ARGUMENTS);
break;
}
@@ -456,7 +456,6 @@
tios.c_cflag |= CSTOPB;
break;
default:
- assert(false);
DieNow(OT_EXIT_INVALID_ARGUMENTS);
break;
}
@@ -544,7 +543,19 @@
break;
#endif
default:
- assert(false);
+ DieNow(OT_EXIT_INVALID_ARGUMENTS);
+ break;
+ }
+
+ switch (flow)
+ {
+ case 'N':
+ break;
+ case 'H':
+ tios.c_cflag |= CRTSCTS;
+ break;
+ default:
+ // not supported
DieNow(OT_EXIT_INVALID_ARGUMENTS);
break;
}