Skip to content

Commit b99d3e2

Browse files
committed
Fix pre-release bugs found (#732)
* Fix pre-release bugs found Fix com ports not saving to local storage Add progress bar text to params page Add button to fetch params if failed Fixed radio calibration page hiding if no rc data Fix dashboard mission loading notification not being hidden Try forcing mavlink 2 Fix params controller thread not ending Fix backend crashing if aircraft is using mavlink1 Fix get all params thread timing out too soon * Address copilot review comments * Try fix clock not updating
1 parent 4b41af5 commit b99d3e2

19 files changed

Lines changed: 120 additions & 49 deletions

File tree

gcs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"name": "Avis-Drone-Labs"
77
},
88
"private": true,
9-
"version": "0.1.10-alpha-dev2",
9+
"version": "0.2.0-alpha",
1010
"license": "GPL-3.0-only",
1111
"homepage": "https://fgcs.projectfalcon.uk",
1212
"githubLink": "https://github.com/Avis-Drone-Labs/FGCS",

gcs/src/components/config/radioCalibration.jsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ import apmParamDefsPlane from "../../../data/gen_apm_params_def_plane.json"
1818

1919
// Redux
2020
import { useDispatch, useSelector } from "react-redux"
21-
import {
22-
emitSetState,
23-
selectConnectedToDrone,
24-
} from "../../redux/slices/droneConnectionSlice"
25-
import { selectAircraftType } from "../../redux/slices/droneInfoSlice"
2621
import {
2722
emitGetRcConfig,
2823
selectRadioChannels,
2924
selectRadioChannelsConfig,
3025
} from "../../redux/slices/configSlice"
26+
import {
27+
emitSetState,
28+
selectConnectedToDrone,
29+
} from "../../redux/slices/droneConnectionSlice"
30+
import { selectAircraftType } from "../../redux/slices/droneInfoSlice"
3131

3232
// Tailwind
3333
const tailwindColors = resolveConfig(tailwindConfig).theme.colors

gcs/src/components/dashboard/preFlightChecklist/checkListArea.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import { ActionIcon, Button, Checkbox, Modal, Tooltip } from "@mantine/core"
1212
import EditCheckList from "./checkListEdit.jsx"
1313

1414
// Styling imports
15+
import { IconCheckbox, IconEdit, IconTrashX } from "@tabler/icons-react"
1516
import resolveConfig from "tailwindcss/resolveConfig"
1617
import tailwindConfig from "../../../../tailwind.config.js"
17-
import { IconCheckbox, IconEdit, IconTrashX } from "@tabler/icons-react"
1818
const tailwindColors = resolveConfig(tailwindConfig).theme.colors
1919

