diff --git a/cereal/log.capnp b/cereal/log.capnp index d12cd6cdc831ae..e4c93739b9828d 100644 --- a/cereal/log.capnp +++ b/cereal/log.capnp @@ -2428,6 +2428,10 @@ struct AudioFeedback { blockNum @1 :UInt16; } +struct SoundRequest { + sound @0 :Car.CarControl.HUDControl.AudibleAlert; +} + struct Touch { sec @0 :Int64; usec @1 :Int64; @@ -2537,6 +2541,8 @@ struct Event { livestreamWideRoadEncodeData @121 :EncodeData; livestreamDriverEncodeData @122 :EncodeData; + soundRequest @152 :SoundRequest; + # *********** Custom: reserved for forks *********** # DO change the name of the field diff --git a/cereal/services.py b/cereal/services.py index c2d38d852db133..623bc55d4cc8db 100755 --- a/cereal/services.py +++ b/cereal/services.py @@ -77,6 +77,7 @@ def __init__(self, should_log: bool, frequency: float, decimation: Optional[int] "rawAudioData": (False, 20.), "bookmarkButton": (True, 0., 1), "audioFeedback": (True, 0., 1), + "soundRequest": (False, 0.), "roadEncodeData": (False, 20., None, QueueSize.BIG), "driverEncodeData": (False, 20., None, QueueSize.BIG), "wideRoadEncodeData": (False, 20., None, QueueSize.BIG), diff --git a/selfdrive/ui/soundd.py b/selfdrive/ui/soundd.py index 8225efabf9af5a..69cbd337380064 100644 --- a/selfdrive/ui/soundd.py +++ b/selfdrive/ui/soundd.py @@ -128,7 +128,9 @@ def update_alert(self, new_alert): self.current_sound_frame = 0 def get_audible_alert(self, sm): - if sm.updated['selfdriveState']: + if sm.updated['soundRequest'] and sm['soundRequest'].sound.raw != AudibleAlert.none: + self.update_alert(sm['soundRequest'].sound.raw) + elif sm.updated['selfdriveState']: new_alert = sm['selfdriveState'].alertSound.raw self.update_alert(new_alert) elif check_selfdrive_timeout_alert(sm): @@ -153,7 +155,7 @@ def soundd_thread(self): # sounddevice must be imported after forking processes import sounddevice as sd - sm = messaging.SubMaster(['selfdriveState', 'soundPressure']) + sm = messaging.SubMaster(['selfdriveState', 'soundPressure', 'soundRequest']) with self.get_stream(sd) as stream: rk = Ratekeeper(20) diff --git a/system/athena/athenad.py b/system/athena/athenad.py index 6bccaae63eb424..de17607d88bb72 100755 --- a/system/athena/athenad.py +++ b/system/athena/athenad.py @@ -578,7 +578,7 @@ def startStream(sdp: str) -> dict: if cp_bytes is not None: with car.CarParams.from_bytes(cp_bytes) as CP: if CP.notCar: - bridge_services_in.append("testJoystick") + bridge_services_in += ["testJoystick", "soundRequest"] body = StreamRequestBody(sdp, "wideRoad", bridge_services_in, ["carState"]) try: