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: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:

- run: |
mk python-release owner=libre-embedded \
repo=runtimepy version=5.16.0
repo=runtimepy version=5.16.1
if: |
matrix.python-version == '3.13'
&& matrix.system == 'ubuntu-latest'
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2025 Libre Embedded
Copyright (c) 2026 Libre Embedded

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
=====================================
generator=datazen
version=3.2.3
hash=ebb0bba9899d4baf7ce73b082f5e384e
hash=5fb00253ef852621d793c49ac8298981
=====================================
-->

# runtimepy ([5.16.0](https://pypi.org/project/runtimepy/))
# runtimepy ([5.16.1](https://pypi.org/project/runtimepy/))

[![python](https://img.shields.io/pypi/pyversions/runtimepy.svg)](https://pypi.org/project/runtimepy/)
![Build Status](https://github.com/libre-embedded/runtimepy/workflows/Python%20Package/badge.svg)
Expand Down
2 changes: 1 addition & 1 deletion local/variables/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
major: 5
minor: 16
patch: 0
patch: 1
entry: runtimepy
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta:__legacy__"

[project]
name = "runtimepy"
version = "5.16.0"
version = "5.16.1"
description = "A framework for implementing Python services."
readme = "README.md"
requires-python = ">=3.12"
Expand Down
4 changes: 2 additions & 2 deletions runtimepy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# =====================================
# generator=datazen
# version=3.2.3
# hash=d903df789fdb4c76fdf462319413ca2c
# hash=6de05aa70a01c132db071f4bfe4f1675
# =====================================

"""
Expand All @@ -10,7 +10,7 @@

DESCRIPTION = "A framework for implementing Python services."
PKG_NAME = "runtimepy"
VERSION = "5.16.0"
VERSION = "5.16.1"

# runtimepy-specific content.
METRICS_NAME = "metrics"
Expand Down
9 changes: 7 additions & 2 deletions runtimepy/codec/protocol/receiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

# third-party
from vcorelib.logging import LoggerMixin
from vcorelib.math import default_time_ns

# internal
from runtimepy.codec.protocol import Protocol, ProtocolFactory
Expand Down Expand Up @@ -80,14 +81,18 @@ def register(self, factory: type[ProtocolFactory]) -> None:
def process(self, data: bytes) -> None:
"""Attempt to process a struct message."""

timestamp_ns = default_time_ns()

with BytesIO(data) as stream:
stream.seek(0, os.SEEK_END)
end_pos = stream.tell()
stream.seek(0, os.SEEK_SET)

while stream.tell() < end_pos:
ident = self.id_primitive.from_stream(
stream, byte_order=self.byte_order
stream,
byte_order=self.byte_order,
timestamp_ns=timestamp_ns,
)

# Handle non-struct messages.
Expand All @@ -107,7 +112,7 @@ def process(self, data: bytes) -> None:
# Handle struct messages.
elif ident in self.instances:
inst = self.instances[ident]
inst.from_stream(stream)
inst.from_stream(stream, timestamp_ns=timestamp_ns)
if ident in self.handlers:
self.handlers[ident](inst)
else:
Expand Down
23 changes: 18 additions & 5 deletions runtimepy/primitives/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,23 +244,36 @@ def to_stream(
stream.write(self.binary(byte_order=byte_order))
return self.kind.size

def update(self, data: BinaryMessage, byte_order: _ByteOrder = None) -> T:
def update(
self,
data: BinaryMessage,
byte_order: _ByteOrder = None,
timestamp_ns: int = None,
) -> T:
"""Update this primitive from a bytes object."""

if byte_order is None:
byte_order = self.byte_order

self.value = self.kind.decode( # type: ignore
data, byte_order=byte_order
self.set_value(
self.kind.decode(data, byte_order=byte_order), # type: ignore
timestamp_ns=timestamp_ns,
)
return self.value

def from_stream(
self, stream: _BinaryIO, byte_order: _ByteOrder = None
self,
stream: _BinaryIO,
byte_order: _ByteOrder = None,
timestamp_ns: int = None,
) -> T:
"""Update this primitive from a stream and return the new value."""

return self.update(stream.read(self.kind.size), byte_order=byte_order)
return self.update(
stream.read(self.kind.size),
byte_order=byte_order,
timestamp_ns=timestamp_ns,
)

@classmethod
def encode(cls, value: T, byte_order: _ByteOrder = None) -> bytes:
Expand Down