From f8d481d7676ced556a7543bfa8d815bac591750b Mon Sep 17 00:00:00 2001 From: Paolo Date: Mon, 10 Jun 2024 22:18:37 +0200 Subject: [PATCH] v2.8.2 --- CONFIG.txt | 4 ++-- README.md | 4 ++-- main.py | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CONFIG.txt b/CONFIG.txt index 61825e6..8ba924e 100644 --- a/CONFIG.txt +++ b/CONFIG.txt @@ -1,6 +1,6 @@ -VALUES=example1 example2 NOPE example3 +VALUES=example1,example2,NOPE,example3 NEWLINE=LF SEPARATOR=, BAUDRATE=9600 UDP_PORT=4444 -SERIAL_PORT=/dev/tty.usbmodem11301 \ No newline at end of file +SERIAL_PORT=/dev/tty.usbmodem21301 \ No newline at end of file diff --git a/README.md b/README.md index 864218e..aa8e42e 100644 --- a/README.md +++ b/README.md @@ -18,14 +18,14 @@ pip install -r requirements.txt ### CONFIG file To configure the parameters of the program you have to create a `CONFIG.txt` file with the following parameters: ```txt -VALUES=PARAM1 PARAM2 NULL PARAM3 +VALUES=PARAM1,PARAM2,NULL,PARAM3 NEWLINE=; SEPARATOR=, BAUDRATE=9600 UDP_PORT=5000 SERIAL_PORT=/dev/ttyUSB0 ``` -The `VALUES` params separated by a space indicate the order of the values in the CSV string. The NULL value indicates that the value is not going to be sent, but discarded when the CSV comes into the program. The `NEWLINE` param indicates the character that separates the CSV strings, the usage of '\n' as a NEWLINE can be achieved via the 'LF' symbol and the '\r\n' via the 'CRLF' one (ex: NEWLINE=LF). The `SEPARATOR` param indicates the character that separates the values in the CSV string. The `BAUDRATE` param indicates the baudrate of the serial port. The `UDP_PORT` param indicates the port of the UDP server. The `SERIAL_PORT` param indicates the serial port to use. +The `VALUES` params must be separated by the `SEPARATOR` character, they indicate the order of the values in the CSV string (note that spaces will be replaced with "_"). The NULL value indicates that the value is not going to be sent, but discarded when the CSV comes into the program. The `NEWLINE` param indicates the character that separates the CSV strings, the usage of '\n' as a NEWLINE can be achieved via the 'LF' symbol and the '\r\n' via the 'CRLF' one (ex: NEWLINE=LF). The `SEPARATOR` param indicates the character that separates the values in the CSV string. The `BAUDRATE` param indicates the baudrate of the serial port. The `UDP_PORT` param indicates the port of the UDP server. The `SERIAL_PORT` param indicates the serial port to use. With the configuration shown above you can send the following JSON (assuming CSV data is: 1,2,3,4\n): ```json diff --git a/main.py b/main.py index 6092bad..3ef327c 100644 --- a/main.py +++ b/main.py @@ -11,7 +11,7 @@ def __init__(self): # Config parameters self.PATH_CONFIG_MODEL = "Path" - self.VALUES=['example1','example2','example3'] + self.VALUES=['example1,example2,example3'] self.NEWLINE=';' self.SEPARATOR=',' self.BAUDRATE=9600 @@ -171,7 +171,7 @@ def startup(self): elif name == 'SERIAL_PORT': self.SERIAL_PORT = value elif name == 'VALUES': - self.VALUES = value + self.VALUES = value.replace(' ', '_').strip() # Update the interface with new values self.update_interface() @@ -191,7 +191,7 @@ def update_interface(self): self.textbox_baudrate.insert("1.0", str(self.BAUDRATE)) def save_to_config_file(self): - values_string = " ".join(self.VALUES) + values_string = ",".join(self.VALUES) if self.PATH_CONFIG_MODEL != "Path": with open(self.PATH_CONFIG_MODEL, 'w') as f: