Skip to content

Commit

Permalink
Merge branch 'master' into remove-tz-dep
Browse files Browse the repository at this point in the history
  • Loading branch information
BBBmau committed Jun 10, 2024
2 parents 84d218a + e3f18b9 commit 97ac223
Show file tree
Hide file tree
Showing 48 changed files with 112 additions and 549 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/selfdrive_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ env:
jobs:
build_release:
name: build release
runs-on: ubuntu-latest
runs-on: ${{ ((github.repository == 'commaai/openpilot') &&
((github.event_name != 'pull_request') ||
(github.event.pull_request.head.repo.full_name == 'commaai/openpilot'))) && 'namespace-profile-amd64-8x16' || 'ubuntu-latest' }}
env:
STRIPPED_DIR: /tmp/releasepilot
steps:
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
path = opendbc
url = ../../commaai/opendbc.git
[submodule "msgq"]
path = msgq
path = msgq_repo
url = ../../commaai/msgq.git
[submodule "rednose_repo"]
path = rednose_repo
Expand Down
1 change: 1 addition & 0 deletions Dockerfile.openpilot
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ COPY ./release ${OPENPILOT_PATH}/release
COPY ./common ${OPENPILOT_PATH}/common
COPY ./opendbc ${OPENPILOT_PATH}/opendbc
COPY ./cereal ${OPENPILOT_PATH}/cereal
COPY ./msgq_repo ${OPENPILOT_PATH}/msgq_repo
COPY ./msgq ${OPENPILOT_PATH}/msgq
COPY ./panda ${OPENPILOT_PATH}/panda
COPY ./selfdrive ${OPENPILOT_PATH}/selfdrive
Expand Down
4 changes: 4 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Version 0.9.8 (2024-XX-XX)
========================
* Always on driver monitoring toggle

