Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 6 additions & 6 deletions native/waze-on-cluster/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# make test host build + NAL, RTP, the SPS fields, the decoder
# against a fake MSDK, receive queue and catch-up, stream health,
# keyframe wait, the turn-box setting, the map's saved settings,
# the local conf and opt-in settings, the map feed
# the opt-in settings, the map feed
# against the shared renderer, the kit's tests, patcher,
# the aapd locator on every build in AAPD_BIN and
# AAPD_BINS, patchd patch/install activation/DLT/restart/driver profiles, the CarPlay
Expand Down Expand Up @@ -52,7 +52,7 @@ VERSION := $(shell sed -n 's/^ *"version": *"\([^"]*\)".*/\1/p' component.json)
# The capture, decode and map feed (own files), the kit's atlas, packing and
# geometry, and the shared renderer's client.
WOC_SRC = src/main.cpp src/refused.cpp src/video_producer.cpp src/freeze_watch.cpp src/alt_screen.cpp src/map_feed.cpp src/map_feeds.cpp src/atlas_scale.cpp src/control.cpp src/h264_source.cpp \
src/guide_setting.cpp src/map_state.cpp src/local_conf.cpp \
src/guide_setting.cpp src/map_state.cpp src/opt_in.cpp \
src/udp_source.cpp src/avb_source.cpp src/framing_probe.cpp src/rtp_h264.cpp src/sps_info.cpp \
src/decoder_msdk.cpp src/nal_reader.cpp src/stream_health.cpp $(KIT)/map_geometry.cpp $(KIT)/yuv_atlas.cpp \
$(KIT)/block_pack.cpp
Expand All @@ -66,7 +66,7 @@ CPP_TESTS = $(BUILD)/host/nal_reader_test $(BUILD)/host/rtp_h264_test $(BUILD)/h
$(BUILD)/host/alt_screen_test $(BUILD)/host/packet_queue_test \
$(BUILD)/host/stream_health_test $(BUILD)/host/source_crop_test \
$(BUILD)/host/map_rect_test $(BUILD)/host/guide_setting_test $(BUILD)/host/decoder_test \
$(BUILD)/host/map_state_test $(BUILD)/host/local_conf_test $(BUILD)/host/atlas_scale_test $(BUILD)/host/sps_info_test \
$(BUILD)/host/map_state_test $(BUILD)/host/opt_in_test $(BUILD)/host/atlas_scale_test $(BUILD)/host/sps_info_test \
$(BUILD)/host/picture_pace_test
# The control socket (accept4) and the producer (pipe2) are Linux's: built and run on Linux only
# (make test-x86).
Expand Down Expand Up @@ -131,7 +131,7 @@ test-cpp: $(CPP_TESTS)
$(BUILD)/host/guide_setting_test
$(BUILD)/host/decoder_test
$(BUILD)/host/map_state_test
$(BUILD)/host/local_conf_test
$(BUILD)/host/opt_in_test
$(BUILD)/host/atlas_scale_test
$(BUILD)/host/sps_info_test
$(if $(LINUX_TESTS),$(foreach t,$(LINUX_TESTS),$(t) &&) true,@echo 'refused_test, video_producer_test: Linux only (make test-x86)')
Expand Down Expand Up @@ -256,9 +256,9 @@ $(BUILD)/host/map_state_test: test/map_state_test.cpp src/map_state.cpp src/map_
mkdir -p $(@D)
$(CXX) $(CXXFLAGS) -Isrc -I$(CR)/src -o $@ test/map_state_test.cpp src/map_state.cpp $(CR)/src/config.cpp $(CR)/src/log.cpp -lpthread

$(BUILD)/host/local_conf_test: test/local_conf_test.cpp src/local_conf.cpp src/local_conf.h $(CR)/src/config.cpp $(CR)/src/log.cpp
$(BUILD)/host/opt_in_test: test/opt_in_test.cpp src/opt_in.cpp src/opt_in.h $(CR)/src/config.cpp $(CR)/src/log.cpp
mkdir -p $(@D)
$(CXX) $(CXXFLAGS) -Isrc -I$(CR)/src -o $@ test/local_conf_test.cpp src/local_conf.cpp $(CR)/src/config.cpp $(CR)/src/log.cpp -lpthread
$(CXX) $(CXXFLAGS) -Isrc -I$(CR)/src -o $@ test/opt_in_test.cpp src/opt_in.cpp $(CR)/src/config.cpp $(CR)/src/log.cpp -lpthread

# ---- target binary (in Docker) --------------------------------------------
target:
Expand Down
25 changes: 13 additions & 12 deletions native/waze-on-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,6 @@ unless **Keep HUD map over BMW's pop-ups** is ticked. **Own settings for
this driver** gives the driver profile in use its own copy of these
settings.

From a shell, `waze-on-cluster -c <conf> run map|panel` sets the cluster
target until the service restarts and prints the status.

**Inside another app's scene.** An app that shows a scene file on a target
with `layers` 1 can host the map there (cluster-render PROTOCOL.md
"Hosting another target"): the map is then drawn only in the rect it
Expand All @@ -122,12 +119,16 @@ hosted_vpp_scale and always_packed" below).

### Settings

Settings are in `waze-on-cluster.conf` (documented inline). Overrides go in
`/var/opt/waze-on-cluster/waze-on-cluster.local.conf`, which updates keep;
the app's map settings are in `/var/opt/waze-on-cluster/map.state.conf`, and
the opt-in settings in `/var/opt/waze-on-cluster/features.conf`. A key the
local conf has that this version does not know is left out with a warning
in the log.
Settings are in `waze-on-cluster.conf` (documented inline), which each
install writes anew. Besides it and the command line (the Android Auto
crop, PATCH.md), the service reads only the app's saved choices
(`/var/opt/waze-on-cluster/map.state.conf` and the turn-box setting) and
the opt-in settings in `/var/opt/waze-on-cluster/features.conf`. On the
cluster the map goes on its map slot, or into a hosting app's scene.

`/var/opt/waze-on-cluster/waze-on-cluster.local.conf`, which versions up to
0.10.9 read, is not read; it stays on the unit for a downgrade, and the log
names it at each start.

### Map size and upload

