mirror of
https://github.com/espressif/openthread.git
synced 2026-08-25 03:39:52 +00:00
[posix-host] add hardware flow control capability to hdlc interface (#4518)
This commit is contained in:
@@ -417,6 +417,7 @@ int HdlcInterface::OpenFile(const char *aFile, const char *aConfig)
|
||||
int speed = 115200;
|
||||
int cstopb = 1;
|
||||
char parity = 'N';
|
||||
char flow = 'N';
|
||||
|
||||
VerifyOrExit((rval = tcgetattr(fd, &tios)) == 0);
|
||||
|
||||
@@ -424,10 +425,10 @@ int HdlcInterface::OpenFile(const char *aFile, const char *aConfig)
|
||||
|
||||
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 @@ int HdlcInterface::OpenFile(const char *aFile, const char *aConfig)
|
||||
break;
|
||||
default:
|
||||
// not supported
|
||||
assert(false);
|
||||
DieNow(OT_EXIT_INVALID_ARGUMENTS);
|
||||
break;
|
||||
}
|
||||
@@ -456,7 +456,6 @@ int HdlcInterface::OpenFile(const char *aFile, const char *aConfig)
|
||||
tios.c_cflag |= CSTOPB;
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
DieNow(OT_EXIT_INVALID_ARGUMENTS);
|
||||
break;
|
||||
}
|
||||
@@ -544,7 +543,19 @@ int HdlcInterface::OpenFile(const char *aFile, const char *aConfig)
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user