Version 0.9.7 (2024-06-11)
========================
* New driving model
Expand Down
12 changes: 7 additions & 5 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,8 @@ env = Environment(
CFLAGS=["-std=gnu11"] + cflags,
CXXFLAGS=["-std=c++1z"] + cxxflags,
LIBPATH=libpath + [
"#cereal",
"#msgq",
"#msgq_repo",
"#third_party",
"#opendbc/can",
"#selfdrive/pandad",
"#common",
"#rednose/helpers",
Expand Down Expand Up @@ -358,9 +356,13 @@ gpucommon = [_gpucommon]

Export('common', 'gpucommon')

# Build cereal and messaging
SConscript(['msgq/SConscript'])
# Build messaging (cereal + msgq + socketmaster + their dependencies)
SConscript(['msgq_repo/SConscript'])
SConscript(['cereal/SConscript'])
Import('socketmaster', 'msgq')
messaging = [socketmaster, msgq, 'zmq', 'capnp', 'kj',]
Export('messaging')


# Build other submodules
SConscript([
Expand Down
6 changes: 3 additions & 3 deletions cereal/SConscript
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Import('env', 'envCython', 'arch', 'common', 'messaging')
Import('env', 'envCython', 'arch', 'common', 'msgq')

import shutil

cereal_dir = Dir('.')
gen_dir = Dir('gen')
other_dir = Dir('#msgq/messaging')
other_dir = Dir('#msgq')

# Build cereal
schema_files = ['log.capnp', 'car.capnp', 'legacy.capnp', 'custom.capnp']
Expand All @@ -22,7 +22,7 @@ env.SharedLibrary('cereal_shared', cereal_objects)
# Build messaging

services_h = env.Command(['services.h'], ['services.py'], 'python3 ' + cereal_dir.path + '/services.py > $TARGET')
env.Program('messaging/bridge', ['messaging/bridge.cc'], LIBS=[messaging, 'zmq', common])
env.Program('messaging/bridge', ['messaging/bridge.cc'], LIBS=[msgq, 'zmq', common])


socketmaster = env.SharedObject(['messaging/socketmaster.cc'])
Expand Down
60 changes: 3 additions & 57 deletions cereal/messaging/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# must be built with scons
from msgq.messaging.messaging_pyx import Context, Poller, SubSocket, PubSocket, SocketEventHandle, toggle_fake_events, \
from msgq.ipc_pyx import Context, Poller, SubSocket, PubSocket, SocketEventHandle, toggle_fake_events, \
set_fake_prefix, get_fake_prefix, delete_fake_prefix, wait_for_one_event
from msgq.messaging.messaging_pyx import MultiplePublishersError, MessagingError
from msgq.ipc_pyx import MultiplePublishersError, IpcError
from msgq import fake_event_handle, pub_sock, sub_sock, drain_sock_raw, context

import os
import capnp
Expand All @@ -13,27 +14,8 @@
from cereal import log
from cereal.services import SERVICE_LIST

assert MultiplePublishersError
assert MessagingError
assert toggle_fake_events
assert set_fake_prefix
assert get_fake_prefix
assert delete_fake_prefix
assert wait_for_one_event

NO_TRAVERSAL_LIMIT = 2**64-1

context = Context()


def fake_event_handle(endpoint: str, identifier: Optional[str] = None, override: bool = True, enable: bool = False) -> SocketEventHandle:
identifier = identifier or get_fake_prefix()
handle = SocketEventHandle(endpoint, identifier, override)
if override:
handle.enabled = enable

return handle


def log_from_bytes(dat: bytes) -> capnp.lib.capnp._DynamicStructReader:
with log.Event.from_bytes(dat, traversal_limit_in_words=NO_TRAVERSAL_LIMIT) as msg:
Expand All @@ -55,42 +37,6 @@ def new_message(service: Optional[str], size: Optional[int] = None, **kwargs) ->
return dat


def pub_sock(endpoint: str) -> PubSocket:
sock = PubSocket()
sock.connect(context, endpoint)
return sock


def sub_sock(endpoint: str, poller: Optional[Poller] = None, addr: str = "127.0.0.1",
conflate: bool = False, timeout: Optional[int] = None) -> SubSocket:
sock = SubSocket()
sock.connect(context, endpoint, addr.encode('utf8'), conflate)

if timeout is not None:
sock.setTimeout(timeout)

if poller is not None:
poller.registerSocket(sock)
return sock


def drain_sock_raw(sock: SubSocket, wait_for_one: bool = False) -> List[bytes]:
"""Receive all message currently available on the queue"""
ret: List[bytes] = []
while 1:
if wait_for_one and len(ret) == 0:
dat = sock.receive()
else:
dat = sock.receive(non_blocking=True)

if dat is None:
break

ret.append(dat)

return ret


def drain_sock(sock: SubSocket, wait_for_one: bool = False) -> List[capnp.lib.capnp._DynamicStructReader]:
"""Receive all message currently available on the queue"""
msgs = drain_sock_raw(sock, wait_for_one=wait_for_one)
Expand Down
4 changes: 2 additions & 2 deletions cereal/messaging/bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
typedef void (*sighandler_t)(int sig);

#include "cereal/services.h"
#include "msgq/messaging/impl_msgq.h"
#include "msgq/messaging/impl_zmq.h"
#include "msgq/impl_msgq.h"
#include "msgq/impl_zmq.h"

std::atomic<bool> do_exit = false;
static void set_do_exit(int sig) {
Expand Down
2 changes: 1 addition & 1 deletion cereal/messaging/messaging.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <capnp/serialize.h>

#include "cereal/gen/cpp/log.capnp.h"
#include "msgq/messaging/messaging.h"
#include "msgq/ipc.h"

#ifdef __APPLE__
#define CLOCK_BOOTTIME CLOCK_MONOTONIC
Expand Down
193 changes: 0 additions & 193 deletions cereal/messaging/tests/test_fake.py

This file was deleted.

Loading

0 comments on commit 97ac223

Please sign in to comment.