Skip to content

Commit cf16ede

Browse files
Merge pull request #544 from Hyperloop-UPV/control-station/blcu
BLCU
2 parents eede506 + b4b1661 commit cf16ede

72 files changed

Lines changed: 4567 additions & 2199 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/frontend-tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
cache: "pnpm"
3030

3131
- name: Install dependencies
32-
run: pnpm install --frozen-lockfile --filter=testing-view --filter=competition-view --filter=ui --filter=core
32+
run: pnpm install --frozen-lockfile --filter=testing-view --filter=flashing-view --filter=competition-view --filter=ui --filter=core
3333

3434
- name: Build frontend
3535
run: pnpm build --filter="./frontend/**"

.github/workflows/release.yaml

Lines changed: 101 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
run: pnpm install --frozen-lockfile
6767

6868
- name: Build with Turbo
69-
run: pnpm turbo build --filter=testing-view --filter=competition-view
69+
run: pnpm turbo build --filter=testing-view --filter=competition-view --filter=flashing-view
7070

7171
- uses: actions/upload-artifact@v4
7272
with:
@@ -80,6 +80,12 @@ jobs:
8080
path: frontend/competition-view/dist/**
8181
retention-days: 1
8282

83+
- uses: actions/upload-artifact@v4
84+
with:
85+
name: flashing-dist
86+
path: frontend/flashing-view/dist/**
87+
retention-days: 1
88+
8389
build-backend:
8490
name: Build Backend - ${{ matrix.os }}
8591
needs: determine-version
@@ -125,22 +131,103 @@ jobs:
125131
path: electron-app/binaries/${{ matrix.binary }}
126132
retention-days: 1
127133

134+
build-blcu:
135+
name: Build BLCU - ${{ matrix.os }}
136+
needs: determine-version
137+
runs-on: ${{ matrix.os }}
138+
strategy:
139+
fail-fast: true
140+
matrix:
141+
include:
142+
- os: windows-latest
143+
binary: blcu-programming-windows-amd64.exe
144+
binary-base: blcu-programming-windows-amd64
145+
- os: ubuntu-latest
146+
binary: blcu-programming-linux-amd64
147+
binary-base: blcu-programming-linux-amd64
148+
- os: macos-latest
149+
binary: blcu-programming-darwin-arm64
150+
binary-base: blcu-programming-darwin-arm64
151+
- os: macos-15-intel
152+
binary: blcu-programming-darwin-amd64
153+
binary-base: blcu-programming-darwin-amd64
154+
steps:
155+
- uses: actions/checkout@v4
156+
157+
- uses: actions/setup-python@v5
158+
with:
159+
python-version: "3.11"
160+
161+
- name: Create virtual environment
162+
working-directory: blcu-programming
163+
run: python -m venv .venv-build
164+
165+
- name: Install dependencies
166+
working-directory: blcu-programming
167+
shell: bash
168+
run: |
169+
if [ "${{ runner.os }}" = "Windows" ]; then
170+
.venv-build/Scripts/pip install -r requirements-build.txt
171+
else
172+
.venv-build/bin/pip install -r requirements-build.txt
173+
fi
174+
175+
- name: Build with PyInstaller
176+
working-directory: blcu-programming
177+
shell: bash
178+
run: |
179+
if [ "${{ runner.os }}" = "Windows" ]; then
180+
PYTHON=".venv-build/Scripts/python"
181+
else
182+
PYTHON=".venv-build/bin/python"
183+
fi
184+
if [ "${{ runner.os }}" = "Windows" ]; then
185+
PATH_SEP=";"
186+
else
187+
PATH_SEP=":"
188+
fi
189+
"$PYTHON" -m PyInstaller \
190+
--clean \
191+
--noconfirm \
192+
--onefile \
193+
--name "${{ matrix.binary-base }}" \
194+
--distpath "../electron-app/binaries" \
195+
--hidden-import uvicorn.loops.auto \
196+
--hidden-import uvicorn.protocols.http.auto \
197+
--hidden-import uvicorn.protocols.websockets.auto \
198+
--hidden-import uvicorn.lifespan.on \
199+
--hidden-import multipart \
200+
--hidden-import multipart.multiparser \
201+
--paths "." \
202+
--add-data "BLCU-config.json${PATH_SEP}." \
203+
api/main.py
204+
205+
- uses: actions/upload-artifact@v4
206+
with:
207+
name: blcu-${{ matrix.os }}
208+
path: electron-app/binaries/${{ matrix.binary }}
209+
retention-days: 1
210+
128211
package-and-upload:
129212
name: Package & Upload - ${{ matrix.os }}
130-
needs: [determine-version, create-draft-release, build-frontend, build-backend]
213+
needs: [determine-version, create-draft-release, build-frontend, build-backend, build-blcu]
131214
runs-on: ${{ matrix.os }}
132215
strategy:
133216
fail-fast: true
134217
matrix:
135218
include:
136219
- os: windows-latest
137220
binary: backend-windows-amd64.exe
221+
blcu-binary: blcu-programming-windows-amd64.exe
138222
- os: ubuntu-latest
139223
binary: backend-linux-amd64
224+
blcu-binary: blcu-programming-linux-amd64
140225
- os: macos-latest
141226
binary: backend-darwin-arm64
227+
blcu-binary: blcu-programming-darwin-arm64
142228
- os: macos-15-intel
143229
binary: backend-darwin-amd64
230+
blcu-binary: blcu-programming-darwin-amd64
144231
steps:
145232
- uses: actions/checkout@v4
146233

@@ -150,6 +237,12 @@ jobs:
150237
name: backend-${{ matrix.os }}
151238
path: electron-app/binaries
152239

240+
- name: Download BLCU binary
241+
uses: actions/download-artifact@v4
242+
with:
243+
name: blcu-${{ matrix.os }}
244+
path: electron-app/binaries
245+
153246
- name: Set executable permissions (Unix)
154247
if: runner.os != 'Windows'
155248
run: chmod +x electron-app/binaries/*
@@ -166,6 +259,12 @@ jobs:
166259
name: competition-dist
167260
path: electron-app/renderer/competition-view
168261

262+
- name: Download flashing-view dist
263+
uses: actions/download-artifact@v4
264+
with:
265+
name: flashing-dist
266+
path: electron-app/renderer/flashing-view
267+
169268
- uses: pnpm/action-setup@v4
170269
with:
171270
version: 10.26.0

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ node_modules/
1010

1111
# Global binaries
1212
*.exe
13+
14+
# electron modules
15+
electron-app/python
16+
electron-app/logger

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ Before starting, ensure you have the following installed:
1313
- **PNPM** (v10.26.0+)
1414
- **Node.js** (v20+)
1515
- **Go** (for the backend)
16+
- **Python** (v3.11+, for the BLCU programming service)
17+
18+
`pnpm install` automatically creates the Python virtual environment and installs dependencies for the BLCU programming service on Windows, macOS, and Linux.
1619

1720
---
1821

@@ -24,7 +27,9 @@ Our `pnpm-workspace.yaml` defines the following workspaces:
2427
| :----------------------------- | :------- | :---------------------------------------------------- |
2528
| `testing-view` | TS/React | Web interface for telemetry testing |
2629
| `competition-view` | TS/React | UI for the competition |
30+
| `flashing-view` | TS/React | UI for flashing firmware to the BLCU board |
2731
| `backend` | Go | Data ingestion and pod communication server |
32+
| `blcu-programming` | Python | FastAPI service that flashes firmware to the BLCU board via TFTP |
2833
| `hyperloop-control-station` | JS | The main Control Station electron desktop application |
2934
| `e2e` | TS | End-to-end tests for the whole app (Playwright) |
3035
| `@workspace/ui` | TS/React | Shared UI component library (frontend-kit) |
@@ -67,8 +72,14 @@ All Turbo scripts support filtering to target specific workspaces:
6772
- `pnpm build:linux` – Packages the Electron app for Linux.
6873
- `pnpm build:mac` – Packages the Electron app for macOS.
6974

75+
#### Frontend View Scripts
76+
77+
- `pnpm build:testing-view` – Builds only the Testing View frontend.
78+
- `pnpm build:competition-view` – Builds only the Competition View frontend.
79+
- `pnpm build:flashing-view` – Builds only the Flashing View frontend.
80+
7081
#### Utility Scripts
7182

7283
- `pnpm ui:add <component-name>` - To add shadcn/ui components
7384

74-
> Note: don't forget to also include it in frontend-kit/ui/src/components/shadcn/index.ts to be able to access it from @workspace/ui
85+
> Note: don't forget to also include it in frontend-kit/ui/src/components/shadcn/index.ts to be able to access it from @workspace/ui

backend/package-lock.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/pkg/adj/validator.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package adj
22

33
import (
4+
"os"
45
"os/exec"
56
"path"
67
"strings"
@@ -62,6 +63,13 @@ func Validate() {
6263
// If none of the candidates are found, an empty string is returned,
6364
// indicating that no Python interpreter is available.
6465
func pythonCommand() string {
66+
// Prefer bundled Python shipped with the Electron app
67+
if bundled := os.Getenv("HYPERLOOP_PYTHON_PATH"); bundled != "" {
68+
if _, err := os.Stat(bundled); err == nil {
69+
return bundled
70+
}
71+
}
72+
6573
candidates := []string{"python3", "python", "py"}
6674

6775
for _, c := range candidates {

blcu-programming/BLCU-config.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"blcu": {
3+
"host": "192.168.0.27",
4+
"port": 69,
5+
"UDP_PORT_DESTINATION": 50420,
6+
"TCP_PORT_SERVER": 50500
7+
8+
},
9+
"adj-data": {
10+
"LVBMS": "192.168.1.11",
11+
"HVBMS": "192.168.1.17",
12+
"PCU": "192.168.1.5",
13+
"LCU": "192.168.1.4",
14+
"VCU": "192.168.1.3"
15+
},
16+
"orders":{
17+
"Write Program": {"id":"700", "description":"Write Program to BLCU", "enum-order": [
18+
"VCU",
19+
"HVBMS",
20+
"LVBMS",
21+
"PCU",
22+
"LCU"
23+
]}
24+
},
25+
"packet":{
26+
27+
"id": 1,
28+
"general_state_machine": [
29+
"Connecting",
30+
"Operational",
31+
"Fault"
32+
] ,
33+
"operational_state_machine":[
34+
"Idle",
35+
"Flashing"
36+
]
37+
},
38+
"api": {
39+
"host": "0.0.0.0",
40+
"port": 8069,
41+
"log_level": "info"
42+
},
43+
"log_file": "tftp_server_activity.log"
44+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"blcu": {
3+
"host": "127.0.0.27",
4+
"port": 69,
5+
"UDP_PORT_DESTINATION": 50400,
6+
"TCP_PORT_SERVER": 50500
7+
8+
},
9+
"adj-data": {
10+
"LVBMS": "192.168.1.11",
11+
"HVBMS": "192.168.1.17",
12+
"PCU": "192.168.1.5",
13+
"LCU": "192.168.1.4",
14+
"VCU": "192.168.1.3"
15+
},
16+
"orders":{
17+
"Write Program": {"id":"700", "description":"Write Program to BLCU", "enum-order": [
18+
"VCU",
19+
"HVBMS",
20+
"LVBMS",
21+
"PCU",
22+
"LCU"
23+
]}
24+
},
25+
"packet":{
26+
27+
"id": 134,
28+
"general_state_machine": [
29+
"Connecting",
30+
"Operational",
31+
"Fault"
32+
] ,
33+
"operational_state_machine":[
34+
"Idle",
35+
"Flashing"
36+
]
37+
},
38+
"api": {
39+
"host": "0.0.0.0",
40+
"port": 8069,
41+
"log_level": "info"
42+
},
43+
"log_file": "tftp_server_activity.log"
44+
}

0 commit comments

Comments
 (0)