Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
05081aa
Fix apt gpg key install
XECDesign Feb 8, 2023
b48040b
Merge branch 'master' into arm64
XECDesign Feb 9, 2023
5d2c6f3
export-image: change boot partition lable to 'bootfs'
XECDesign Feb 14, 2023
04d0dcb
Merge branch 'master' into arm64
XECDesign Feb 14, 2023
f2d3855
Update release notes
XECDesign Feb 14, 2023
25e2319
Merge branch 'master' into arm64
XECDesign Feb 14, 2023
60c9ba3
Re-enable wolfram-engine on arm64
XECDesign Mar 9, 2023
cf40e4b
Check that docker is not set up in rootless mode (#679)
stefanb2 Mar 27, 2023
0db41e3
Ensure that deploy is always owned by user (#680)
stefanb2 Mar 27, 2023
a2afdf7
Merge branch 'master' into arm64
XECDesign Mar 27, 2023
3e8046d
Update qemu ARM binary name in README.md (#684)
stefanb2 Mar 27, 2023
b8437a7
DRY removal for docker run command line (#686)
stefanb2 Mar 28, 2023
84746b2
Merge branch 'master' into arm64
XECDesign Mar 28, 2023
4e92753
Use tmpfs for chroot /run and /tmp
XECDesign Mar 29, 2023
0defafe
Merge branch 'master' into arm64
XECDesign Mar 29, 2023
6dc45a8
Register binfmt_misc entry for docker build (#685)
moh53n Apr 3, 2023
9249e14
Copy container log to deploy (#688)
stefanb2 Apr 3, 2023
47eee1f
Update release notes
XECDesign Apr 25, 2023
c16e6b7
Merge branch 'master' into arm64
XECDesign Apr 25, 2023
7c75094
Update chromium install
XECDesign Dec 2, 2021
01d24ef
Skip binfmt_misc register when unnecessary (#693)
stefanb2 May 9, 2023
a86d732
Register aarch64 in binfmt misc (#694)
stefanb2 May 9, 2023
446f3e3
Adds call to mknod if loop dev does not exist after call to `losetup …
bamartin125 Aug 17, 2023
e484aa8
Merge branch 'master' into arm64
XECDesign Aug 17, 2023
77706bd
fix: support bash v3 by removing array usage (#705)
reubenmiller Sep 25, 2023
ed68013
fix: support bash v3 by removing array usage (#705)
reubenmiller Sep 25, 2023
6aca615
Switch to Bookworm
XECDesign Sep 7, 2023
9d9d063
Remove/replace obsolete packages
XECDesign Sep 7, 2023
a524fe4
stage3: replace qpdfview with evince
XECDesign Sep 7, 2023
43c49d8
stage3: install eom
XECDesign Sep 7, 2023
9fc1385
stage3: install Firefox
XECDesign Sep 7, 2023
8dd23cb
Remove dhcpcd and associated options
XECDesign Sep 7, 2023
4a4a66e
export-image: auto-remove and purge packages on dist-upgrade
XECDesign Sep 7, 2023
88ac523
Enable Wayland by default
XECDesign Sep 7, 2023
c856800
Switch to new kernel and firmware packages
XECDesign Sep 7, 2023
64b498b
Don't generate NOOBS files
XECDesign Sep 7, 2023
188c155
Migrate to raspberrypi.com
XECDesign Sep 8, 2023
e6dd7ca
stage2: remove rng-tools
XECDesign Sep 12, 2023
574d3e7
stage0: only fetch armhf packages from Raspbian
XECDesign Sep 13, 2023
d7dde0c
stage5: disable greenfoot and bluej as they don't seem to work
XECDesign Sep 7, 2023
6051f1d
stage4: remove pimoroni packages for now
XECDesign Sep 13, 2023
3a6342b
stage0: install kernel headers
XECDesign Sep 14, 2023
7ae1a26
stage4: ignore power key and let raspberrypi-ui-mods handle it
XECDesign Sep 14, 2023
c4f98a8
Move picamera2 to stage3 - PyAV takes up too much space for lite images
XECDesign Aug 23, 2023
5b15e14
stage2: install GPIO libraries
XECDesign Sep 25, 2023
dc6a3c1
stage2: install python3-smbus2
XECDesign Sep 26, 2023
a0b8868
Update release notes
XECDesign Sep 27, 2023
c318daf
Merge branch 'master' into arm64
XECDesign Sep 27, 2023
325123f
stage0: add non-free-firmware
XECDesign Sep 25, 2023
5ef8b0d
Remove 32-bit kernels and install 64-bit headers
XECDesign Sep 27, 2023
5f2fe0f
pi5 support
XECDesign Mar 29, 2023
fb56ad5
stage5: match rp-prefapps package list
XECDesign Oct 3, 2023
962bf48
Merge branch 'master' into arm64
XECDesign Oct 4, 2023
663401d
README.md: default release is bookworm (#715)
marcone Oct 16, 2023
0ef867e
Fix build-docker.sh CONTINUE=1 mode (#716)
stefanb2 Oct 17, 2023
78444ea
Merge branch 'master' into arm64
XECDesign Oct 17, 2023
d966897
README.md: add PI_GEN_RELEASE (#720)
stefanb2 Oct 23, 2023
19acff0
Fix typo (#725)
Nov 22, 2023
95c9fa8
stage2: include gpiod binary tools
XECDesign Nov 27, 2023
5b22a55
Update release notes
XECDesign Nov 27, 2023
1460069
Merge branch 'master' into arm64
XECDesign Nov 27, 2023
193bae2
Remove obsolete packages
XECDesign Nov 28, 2023
caf3d86
Merge branch 'master' into arm64
XECDesign Nov 28, 2023
399a5c2
stage2: install python3-venv
XECDesign Nov 29, 2023
ae81834
export-image: Add issue.txt symlink
XECDesign Nov 29, 2023
e07ee9b
Update release notes
XECDesign Nov 29, 2023
0fda322
Merge branch 'master' into arm64
XECDesign Nov 29, 2023
02b371d
stage4: Update beginner's guide URL, assuming the latest version is a…
XECDesign Nov 29, 2023
70cd6f2
Merge branch 'master' into arm64
XECDesign Nov 29, 2023
a1f94ad
Merge tag '2023-12-05-raspios-bookworm-arm64'
PeterJohnson Dec 9, 2023
3c92253
Update for bookworm (WIP)
PeterJohnson Dec 20, 2023
27bc31c
Update to kickoff releases
PeterJohnson Jan 8, 2024
cb31e54
Update to 2024.3.1
PeterJohnson Feb 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG BASE_IMAGE=debian:bullseye
ARG BASE_IMAGE=debian:bookworm
FROM ${BASE_IMAGE}

ENV DEBIAN_FRONTEND noninteractive
Expand All @@ -10,7 +10,7 @@ RUN apt-get -y update && \
libarchive-tools libcap2-bin rsync grep udev xz-utils curl xxd file kmod bc\
binfmt-support ca-certificates qemu-utils kpartx fdisk gpg pigz\
crossbuild-essential-arm64 \
build-essential cmake python3 python3-distutils python3-jinja2 ant sudo openjdk-17-jdk \
build-essential cmake ninja-build protobuf-compiler python3 python3-distutils python3-jinja2 ant sudo openjdk-17-jdk \
&& rm -rf /var/lib/apt/lists/*

COPY . /pi-gen/
Expand Down
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ The following environment variables are supported:
The release version to build images against. Valid values are jessie, stretch
buster, bullseye, and testing.

* `PI_GEN_RELEASE` (Default: `Raspberry Pi reference`)

The release name to use in `/etc/issue.txt`. The default should only be used
for official Raspberry Pi builds.

* `USE_QCOW2` **EXPERIMENTAL** (Default: `0` )

Instead of using traditional way of building the rootfs of every stage in
Expand All @@ -87,7 +92,7 @@ The following environment variables are supported:
that the network block device is not disconnected correctly after the Docker process has
ended abnormally. In that case see [Disconnect an image if something went wrong](#Disconnect-an-image-if-something-went-wrong)

* `RELEASE` (Default: bullseye)
* `RELEASE` (Default: bookworm)

The release version to build images against. Valid values are any supported
Debian release. However, since different releases will have different sets of
Expand Down Expand Up @@ -204,9 +209,9 @@ The following environment variables are supported:
stays activated. `FIRST_USER_PASS` must be set for this to work. Please be aware of the implied
security risk of defining a default username and password for your devices.

* `WPA_ESSID`, `WPA_PASSWORD` and `WPA_COUNTRY` (Default: unset)
* `WPA_COUNTRY` (Default: unset)

If these are set, they are use to configure `wpa_supplicant.conf`, so that the Raspberry Pi can automatically connect to a wireless network on first boot. If `WPA_ESSID` is set and `WPA_PASSWORD` is unset an unprotected wireless network will be configured. If set, `WPA_PASSWORD` must be between 8 and 63 characters. `WPA_COUNTRY` is a 2-letter ISO/IEC 3166 country Code, i.e. `GB`
Sets the default WLAN regulatory domain and unblocks WLAN interfaces. This should be a 2-letter ISO/IEC 3166 country Code, i.e. `GB`

* `ENABLE_SSH` (Default: `1`)

Expand Down Expand Up @@ -527,7 +532,7 @@ To resolve this, ensure that the following files are available (install them if

```
/lib/modules/$(uname -r)/kernel/fs/binfmt_misc.ko
/usr/bin/qemu-arm-static
/usr/bin/qemu-aarch64-static
```

You may also need to load the module by hand - run `modprobe binfmt_misc`.
Expand Down
126 changes: 84 additions & 42 deletions build-docker.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
#!/bin/bash -eu
#!/usr/bin/env bash
# Note: Avoid usage of arrays as MacOS users have an older version of bash (v3.x) which does not supports arrays
set -eu

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
DIR="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd)"

BUILD_OPTS="$*"

DOCKER="docker"
# Allow user to override docker command
DOCKER=${DOCKER:-docker}

if ! ${DOCKER} ps >/dev/null 2>&1; then
DOCKER="sudo docker"
# Ensure that default docker command is not set up in rootless mode
if \
! ${DOCKER} ps >/dev/null 2>&1 || \
${DOCKER} info 2>/dev/null | grep -q rootless \
; then
DOCKER="sudo ${DOCKER}"
fi
if ! ${DOCKER} ps >/dev/null; then
echo "error connecting to docker:"
Expand Down Expand Up @@ -88,49 +95,84 @@ fi
# Modify original build-options to allow config file to be mounted in the docker container
BUILD_OPTS="$(echo "${BUILD_OPTS:-}" | sed -E 's@\-c\s?([^ ]+)@-c /config@')"

${DOCKER} build --build-arg BASE_IMAGE=debian:bullseye -t pi-gen "${DIR}"
${DOCKER} build --build-arg BASE_IMAGE=debian:bookworm -t pi-gen "${DIR}"

if [ "${CONTAINER_EXISTS}" != "" ]; then
trap 'echo "got CTRL+C... please wait 5s" && ${DOCKER} stop -t 5 ${CONTAINER_NAME}_cont' SIGINT SIGTERM
time ${DOCKER} run --rm --privileged \
--cap-add=ALL \
-v /dev:/dev \
-v /lib/modules:/lib/modules \
${PIGEN_DOCKER_OPTS} \
--volume "${CONFIG_FILE}":/config:ro \
-e "GIT_HASH=${GIT_HASH}" \
--volumes-from="${CONTAINER_NAME}" --name "${CONTAINER_NAME}_cont" \
-e IMG_NAME="${IMG_NAME}"\
-e IMG_VERSION="${IMG_VERSION}"\
pi-gen \
bash -e -o pipefail -c "dpkg-reconfigure qemu-user-static &&
# binfmt_misc is sometimes not mounted with debian bullseye image
(mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc || true) &&
cd /pi-gen; ./build.sh ${BUILD_OPTS} &&
rsync -av work/*/build.log deploy/" &
wait "$!"
DOCKER_CMDLINE_NAME="${CONTAINER_NAME}_cont"
DOCKER_CMDLINE_PRE="--rm"
DOCKER_CMDLINE_POST="--volumes-from=${CONTAINER_NAME}"
else
trap 'echo "got CTRL+C... please wait 5s" && ${DOCKER} stop -t 5 ${CONTAINER_NAME}' SIGINT SIGTERM
time ${DOCKER} run --name "${CONTAINER_NAME}" --privileged \
--cap-add=ALL \
-v /dev:/dev \
-v /lib/modules:/lib/modules \
${PIGEN_DOCKER_OPTS} \
--volume "${CONFIG_FILE}":/config:ro \
-e "GIT_HASH=${GIT_HASH}" \
-e IMG_NAME="${IMG_NAME}"\
-e IMG_VERSION="${IMG_VERSION}"\
pi-gen \
bash -e -o pipefail -c "dpkg-reconfigure qemu-user-static &&
# binfmt_misc is sometimes not mounted with debian bullseye image
(mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc || true) &&
cd /pi-gen; ./build.sh ${BUILD_OPTS} &&
rsync -av work/*/build.log deploy/" &
wait "$!"
DOCKER_CMDLINE_NAME="${CONTAINER_NAME}"
DOCKER_CMDLINE_PRE=""
DOCKER_CMDLINE_POST=""
fi

# Check if binfmt_misc is required
binfmt_misc_required=1
case $(uname -m) in
aarch64)
binfmt_misc_required=0
;;
arm*)
binfmt_misc_required=0
;;
esac

# Check if qemu-aarch64-static and /proc/sys/fs/binfmt_misc are present
if [[ "${binfmt_misc_required}" == "1" ]]; then
if ! qemu_arm=$(which qemu-aarch64-static) ; then
echo "qemu-aarch64-static not found (please install qemu-user-static)"
exit 1
fi
if [ ! -f /proc/sys/fs/binfmt_misc/register ]; then
echo "binfmt_misc required but not mounted, trying to mount it..."
if ! mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc ; then
echo "mounting binfmt_misc failed"
exit 1
fi
echo "binfmt_misc mounted"
fi
if ! grep -q "^interpreter ${qemu_arm}" /proc/sys/fs/binfmt_misc/qemu-aarch64* ; then
# Register qemu-aarch64 for binfmt_misc
reg="echo ':qemu-aarch64-rpi:M::"\
"\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00:"\
"\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:"\
"${qemu_arm}:F' > /proc/sys/fs/binfmt_misc/register"
echo "Registering qemu-aarch64 for binfmt_misc..."
sudo bash -c "${reg}" 2>/dev/null || true
fi
fi

trap 'echo "got CTRL+C... please wait 5s" && ${DOCKER} stop -t 5 ${DOCKER_CMDLINE_NAME}' SIGINT SIGTERM
time ${DOCKER} run \
$DOCKER_CMDLINE_PRE \
--name "${DOCKER_CMDLINE_NAME}" \
--privileged \
--cap-add=ALL \
-v /dev:/dev \
-v /lib/modules:/lib/modules \
${PIGEN_DOCKER_OPTS} \
--volume "${CONFIG_FILE}":/config:ro \
-e "GIT_HASH=${GIT_HASH}" \
-e IMG_VERSION="${IMG_VERSION}"\
$DOCKER_CMDLINE_POST \
pi-gen \
bash -e -o pipefail -c "
dpkg-reconfigure qemu-user-static &&
# binfmt_misc is sometimes not mounted with debian bullseye image
(mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc || true) &&
cd /pi-gen; ./build.sh ${BUILD_OPTS} &&
rsync -av work/*/build.log deploy/
" &
wait "$!"

# Ensure that deploy/ is always owned by calling user
echo "copying results from deploy/"
${DOCKER} cp "${CONTAINER_NAME}":/pi-gen/deploy .
${DOCKER} cp "${CONTAINER_NAME}":/pi-gen/deploy - | tar -xf -

echo "copying log from container ${CONTAINER_NAME} to deploy/"
${DOCKER} logs --timestamps "${CONTAINER_NAME}" &>deploy/build-docker.log

ls -lah deploy

# cleanup
Expand Down
5 changes: 2 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ trap term EXIT INT TERM

export PI_GEN=${PI_GEN:-pi-gen}
export PI_GEN_REPO=${PI_GEN_REPO:-https://github.com/RPi-Distro/pi-gen}
export PI_GEN_RELEASE=${PI_GEN_RELEASE:-Raspberry Pi reference}

if [ -z "${IMG_NAME}" ]; then
echo "IMG_NAME not set" 1>&2
Expand Down Expand Up @@ -229,9 +230,7 @@ export TARGET_HOSTNAME=${TARGET_HOSTNAME:-raspberrypi}
export FIRST_USER_NAME=${FIRST_USER_NAME:-pi}
export FIRST_USER_PASS
export DISABLE_FIRST_BOOT_USER_RENAME=${DISABLE_FIRST_BOOT_USER_RENAME:-0}
export RELEASE=${RELEASE:-bullseye} # Don't forget to update stage0/prerun.sh
export WPA_ESSID
export WPA_PASSWORD
export RELEASE=${RELEASE:-bookworm} # Don't forget to update stage0/prerun.sh
export WPA_COUNTRY
export ENABLE_SSH="${ENABLE_SSH:-1}"
export PUBKEY_ONLY_SSH="${PUBKEY_ONLY_SSH:-0}"
Expand Down
1 change: 1 addition & 0 deletions config
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
PI_GEN_RELEASE=WPILibPi
IMG_NAME='WPILibPi_64'
TARGET_HOSTNAME=wpilibpi
FIRST_USER_PASS=raspberry
Expand Down
5 changes: 1 addition & 4 deletions deps/tools/configServer/src/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
#include <string_view>

#include <wpi/Signal.h>

namespace wpi {
class json;
} // namespace wpi
#include <wpi/json_fwd.h>

class UploadHelper;

Expand Down
17 changes: 9 additions & 8 deletions deps/tools/configServer/src/NetworkSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <unistd.h>

#include <bit>
#include <string>
#include <vector>

Expand Down Expand Up @@ -56,8 +57,8 @@ bool NetmaskToCidr(std::string_view netmask, unsigned int* cidr) {
in_addr addr;
if (wpi::uv::NameToAddr(netmask, &addr) != 0) return false;
uint32_t hostAddr = ntohl(addr.s_addr);
auto leadingOnes = wpi::countLeadingOnes(hostAddr);
auto trailingZeros = wpi::countTrailingZeros(hostAddr);
auto leadingOnes = std::countl_one(hostAddr);
auto trailingZeros = std::countr_zero(hostAddr);
if (leadingOnes + trailingZeros != 32) return false;
*cidr = leadingOnes;
return true;
Expand Down Expand Up @@ -123,19 +124,19 @@ static std::string BuildDhcpcdSetting(
break;
case NetworkSettings::kStatic:
fmt::print(os, "interface {}\n", iface);
fmt::print(os, "static ip_address={}/{}\n", addressOut, cidr);
fmt::print(os, "static ip_address={}/{}\n", addressOut.str(), cidr);
if (!gatewayOut.empty())
fmt::print(os, "static routers={}\n", gatewayOut);
fmt::print(os, "static routers={}\n", gatewayOut.str());
if (!dnsOut.empty())
fmt::print(os, "static domain_name_servers={}\n", dnsOut);
fmt::print(os, "static domain_name_servers={}\n", dnsOut.str());
break;
case NetworkSettings::kDhcpStatic:
fmt::print(os, "profile static_{}\n", iface);
fmt::print(os, "static ip_address={}/{}\n", addressOut, cidr);
fmt::print(os, "static ip_address={}/{}\n", addressOut.str(), cidr);
if (!gatewayOut.empty())
fmt::print(os, "static routers={}\n", gatewayOut);
fmt::print(os, "static routers={}\n", gatewayOut.str());
if (!dnsOut.empty())
fmt::print(os, "static domain_name_servers={}\n", dnsOut);
fmt::print(os, "static domain_name_servers={}\n", dnsOut.str());
fmt::print(os, "interface {}\n", iface);
fmt::print(os, "fallback static_{}\n", iface);
break;
Expand Down
5 changes: 1 addition & 4 deletions deps/tools/configServer/src/NetworkSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@
#include <string_view>

#include <wpi/Signal.h>
#include <wpi/json_fwd.h>
#include <wpinet/uv/Loop.h>

namespace wpi {
class json;
} // namespace wpi

class NetworkSettings {
struct private_init {};

Expand Down
8 changes: 5 additions & 3 deletions deps/tools/configServer/src/RomiStatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <string_view>

#include <fmt/format.h>
#include <wpi/MemoryBuffer.h>
#include <wpi/SmallString.h>
#include <wpi/fmt/raw_ostream.h>
#include <wpi/fs.h>
Expand Down Expand Up @@ -237,17 +238,18 @@ wpi::json RomiStatus::ReadRomiConfigFile(
std::function<void(std::string_view)> onFail) {
// Read config file
std::error_code ec;
wpi::raw_fd_istream is(ROMI_JSON, ec);
std::unique_ptr<wpi::MemoryBuffer> fileBuffer =
wpi::MemoryBuffer::GetFile(ROMI_JSON, ec);

if (ec) {
if (fileBuffer == nullptr || ec) {
onFail("Could not read romi config file");
fmt::print(stderr, "could not read {}\n", ROMI_JSON);
return wpi::json();
}

wpi::json j;
try {
j = wpi::json::parse(is);
j = wpi::json::parse(fileBuffer->GetCharBuffer());
} catch(const wpi::json::parse_error& e) {
onFail("Parse error in config file");
fmt::print(stderr, "Parse error in {}: byte {}: {}\n", ROMI_JSON, e.byte,
Expand Down
9 changes: 3 additions & 6 deletions deps/tools/configServer/src/RomiStatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,12 @@

#include <cscore.h>
#include <wpi/Signal.h>
#include <wpi/json_fwd.h>
#include <wpinet/uv/Loop.h>

namespace wpi {
class json;

namespace uv {
namespace wpi::uv {
class Buffer;
} // namespace uv
} // namespace wpi
} // namespace wpi::uv

class RomiStatus {
struct private_init {};
Expand Down
5 changes: 1 addition & 4 deletions deps/tools/configServer/src/SystemStatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@
#include <memory>

#include <wpi/Signal.h>
#include <wpi/json_fwd.h>

#include "DataHistory.h"

namespace wpi {
class json;
} // namespace wpi

class SystemStatus {
struct private_init {};

Expand Down
9 changes: 6 additions & 3 deletions deps/tools/configServer/src/VisionSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "VisionSettings.h"

#include <fmt/format.h>
#include <wpi/MemoryBuffer.h>
#include <wpi/fs.h>
#include <wpi/json.h>
#include <wpi/raw_istream.h>
Expand Down Expand Up @@ -41,15 +42,17 @@ void VisionSettings::UpdateStatus() { status(GetStatusJson()); }

wpi::json VisionSettings::GetStatusJson() {
std::error_code ec;
wpi::raw_fd_istream is(FRC_JSON, ec);
if (ec) {
std::unique_ptr<wpi::MemoryBuffer> fileBuffer =
wpi::MemoryBuffer::GetFile(FRC_JSON, ec);

if (fileBuffer == nullptr || ec) {
fmt::print(stderr, "could not read {}\n", FRC_JSON);
return wpi::json();
}

try {
wpi::json j = {{"type", "visionSettings"},
{"settings", wpi::json::parse(is)}};
{"settings", wpi::json::parse(fileBuffer->GetCharBuffer())}};
return j;
} catch (wpi::json::exception& e) {
fmt::print(stderr, "could not parse {}\n", FRC_JSON);
Expand Down
Loading