Skip to content

Commit 2f2c347

Browse files
committed
Merge branch 'main' into develop
2 parents 4e841cd + 3d7e364 commit 2f2c347

4 files changed

Lines changed: 14 additions & 11 deletions

File tree

backend/cmd/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ connections = "/backend"
1111
file_server = "/"
1212

1313
[vehicle]
14-
boards = ["BLCU"]
14+
boards = ["VCU"]
1515

1616
[vehicle.network]
1717
tcp_client_tag = "TCP_CLIENT"

backend/cmd/main.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"runtime"
1414
"runtime/pprof"
1515
"strings"
16-
"time"
1716

1817
blcuPackage "github.com/HyperloopUPV-H8/h9-backend/internal/blcu"
1918
"github.com/HyperloopUPV-H8/h9-backend/internal/common"
@@ -164,14 +163,11 @@ func main() {
164163

165164
transp := transport.NewTransport()
166165

167-
prev := time.Now()
168166
transp.SetAPI(&TransportAPI{
169167
OnNotification: func(notification abstraction.TransportNotification) {
170168
packet := notification.(transport.PacketNotification)
171169
switch p := packet.Packet.(type) {
172170
case *data.Packet:
173-
fmt.Println(time.Since(prev))
174-
prev = time.Now()
175171
if _, ok := orders[p.Id()]; ok {
176172
loggerHandler.Log(order_logger.LoggableOrder(*p))
177173
return
@@ -206,7 +202,9 @@ func main() {
206202
}
207203
},
208204

209-
OnConnectionUpdate: func(target abstraction.TransportTarget, isConnected bool) {},
205+
OnConnectionUpdate: func(target abstraction.TransportTarget, isConnected bool) {
206+
connectionTransfer.Update(string(target), isConnected)
207+
},
210208
})
211209

212210
// Load and set packet decoder and encoder
@@ -221,7 +219,7 @@ func main() {
221219
}
222220

223221
// Start handling TCP client connections
224-
backendTcpClientAddr, err := net.ResolveTCPAddr("tcp", fmt.Sprintf("%s:%d", info.Addresses.Backend, info.Ports.TcpClient))
222+
backendTcpClientAddr, err := net.ResolveTCPAddr("tcp", fmt.Sprintf("%s:%d", info.Addresses.Backend.String(), info.Ports.TcpClient))
225223
if err != nil {
226224
panic("Failed to resolve local backend TCP client address")
227225
}
@@ -231,7 +229,7 @@ func main() {
231229
serverTargets[fmt.Sprintf("%s:%d", info.Addresses.Boards[board.Name], info.Ports.TcpClient)] = abstraction.TransportTarget(board.Name)
232230
continue
233231
}
234-
go transp.HandleClient(tcp.NewClient(backendTcpClientAddr), abstraction.TransportTarget(board.Name), "tcp", string(info.Addresses.Boards[board.Name]))
232+
go transp.HandleClient(tcp.NewClient(backendTcpClientAddr), abstraction.TransportTarget(board.Name), "tcp", fmt.Sprintf("%s:%d", info.Addresses.Boards[board.Name], info.Ports.TcpServer))
235233
}
236234

237235
// Start handling TCP server connections

backend/pkg/transport/network/tcp/client.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ package tcp
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67
"net"
8+
"syscall"
79
"time"
810

911
"github.com/HyperloopUPV-H8/h9-backend/pkg/abstraction"
@@ -64,7 +66,7 @@ func NewClient(local net.Addr) ClientConfig {
6466

6567
Context: context.TODO(),
6668

67-
MaxRetries: 30,
69+
MaxRetries: -1,
6870
Backoff: NewExponBackoff(defaultBackoffMin, defaultBackoffExp, defaultBackoffMax),
6971
}
7072
}
@@ -82,7 +84,7 @@ func (config ClientConfig) Dial(network, remote string) (net.Conn, error) {
8284
return nil, config.Context.Err()
8385
}
8486

85-
if netErr, ok := err.(net.Error); !ok || !netErr.Timeout() {
87+
if netErr, ok := err.(net.Error); !errors.Is(err, syscall.ECONNREFUSED) && (!ok || !netErr.Timeout()) {
8688
return nil, err
8789
}
8890
time.Sleep(config.Backoff(config.CurrentRetries))

common-front/lib/store/connectionsStore.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ export const useConnectionsStore = create<ConnectionsStore>((set) => ({
4545
setConnections: (connections: Connection[]) => {
4646
set(state => ({
4747
...state,
48-
boards: connections
48+
connections: {
49+
...state.connections,
50+
boards: connections
51+
}
4952
}))
5053
}
5154
}))

0 commit comments

Comments
 (0)