Skip to content

Commit

Permalink
v2.8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Paolo-Beci committed Jun 10, 2024
1 parent bc5f637 commit f8d481d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions CONFIG.txt
Original file line number Diff line number Diff line change
@@ -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
SERIAL_PORT=/dev/tty.usbmodem21301
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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:
Expand Down

0 comments on commit f8d481d

Please sign in to comment.