Skip to content

Commit

Permalink
v2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Paolo-Beci committed May 2, 2024
1 parent b9964cb commit 0ca5000
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CONFIG.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
VALUES=example1 example2 NOPE example3
NEWLINE=;
NEWLINE=LF
SEPARATOR=,
BAUDRATE=9600
UDP_PORT=4444
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ 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' is not currently supported. 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 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.

With the configuration shown above you can send the following JSON (assuming CSV data is: 1,2,3,4\n):
```json
Expand Down
7 changes: 7 additions & 0 deletions backend/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ def open_stream_udp(UDP_PORT):
# Read data from the serial port
def read_serial_data(ser_socket, udp_socket, VALUES, NEWLINE, SEPARATOR, UDP_PORT):
data_buffer = ""

# NEWLINE translation of special characters
if NEWLINE == "LF":
NEWLINE = "\n"
elif NEWLINE == "CRLF":
NEWLINE = "\r\n"

def read_data_handler(data_buffer):
while True:
try:
Expand Down
Binary file modified img/app.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ def __init__(self):
# Config parameters
self.PATH_CONFIG_MODEL = "Path"
self.VALUES=['example1','example2','example3']
self.NEWLINE=b';'
self.SEPARATOR=b','
self.NEWLINE=';'
self.SEPARATOR=','
self.BAUDRATE=9600
self.UDP_PORT=5000
self.SERIAL_PORT=b'/dev/ttyUSB0'
self.SERIAL_PORT='/dev/ttyUSB0'

# Flag
self.connected = False
Expand Down Expand Up @@ -49,14 +49,14 @@ def __init__(self):
self.browse_button_config_model.pack(pady=10)

# Values
self.label_values = tk.Label(self.app, text="Insert data label values:")
self.label_values = tk.Label(self.app, text="Insert data label values, separated by spaces:")
self.label_values.pack()
self.textbox_values = tk.Text(self.app, height=1, width=50)
self.textbox_values.insert("1.0", self.VALUES)
self.textbox_values.pack()

# Newline
self.label_newline = tk.Label(self.app, text="Insert newline separator for the upcoming CSV stream:")
self.label_newline = tk.Label(self.app, text="Insert newline separator for the upcoming CSV stream. \nInsert LF->'\\n' and CRLF->'\\r\\n':")
self.label_newline.pack()
self.textbox_newline = tk.Text(self.app, height=1, width=30)
self.textbox_newline.insert("1.0", self.NEWLINE)
Expand Down

0 comments on commit 0ca5000

Please sign in to comment.