Skip to content

Commit 742eec1

Browse files
committed
Add option in config.toml to enable progagating fault
1 parent c8ae2d8 commit 742eec1

4 files changed

Lines changed: 20 additions & 6 deletions

File tree

backend/cmd/config.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@ type Network struct {
1414
Manual bool
1515
}
1616

17+
type Transport struct {
18+
PropagateFault bool
19+
}
20+
1721
type Config struct {
18-
Vehicle vehicle.Config
19-
Server server.Config
20-
Adj Adj
21-
Network Network
22+
Vehicle vehicle.Config
23+
Server server.Config
24+
Adj Adj
25+
Network Network
26+
Transport Transport
2227
}

backend/cmd/config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ branch = "main" # Leave blank when using ADJ as a submodule (like this: "")
2323
test = true
2424
[network]
2525
manual = false
26+
[transport]
27+
propagate_fault = false

backend/cmd/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ import (
3333
vehicle_models "github.com/HyperloopUPV-H8/h9-backend/internal/vehicle/models"
3434
"github.com/HyperloopUPV-H8/h9-backend/pkg/abstraction"
3535
"github.com/HyperloopUPV-H8/h9-backend/pkg/broker"
36-
connection_topic "github.com/HyperloopUPV-H8/h9-backend/pkg/broker/topics/connection"
3736
blcu_topics "github.com/HyperloopUPV-H8/h9-backend/pkg/broker/topics/blcu"
37+
connection_topic "github.com/HyperloopUPV-H8/h9-backend/pkg/broker/topics/connection"
3838
data_topic "github.com/HyperloopUPV-H8/h9-backend/pkg/broker/topics/data"
3939
logger_topic "github.com/HyperloopUPV-H8/h9-backend/pkg/broker/topics/logger"
4040
message_topic "github.com/HyperloopUPV-H8/h9-backend/pkg/broker/topics/message"
@@ -322,6 +322,7 @@ func main() {
322322

323323
// <--- transport --->
324324
transp := transport.NewTransport(trace.Logger)
325+
transp.SetpropagateFault(config.Transport.PropagateFault)
325326

326327
// <--- vehicle --->
327328
ipToBoardId := make(map[string]abstraction.BoardId)

backend/pkg/transport/transport.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ type Transport struct {
3636

3737
tftp *tftp.Client
3838

39+
propagateFault bool
40+
3941
api abstraction.TransportAPI
4042

4143
logger zerolog.Logger
@@ -331,7 +333,7 @@ func (transport *Transport) handleConversation(socket network.Socket, reader io.
331333
}
332334

333335
// Intercept packets with id == 0 and replicate
334-
if packet.Id() == 0 {
336+
if transport.propagateFault && packet.Id() == 0 {
335337
conversationLogger.Info().Msg("replicating packet with id 0 to all boards")
336338
err := transport.handlePacketEvent(NewPacketMessage(packet))
337339
if err != nil {
@@ -362,3 +364,7 @@ func (transport *Transport) SendFault() {
362364
// transport.errChan <- err
363365
// }
364366
}
367+
368+
func (transport *Transport) SetpropagateFault(enabled bool) {
369+
transport.propagateFault = enabled
370+
}

0 commit comments

Comments
 (0)