Skip to content

Commit

Permalink
feat: github build actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Paolo-Beci committed Apr 15, 2024
1 parent fea2442 commit acc21e6
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 17 deletions.
Binary file modified .DS_Store
Binary file not shown.
39 changes: 39 additions & 0 deletions .github/workflows/build_executables.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build Executables

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Install Dependencies
run: |
pip install -r requirements.txt
- name: Build Windows Executable
if: runner.os == 'Windows'
run: |
docker run --rm -v ${PWD}:/workspace -w /workspace quay.io/pypa/manylinux2014_x86_64 bash -c "pyinstaller --name SCannerAdapter --onefile main.py"
- name: Build macOS Executable
if: runner.os == 'macOS'
run: |
pyinstaller --name SCannerAdapter --onefile main.py
- name: Build Linux Executable
if: runner.os == 'Linux'
run: |
pyinstaller --name SCannerAdapter --onefile main.py
- name: Archive Artifacts
uses: actions/upload-artifact@v2
with:
name: executables
path: dist/
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,6 @@ cython_debug/
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
#.idea/

tempCodeRunnerFile.py
23 changes: 8 additions & 15 deletions backend/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,42 +59,35 @@ def open_stream_plotjuggler(port):
try:
# Create a UDP socket
server_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

# Bind the socket to the port
server_socket.bind(("localhost", port))
# server_socket.bind((LOCALHOST_IP, port))

print(f"JSON streaming server for PlotJuggler is listening on port {port}")

# Function to handle PlotJuggler connections
def handle_client(client_address):
def handle_client():
try:
while True:
# Generate JSON data (replace with your actual data)
example_json_data = {'Engine_Speed': 0, 'Inlet_Manifold_Pressure': 97.6, 'Inlet_Air_Temperature': 32, 'Throttle_Position': 17.3}
print(f"Sending JSON data to {client_address}: {example_json_data}")
print(f"Sending JSON data to port {port}: {example_json_data}")

# Convert JSON data to string
json_str = json.dumps(example_json_data)

# Send JSON data to the client
server_socket.sendto(json_str.encode(), client_address)
server_socket.sendto(json_str.encode(), ("0.0.0.0", port)) # Check with cmd: nc -ul 9870

time.sleep(1)
except Exception as e:
print(f"Error handling client connection: {e}")

# Accept incoming connections and handle them in a separate thread
print("Waiting for connections...")
while True:
data, client_address = server_socket.recvfrom(1024)
print(f"Accepted connection from {client_address}")
client_thread = threading.Thread(target=handle_client, daemon=True, args=(client_address,))
client_thread.start()
# Start the thread to handle PlotJuggler connections
stream_plotjuggler_thread = threading.Thread(target=handle_client, daemon=True)
stream_plotjuggler_thread.start()

except Exception as e:
print(f"Error opening JSON streaming server: {e}")
finally:
server_socket.close()

# Cannelloni CAN stream to JSON converter
def cannelloni_to_json(message_cannelloni, dbc_path):
Expand Down
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(self):
self.label_ip_scanner = tk.Label(self.app, text="IP SCanner:")
self.label_ip_scanner.pack()
self.textbox_ip_scanner = tk.Text(self.app, height=1, width=30)
self.textbox_ip_scanner.insert("1.0", "127.0.0.1") # Default IP address
self.textbox_ip_scanner.insert("1.0", "8.8.8.8") # Default IP address
self.textbox_ip_scanner.pack()

# CAN0 Port
Expand Down

0 comments on commit acc21e6

Please sign in to comment.