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
2 changes: 0 additions & 2 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import os
import platform
import subprocess
import sysconfig
import numpy as np
import catch2

arch = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip()
Expand Down Expand Up @@ -71,7 +70,6 @@ env = Environment(
Export('env', 'arch', 'common')

envCython = env.Clone(LIBS=[])
envCython["CPPPATH"] += [np.get_include()]
envCython["CCFLAGS"] += ["-Wno-#warnings", "-Wno-cpp", "-Wno-shadow", "-Wno-deprecated-declarations"]
envCython["CCFLAGS"].remove('-Werror')
if arch == "Darwin":
Expand Down
16 changes: 10 additions & 6 deletions msgq/visionipc/tests/test_visionipc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import struct
import unittest
from typing import Optional
import numpy as np
from msgq.visionipc import VisionIpcServer, VisionIpcClient, VisionStreamType


Expand Down Expand Up @@ -55,13 +55,17 @@ def test_send_single_buffer(self):
assert self.server is not None
assert self.client is not None
assert self.client.buffer_len is not None
buf = np.zeros(self.client.buffer_len, dtype=np.uint8)
buf.view('<u8')[0] = 1234
buf = bytearray(self.client.buffer_len)
struct.pack_into("<Q", buf, 0, 1234)
self.server.send(VisionStreamType.VISION_STREAM_ROAD, buf, frame_id=1337)

recv_buf = self.client.recv()
assert recv_buf is not None
assert recv_buf.data.view('<u8')[0] == 1234
data = recv_buf.data
assert isinstance(data, memoryview)
assert struct.unpack_from("<Q", data, 0)[0] == 1234
assert len(data) == self.client.buffer_len
assert data[8:].nbytes == self.client.buffer_len - 8
assert self.client.frame_id == 1337
assert recv_buf.frame_id == 1337

Expand All @@ -70,7 +74,7 @@ def test_no_conflate(self):
assert self.server is not None
assert self.client is not None
assert self.client.buffer_len is not None
buf = np.zeros(self.client.buffer_len, dtype=np.uint8)
buf = bytearray(self.client.buffer_len)
self.server.send(VisionStreamType.VISION_STREAM_ROAD, buf, frame_id=1)
self.server.send(VisionStreamType.VISION_STREAM_ROAD, buf, frame_id=2)

Expand All @@ -87,7 +91,7 @@ def test_conflate(self):
assert self.server is not None
assert self.client is not None
assert self.client.buffer_len is not None
buf = np.zeros(self.client.buffer_len, dtype=np.uint8)
buf = bytearray(self.client.buffer_len)
self.server.send(VisionStreamType.VISION_STREAM_ROAD, buf, frame_id=1)
self.server.send(VisionStreamType.VISION_STREAM_ROAD, buf, frame_id=2)

Expand Down
6 changes: 2 additions & 4 deletions msgq/visionipc/visionipc_pyx.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
# cython: c_string_encoding=ascii, language_level=3

import sys
import numpy as np
cimport numpy as cnp
from cython.view cimport array
from libc.string cimport memcpy
from libc.stdint cimport uint32_t, uint64_t
from libcpp cimport bool
Expand Down Expand Up @@ -37,7 +34,8 @@ cdef class VisionBuf:

@property
def data(self):
return np.asarray(<cnp.uint8_t[:self.buf.len]> self.buf.addr)
cdef unsigned char[:] data = <unsigned char[:self.buf.len]> self.buf.addr
return memoryview(data)

@property
def width(self):
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ dependencies = [
"ruff",
"parameterized",
"coverage",
"numpy",
"cppcheck",
"cpplint",
"codespell",
Expand Down
Loading