Expand All @@ -140,7 +141,7 @@ The map covers the cluster's central map area, 1088x480 on the 1920x720
panel. The patch advertises exactly that, so `tex_size` must equal it.
`src_crop` takes part of a picture of one size and scales it to `tex_size`
(Android Auto's 1280x720 stream has its map in the top 1280x564).
`map_rect` draws the map stretched into a rect of the current target.
`map_rect` draws the map stretched into a rect of the map slot.
`target_fps` (30) caps the frame rate; `picture_fps` (0: every frame) makes
at most that many pictures a second, which saves CPU when the phone sends
more than the cluster takes (set it to `target_fps` then).
Expand Down Expand Up @@ -172,8 +173,8 @@ They take effect when waze-on-cluster next starts (the next head-unit
start). A restart of the service applies them at once, but the map stays
blank until the phone connects again.

Not in `waze-on-cluster.local.conf`: there they are left out, and patchd
moves them to `features.conf`.
patchd moves any it finds in `waze-on-cluster.local.conf` to
`features.conf`, so a downgrade never meets them there.

**What they need.**
- Both: a waze-on-cluster whose `waze-on-cluster.conf` has the key. An older
Expand Down
10 changes: 6 additions & 4 deletions native/waze-on-cluster/patch/patchd.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ var REBOOT_CMD = (process.env.WOC_REBOOT_CMD || '/usr/bin/nsm_control --requestR
var REBOOT_CMD_TIMEOUT_MS = 30000;
/* A restart NSM took that has not taken the unit down by then failed. */
var REBOOT_WAIT_MS = parseInt(process.env.WOC_REBOOT_WAIT_MS, 10) || 180000;
/* The unit's own render settings, which updates keep. */
/* The local conf waze-on-cluster up to 0.10.9 reads over its configuration;
* later versions do not read it. It stays on the unit for a downgrade, kept
* one every release starts with (moveMapSettings, moveFeatures). */
var LOCAL_CONF = process.env.WOC_LOCAL_CONF || '/var/opt/waze-on-cluster/waze-on-cluster.local.conf';
/* Where the map shows and the HUD map's size, place and whether it stays
* shown over BMW's pop-ups, as the app chose them: the render reads this file (its map_state_file) over its
Expand All @@ -244,7 +246,7 @@ var MAP_STATE = path.join(STATE_DIR, 'map.state.conf');
var MAP_KEYS = ['cluster', 'hud', 'hud_width_pct', 'hud_offset_x', 'hud_offset_y', 'hud_keep_shown'];
/* The opt-in settings: the render reads this file (its features_file) over
* its configuration. Not in LOCAL_CONF, which every release up to 0.10.7
* refuses to start with any of FEATURE_KEYS in; no release before this one
* refuses to start with any of FEATURE_KEYS in; no release before 0.10.9
* reads FEATURES. */
var FEATURES = path.join(STATE_DIR, 'features.conf');
var FEATURE_KEYS = ['hosted_vpp_scale', 'always_packed'];
Expand Down Expand Up @@ -1622,8 +1624,8 @@ function aaRevert(noRestart, dropBackup, done) {
function saveFile(f, text) {
try { fs.mkdirSync(STATE_DIR, 0o755); } catch (e) { if (e.code !== 'EEXIST') throw e; }
var fd = fs.openSync(f + '.tmp', 'w', 0o644);
/* The capture (hmi_5000) reads waze-on-cluster.local.conf and the map
* settings, whatever umask the caller (an install hook) has. */
/* The render (hmi_5000) reads the map settings, and an earlier version
* the local conf, whatever umask the caller (an install hook) has. */
try { fs.fchmodSync(fd, 0o644); fs.writeSync(fd, text); fs.fsyncSync(fd); } finally { fs.closeSync(fd); }
fs.renameSync(f + '.tmp', f);
}
Expand Down
56 changes: 47 additions & 9 deletions native/waze-on-cluster/patch/test/rollback_conf_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (C) 2026 Robert Nisipeanu
/* Every released waze-on-cluster against the settings files this version
* leaves: with the opt-in keys (hosted_vpp_scale, always_packed) turned on,
* waze-on-cluster.local.conf stays one each release starts with, through
* an install or update (patchd activate), a head-unit start (patchd's
* daemon), Undo update, Remove and removal (patchd deactivate), a reinstall,
* an update cut short or undone, and a move cut short between its two
* writes; a removal is refused while the local conf cannot be rewritten;
* and every release whose code reads features.conf, where the keys live,
* knows them.
* leaves. This version does not read waze-on-cluster.local.conf; earlier
* ones do, so it stays on the unit, one each release starts with: with the
* opt-in keys (hosted_vpp_scale, always_packed) turned on, and on a car whose
* local conf has the owner's settings, the app's map settings and the opt-in
* keys, through an install or update (patchd activate), a head-unit start
* (patchd's daemon), a downgrade (Undo update), Remove and uninstall (patchd
* deactivate), a reinstall, an update cut short or undone, and a move cut
* short between its two writes; a removal is refused while the local conf
* cannot be rewritten; a unit without a local conf is left without one; and
* every release whose code reads features.conf, where the keys live, knows
* them.
*
* A release loads its shipped waze-on-cluster.conf first and refuses to
* start with a key it does not know, so a key that file sets is one the
Expand Down Expand Up @@ -53,7 +56,8 @@ if (!list.length) {
list = tags() || [];
}
var RELEASES = list.map(function (t) { return t.slice('waze-on-cluster@'.length); }).filter(function (v) { return /^\d+\.\d+\.\d+$/.test(v); }).sort(cmp);
ok('every release from 0.5.0 to 0.10.7 is at hand', RELEASES.indexOf('0.5.0') >= 0 && RELEASES.indexOf('0.10.7') >= 0, RELEASES.join(' '));
ok('every release from 0.5.0 to 0.10.9 is at hand', ['0.5.0', '0.10.7', '0.10.8', '0.10.9'].every(function (v) { return RELEASES.indexOf(v) >= 0; }),
RELEASES.join(' '));
if (!RELEASES.length) process.exit(1);

/* A conf's lines as Config::load reads them: [key, value] or [null, line]
Expand Down Expand Up @@ -117,6 +121,7 @@ process.on('exit', function () {
try { cp.execFileSync('rm', ['-rf', dir]); } catch (e) {}
});
var STATE = path.join(dir, 'state'), LOCAL = path.join(STATE, 'waze-on-cluster.local.conf'), FEATURES = path.join(STATE, 'features.conf');
var MAP_STATE = path.join(STATE, 'map.state.conf');
var SOCK = path.join(dir, 'shm', 'patch.sock');
fs.mkdirSync(STATE);
var ENV = Object.assign({}, process.env, {
Expand Down Expand Up @@ -248,6 +253,39 @@ var ON = 'hosted_vpp_scale = 1\nalways_packed = 1\n';
check('the move cut short between its writes', USER, null, out);
fs.rmdirSync(FEATURES + '.tmp');

/* 5. A car with a local conf: the owner's settings (a target, a frame
* rate), the app's map settings and an opt-in key, which releases up to
* 0.8.8 and 0.10.7 refuse. The first install moves those two into their
* files; the owner's lines stay in the local conf, which every release
* starts with, through every step after. */
var OWN = '# mine\ntarget = panel\ntarget_fps = 20\n';
var CAR_LOCAL = OWN + 'cluster = 0\nhud_width_pct = 50\nhosted_vpp_scale = 1\n';
var CAR_MAP = 'cluster = 0\nhud_width_pct = 50\n', CAR_FEAT = 'hosted_vpp_scale = 1\n';
ok('every release starts with the owner\'s settings', refusing(OWN).length === 0, refusing(OWN).join(' '));
ok('releases refuse the car\'s local conf as it was', refusing(CAR_LOCAL).length > 0);
var life = [['an update to this version', 'activate'], ['a head-unit start', 'boot'], ['a downgrade', 'deactivate'],
['an update to this version again', 'activate'], ['a head-unit start', 'boot'], ['Remove', 'deactivate'],
['a reinstall', 'activate'], ['a head-unit start', 'boot'], ['uninstall', 'deactivate'], ['a reinstall', 'activate']];
async function step(which) { return which === 'boot' ? boot() : hook(which); }
set(CAR_LOCAL, null);
try { fs.unlinkSync(MAP_STATE); } catch (e) {}
for (i = 0; i < life.length; i++) {
out = await step(life[i][1]);
var map = read(MAP_STATE);
check('a car with a local conf, ' + life[i][0], OWN, CAR_FEAT, out);
ok('a car with a local conf, ' + life[i][0] + ': the app\'s map settings in map.state.conf', map === CAR_MAP,
JSON.stringify(map));
}

/* 6. No local conf (every Store install): none made, nor any other
* settings file, through every step. */
[LOCAL, FEATURES, MAP_STATE].forEach(function (f) { try { fs.unlinkSync(f); } catch (e) {} });
for (i = 0; i < life.length; i++) {
out = await step(life[i][1]);
ok('no local conf, ' + life[i][0] + ': none made, no settings file', read(LOCAL) === null && read(FEATURES) === null &&
read(MAP_STATE) === null, out.slice(-300));
}

process.stdout.write(fails ? ('\n' + fails + ' check(s) failed\n') : '\nall checks passed\n');
process.exit(fails ? 1 : 0);
})().catch(function (e) { process.stdout.write('FAIL ' + (e.stack || e) + '\n'); process.exit(1); });
7 changes: 3 additions & 4 deletions native/waze-on-cluster/src/control.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (C) 2026 Robert Nisipeanu
/* The control socket: newline-delimited JSON between its owner (the app, or
* `waze-on-cluster run`) and the tool (README.md "Using it").
/* The control socket: newline-delimited JSON between its owner (the app)
* and the tool (README.md "Using it").
*
* owner -> tool {"cmd":"start","target":"sail"|"map"|"panel"}
* {"cmd":"cluster","on":"0"|"1"} the map on the cluster off or on
* owner -> tool {"cmd":"cluster","on":"0"|"1"} the map on the cluster off or on
* {"cmd":"hud","on":"0"|"1"} the map on the HUD off or on
* {"cmd":"hud","hud_width_pct":"0"|"20".."100"} the HUD map's size
* {"cmd":"hud","hud_x":"-800".."800","hud_y":...} where it is, from the centre
Expand Down
39 changes: 0 additions & 39 deletions native/waze-on-cluster/src/local_conf.h

This file was deleted.

Loading