Multiple EOL characters are possible to set
Signed-off-by: Lenard Nagy <lenard.nagy@ericsson.com>
diff --git a/src/SerialPort.cc b/src/SerialPort.cc
index 3dd51d7..5db3f59 100644
--- a/src/SerialPort.cc
+++ b/src/SerialPort.cc
@@ -20,7 +20,6 @@
//Set default values
speed = B9600; //9600 baud
blocking = 1; //set blocking
- eolChar = '\n'; //set line ending char
dataBits = CS8; //8 data bits
stopBit = ~CSTOPB; //1 stop bit
parity = 0; //parity: none
@@ -111,9 +110,9 @@
}
//printf("Parameter %s set to %s (int: %d)\n", parameter_name, parameter_value, blocking);
- } else if (strcmp(parameter_name, "EOLChar") == 0) {
- eolChar = parameter_value[0];
- //printf("Parameter %s set to %s (int: %d)\n", parameter_name, parameter_value, eolChar);
+ } else if (strncmp(parameter_name, "EOLChar", 7) == 0) {
+ eolChars.push_back(parameter_value[0]);
+ printf("Parameter %s set to %s (int: %d)\n", parameter_name, parameter_value, eolChars.back());
} else if (strcmp(parameter_name, "dataBits") == 0) {
if (strcmp(parameter_value, "5") == 0) {
dataBits = CS5;
@@ -172,11 +171,13 @@
ret_buffer = CHARSTRING(read_bytes, (const char*)pointer);
}
- if (input_buffer[0] == eolChar) { //EOL received, returning
- //printf("EOL received, returning");
- CHARSTRING ret_val = CHARSTRING(ret_buffer);
- ret_buffer = CHARSTRING("");
- incoming_message(ret_val);
+ for(unsigned int i = 0; i < eolChars.size(); i++){
+ if (input_buffer[0] == eolChars.at(i)) { //EOL received, returning
+ //printf("EOL received, returning");
+ CHARSTRING ret_val = CHARSTRING(ret_buffer);
+ ret_buffer = CHARSTRING("");
+ incoming_message(ret_val);
+ }
}
}
}
diff --git a/src/SerialPort.cfg b/src/SerialPort.cfg
index eef5fe6..292b62e 100644
--- a/src/SerialPort.cfg
+++ b/src/SerialPort.cfg
@@ -29,8 +29,8 @@
[TESTPORT_PARAMETERS]
# In this section you can specify parameters that are passed to Test Ports.
-*.SerialPort1.deviceFileName := "/dev/ttyUSB0"
-*.SerialPort2.deviceFileName := "/dev/ttyUSB1"
+*.SerialPort1.deviceFileName := "/dev/ttyS4" #"/dev/ttyUSB0"
+*.SerialPort2.deviceFileName := "/dev/ttyS5" #"/dev/ttyUSB1"
## Baud rate of port
# Valid values:
@@ -60,8 +60,13 @@
*.SerialPort1.deviceBlocking := "yes"
*.SerialPort2.deviceBlocking := "yes"
-## EOL character
+## EOL character
+#
+# !!WARNING!! Mandatory parameter
+# Please set minimum 1 EOL char for each port
+##
*.SerialPort1.EOLChar := "\n"
+*.SerialPort1.EOLChar := ">"
*.SerialPort2.EOLChar := "\n"
## Number of data bits
diff --git a/src/SerialPort.hh b/src/SerialPort.hh
index 9c9a016..3faf90d 100644
--- a/src/SerialPort.hh
+++ b/src/SerialPort.hh
@@ -20,6 +20,7 @@
#include <errno.h>
#include <string.h>
#include <termios.h>
+#include <vector>
namespace SerialPortTypes {
@@ -53,7 +54,7 @@
speed_t speed;
int parity;
int blocking;
- char eolChar;
+ std::vector<char> eolChars;
int dataBits;
int stopBit;
CHARSTRING ret_buffer;