Skip to content

Commit 241ceaf

Browse files
authored
Merge branch 'develop' into chore/improve-dev-environment
2 parents 4301518 + e50eb4c commit 241ceaf

4 files changed

Lines changed: 72 additions & 10 deletions

File tree

backend/cmd/config.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,17 @@ type Transport struct {
1818
PropagateFault bool
1919
}
2020

21+
type Blcu struct {
22+
IP string
23+
DownloadOrderId uint16
24+
UploadOrderId uint16
25+
}
26+
2127
type Config struct {
2228
Vehicle vehicle.Config
2329
Server server.Config
2430
Adj Adj
2531
Network Network
2632
Transport Transport
33+
Blcu Blcu
2734
}

backend/cmd/config.toml

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,48 @@
1+
# Hyperloop UPV Backend Configuration
2+
# Configuration file for the H10 Control Station backend server
3+
4+
# Vehicle Configuration
15
[vehicle]
2-
boards = ["HVSCU", "PCU"]
6+
boards = ["HVSCU", "PCU", "BLCU"]
7+
8+
# BLCU (Boot Loader Control Unit) Configuration
9+
[blcu]
10+
ip = "127.0.0.1" # TFTP server IP address
11+
download_order_id = 1 # Packet ID for download orders (0 = use default)
12+
upload_order_id = 2 # Packet ID for upload orders (0 = use default)
13+
14+
# Server Configuration
315
[server.ethernet-view]
416
address = "127.0.0.1:4040"
517
static = "./ethernet-view"
18+
619
[server.ethernet-view.endpoints]
720
pod_data = "/podDataStructure"
821
order_data = "/orderStructures"
922
programable_boards = "/uploadableBoards"
1023
connections = "/backend"
1124
files = "/"
25+
1226
[server.control-station]
1327
address = "127.0.0.1:4000"
1428
static = "./control-station"
29+
1530
[server.control-station.endpoints]
1631
pod_data = "/podDataStructure"
1732
order_data = "/orderStructures"
1833
programable_boards = "/uploadableBoards"
1934
connections = "/backend"
2035
files = "/"
36+
37+
# ADJ (Architecture Description JSON) Configuration
2138
[adj]
22-
branch = "main" # Leave blank when using ADJ as a submodule (like this: "")
23-
test = true
39+
branch = "software" # Leave blank when using ADJ as a submodule (like this: "")
40+
test = true # Enable test mode
41+
42+
# Network Configuration
2443
[network]
25-
manual = false
44+
manual = true # Manual network device selection
45+
46+
# Transport Configuration
2647
[transport]
27-
propagate_fault = true
48+
propagate_fault = true # Propagate fault messages like VCU

backend/cmd/main.go

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,20 @@ func main() {
221221
vehicle.SetTransport(transp)
222222

223223
// <--- BLCU Board --->
224-
// Register BLCU board for handling bootloader operations
225-
if blcuIP, exists := adj.Info.Addresses[BLCU]; exists {
224+
// Register BLCU board for handling bootloader operations if configured
225+
if common.Contains(config.Vehicle.Boards, "BLCU") {
226+
// Use BLCU address from config, ADJ, or default localhost
227+
blcuIP := config.Blcu.IP
228+
if blcuIP == "" {
229+
if adjBlcuIP, exists := adj.Info.Addresses[BLCU]; exists {
230+
blcuIP = adjBlcuIP
231+
} else {
232+
blcuIP = "127.0.0.1" // Default TFTP server address
233+
}
234+
}
226235
blcuBoard := boards.New(blcuIP)
227236
vehicle.AddBoard(blcuBoard)
228237
trace.Info().Str("ip", blcuIP).Msg("BLCU board registered")
229-
} else {
230-
trace.Warn().Msg("BLCU address not found in ADJ")
231238
}
232239

233240
// <--- transport --->
@@ -243,6 +250,33 @@ func main() {
243250
transp.SetTargetIp(adj.Info.Addresses[board.Name], abstraction.TransportTarget(board.Name))
244251
}
245252

253+
// Set BLCU packet ID mappings if BLCU is configured
254+
if common.Contains(config.Vehicle.Boards, "BLCU") {
255+
// Use configurable packet IDs or defaults
256+
downloadOrderId := config.Blcu.DownloadOrderId
257+
uploadOrderId := config.Blcu.UploadOrderId
258+
if downloadOrderId == 0 {
259+
downloadOrderId = boards.BlcuDownloadOrderId
260+
}
261+
if uploadOrderId == 0 {
262+
uploadOrderId = boards.BlcuUploadOrderId
263+
}
264+
265+
transp.SetIdTarget(abstraction.PacketId(downloadOrderId), abstraction.TransportTarget("BLCU"))
266+
transp.SetIdTarget(abstraction.PacketId(uploadOrderId), abstraction.TransportTarget("BLCU"))
267+
268+
// Use BLCU address from config, ADJ, or default
269+
blcuIP := config.Blcu.IP
270+
if blcuIP == "" {
271+
if adjBlcuIP, exists := adj.Info.Addresses[BLCU]; exists {
272+
blcuIP = adjBlcuIP
273+
} else {
274+
blcuIP = "127.0.0.1"
275+
}
276+
}
277+
transp.SetTargetIp(blcuIP, abstraction.TransportTarget("BLCU"))
278+
}
279+
246280
// Start handling TCP client connections
247281
i := 0
248282
serverTargets := make(map[string]abstraction.TransportTarget)

backend/pkg/broker/topics/blcu/download.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func (download *Download) handleDownload(message *websocket.Message) error {
8787
return err
8888
}
8989

90-
pushErr := download.api.UserPush(downloadRequest)
90+
pushErr := download.api.UserPush(&downloadRequest)
9191
return pushErr
9292
}
9393

0 commit comments

Comments
 (0)