2020
export default function CheckListArea({
@@ -51,7 +51,6 @@ export default function CheckListArea({
5151

5252
function generateCheckboxList(defaultCheck = false) {
5353
// Go from string to list, does not return
54-
console.log(checkBoxListString)
5554
var final = []
5655
checkBoxListString
5756
.split("<li><p>")

gcs/src/components/dashboard/statusBar.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export default function StatusBar(props) {
4848
// Start clock
4949
useEffect(() => {
5050
updateClock.start()
51-
return updateClock.stop
51+
return () => updateClock.stop()
5252
}, [])
5353

5454
// Alerts

gcs/src/components/navbar.jsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ export default function Navbar() {
143143
AddCommand("disconnect_from_drone", disconnect)
144144
}, [])
145145

146+
useEffect(() => {
147+
if (!comPorts.includes(selectedComPort)) {
148+
dispatch(setSelectedComPorts(null))
149+
}
150+
}, [comPorts, selectedComPort])
151+
146152
const linkClassName =
147153
"text-md px-2 rounded-sm outline-none focus:text-falconred-400 hover:text-falconred-400 transition-colors delay-50"
148154

gcs/src/components/spotlight/commandHandler.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
*/
55

66
// 3rd Party Imports
7+
import { useHotkeys } from "@mantine/hooks"
8+
import { useEffect, useState } from "react"
79
import { useNavigate } from "react-router"
810
import { useSettings } from "../../helpers/settings"
9-
import { useState, useEffect } from "react"
10-
import { useHotkeys } from "@mantine/hooks"
1111

1212
let commands = []
1313

@@ -73,7 +73,7 @@ export function AddCommand(id, command, shortcut = null, macShortcut = null) {
7373
macShortcut: macShortcut,
7474
})
7575
} else {
76-
console.log(`Attempting to add command that already exists: ${id}`)
76+
console.error(`Attempting to add command that already exists: ${id}`)
7777
}
7878
}
7979

@@ -84,12 +84,6 @@ export function RunCommand(id) {
8484
if (cmd !== undefined) {
8585
cmd.command()
8686
} else {
87-
console.log(`Couldn't find command ${id} to run`)
88-
}
89-
90-
try {
91-
commands.find((entry) => entry.id == id).command()
92-
} catch {
93-
console.log(`Couldn't find command, ${id}, to run`)
87+
console.error(`Couldn't find command ${id} to run`)
9488
}
9589
}

gcs/src/params.jsx

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import { useEffect } from "react"
99

1010
// 3rd Party Imports
11-
import { Progress } from "@mantine/core"
11+
import { Button, Progress } from "@mantine/core"
1212
import { useDebouncedValue } from "@mantine/hooks"
1313
import AutoSizer from "react-virtualized-auto-sizer"
1414
import { FixedSizeList } from "react-window"
@@ -58,16 +58,20 @@ export default function Params() {
5858
const fetchingVars = useSelector(selectFetchingVars)
5959
const fetchingVarsProgress = useSelector(selectFetchingVarsProgress)
6060

61+
function fetchParams() {
62+
dispatch(setFetchingVars(true))
63+
dispatch(emitRefreshParams())
64+
dispatch(setHasFetchedOnce(true))
65+
}
66+
6167
// Reset state if we loose connection
6268
useEffect(() => {
6369
if (!connected) {
6470
dispatch(resetParamState())
6571
}
6672

6773
if (connected && !hasFetchedOnce && !fetchingVars) {
68-
dispatch(setFetchingVars(true))
69-
dispatch(emitRefreshParams())
70-
dispatch(setHasFetchedOnce(true))
74+
fetchParams()
7175
}
7276
}, [connected])
7377

@@ -92,11 +96,18 @@ export default function Params() {
9296
{connected ? (
9397
<>
9498
{fetchingVars && (
95-
<Progress
96-
radius="xs"
97-
value={fetchingVarsProgress}
98-
className="w-1/3 mx-auto my-auto"
99-
/>
99+
<div className="my-auto">
100+
{fetchingVarsProgress.param_id && (
101+
<p className="text-center my-4">
102+
Fetched {fetchingVarsProgress.param_id}
103+
</p>
104+
)}
105+
<Progress
106+
radius="xs"
107+
value={fetchingVarsProgress.progress}
108+
className="w-1/3 mx-auto my-auto"
109+
/>
110+
</div>
100111
)}
101112

102113
{Object.keys(params).length > 0 && !fetchingVars && (
@@ -119,6 +130,14 @@ export default function Params() {
119130
</div>
120131
</div>
121132
)}
133+
{Object.keys(params).length === 0 && !fetchingVars && (
134+
<div className="flex flex-col my-auto mx-auto">
135+
<p className="text-center my-4">
136+
No parameters found, try fetching them again.
137+
</p>
138+
<Button onClick={() => fetchParams()}>Fetch Params</Button>
139+
</div>
140+
)}
122141
</>
123142
) : (
124143
<NoDroneConnected tab="params" />

gcs/src/redux/middleware/socketMiddleware.js

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ import {
6464
} from "../slices/droneInfoSlice"
6565
import {
6666
addIdToItem,
67+
closeDashboardMissionFetchingNotificationNoSuccessThunk,
6768
closeDashboardMissionFetchingNotificationThunk,
6869
setCurrentMission,
6970
setCurrentMissionItems,
@@ -151,7 +152,8 @@ const socketMiddleware = (store) => {
151152

152153
function handleRcChannels(msg) {
153154
let chans = {}
154-
for (let i = 1; i < msg.chancount + 1; i++) {
155+
const chanCount = msg.chancount || 16 // default to 16 channels if chancount is 0
156+
for (let i = 1; i < chanCount + 1; i++) {
155157
chans[i] = msg[`chan${i}_raw`]
156158
}
157159

@@ -249,6 +251,9 @@ const socketMiddleware = (store) => {
249251
store.dispatch(setConnected(false))
250252
store.dispatch(setConnecting(false))
251253
store.dispatch(emitGetComPorts())
254+
store.dispatch(
255+
closeDashboardMissionFetchingNotificationNoSuccessThunk(),
256+
)
252257
}
253258
})
254259

@@ -261,10 +266,13 @@ const socketMiddleware = (store) => {
261266
port.toLowerCase().includes("mavlink") ||
262267
port.toLowerCase().includes("ardupilot"),
263268
)
264-
if (possibleComPort !== undefined) {
265-
store.dispatch(setSelectedComPorts(possibleComPort))
266-
} else if (msg.length > 0) {
267-
store.dispatch(setSelectedComPorts(msg[0]))
269+
if (!store.getState().droneConnection.selected_com_ports) {
270+
// If no com port is selected, select a possible mavlink/ardupilot port if it exists, otherwise select the first port
271+
if (possibleComPort !== undefined) {
272+
store.dispatch(setSelectedComPorts(possibleComPort))
273+
} else if (msg.length > 0) {
274+
store.dispatch(setSelectedComPorts(msg[0]))
275+
}
268276
}
269277
})
270278

@@ -275,7 +283,7 @@ const socketMiddleware = (store) => {
275283

276284
// Flags an error with the com port
277285
socket.socket.on("connection_error", (msg) => {
278-
console.log("Connection error: " + msg.message)
286+
console.error("Connection error: " + msg.message)
279287
showErrorNotification(msg.message)
280288
store.dispatch(setConnecting(false))
281289
store.dispatch(setConnected(false))
@@ -366,17 +374,19 @@ const socketMiddleware = (store) => {
366374
store.dispatch(setParams(msg))
367375
store.dispatch(setShownParams(msg))
368376
store.dispatch(setFetchingVars(false))
369-
store.dispatch(setFetchingVarsProgress(0))
377+
store.dispatch(setFetchingVarsProgress({ progress: 0, param_id: "" }))
370378
store.dispatch(setParamSearchValue(""))
371379
})
372380

373381
socket.socket.on(
374382
ParamSpecificSocketEvents.onParamRequestUpdate,
375383
(msg) => {
376384
store.dispatch(
377-
setFetchingVarsProgress(
378-
(msg.current_param_index / msg.total_number_of_params) * 100,
379-
),
385+
setFetchingVarsProgress({
386+
progress:
387+
(msg.current_param_index / msg.total_number_of_params) * 100,
388+
param_id: msg.current_param_id,
389+
}),
380390
)
381391
},
382392
)

gcs/src/redux/slices/missionSlice.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,18 @@ export const closeDashboardMissionFetchingNotificationThunk =
530530
}
531531
dispatch(setDashboardMissionFetchingNotificationId(null))
532532
}
533+
export const closeDashboardMissionFetchingNotificationNoSuccessThunk =
534+
() => (dispatch, getState) => {
535+
const { dashboardMissionFetchingNotificationId } = getState().missionInfo
536+
if (dashboardMissionFetchingNotificationId) {
537+
closeLoadingNotification(
538+
dashboardMissionFetchingNotificationId,
539+
"",
540+
"",
541+
)
542+
}
543+
dispatch(setDashboardMissionFetchingNotificationId(null))
544+
}
533545

534546
export const getFrameKey = (frame) =>
535547
parseInt(

gcs/src/redux/slices/paramsSlice.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const paramsSlice = createSlice({
1010
modifiedParams: [],
1111
showModifiedParams: false,
1212
fetchingVars: false,
13-
fetchingVarsProgress: 0,
13+
fetchingVarsProgress: { progress: 0, param_id: "" },
1414
searchValue: "",
1515
hasFetchedOnce: false,
1616
},
@@ -86,7 +86,7 @@ const paramsSlice = createSlice({
8686
},
8787
resetParamState: (state) => {
8888
state.fetchingVars = false
89-
state.fetchingVarsProgress = 0
89+
state.fetchingVarsProgress = { progress: 0, param_id: "" }
9090
state.params = []
9191
state.shownParams = []
9292
state.modifiedParams = []

0 commit comments

Comments
 (0)