Commit 636ae957 authored by Lenard Nagy's avatar Lenard Nagy
Browse files

Multiple EOL characters are possible to set


Signed-off-by: Lenard Nagy's avatarLenard Nagy <lenard.nagy@ericsson.com>
parent 976c3fb0
......@@ -20,7 +20,6 @@ namespace SerialPortTypes {
//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 @@ namespace SerialPortTypes {
}
//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 @@ namespace SerialPortTypes {
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);
}
}
}
}
......
......@@ -29,8 +29,8 @@ LogEntityName := Yes
[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 @@ LogEntityName := Yes
*.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
......
......@@ -20,6 +20,7 @@
#include <errno.h>
#include <string.h>
#include <termios.h>
#include <vector>
namespace SerialPortTypes {
......@@ -53,7 +54,7 @@ namespace SerialPortTypes {
speed_t speed;
int parity;
int blocking;
char eolChar;
std::vector<char> eolChars;
int dataBits;
int stopBit;
CHARSTRING ret_buffer;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment