summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2016-10-30 20:15:35 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2016-10-30 20:15:35 +0100
commit7068a697b235f1ae05bc1a5cf93e7eeefbe7a1df (patch)
treef946f96d0caa262b7b25bc1b74a26673064aeeff
parent804fe1979f9ed7bef7badaf0aa08e35e09874772 (diff)
downloaddabmux-7068a697b235f1ae05bc1a5cf93e7eeefbe7a1df.tar.gz
dabmux-7068a697b235f1ae05bc1a5cf93e7eeefbe7a1df.tar.bz2
dabmux-7068a697b235f1ae05bc1a5cf93e7eeefbe7a1df.zip
Fix PRBS url parsing
-rw-r--r--src/input/Prbs.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/input/Prbs.cpp b/src/input/Prbs.cpp
index b9e244b..8e5a9ae 100644
--- a/src/input/Prbs.cpp
+++ b/src/input/Prbs.cpp
@@ -46,17 +46,23 @@ const uint32_t PRBS_DEFAULT_POLY = (1 << 19) | (1 << 16) | 1;
int Prbs::open(const string& name)
{
- if (name.empty()) {
+ if (name.substr(0, 7) != "prbs://") {
+ throw logic_error("Invalid PRBS name");
+ }
+
+ const string& url_polynomial = name.substr(7);
+
+ if (url_polynomial.empty()) {
m_prbs.setup(PRBS_DEFAULT_POLY);
}
else {
- if (name[0] != ':') {
+ if (url_polynomial[0] != ':') {
throw invalid_argument(
"Invalid PRBS address format. "
"Must be prbs://:polynomial.");
}
- const string poly_str = name.substr(1);
+ const string poly_str = url_polynomial.substr(1);
long polynomial = hexparse(poly_str);