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
9 changes: 9 additions & 0 deletions src/pycbsdk/cbhw/packet/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
from ctypes import *
import struct
import numpy as np


class classproperty(object):
def __init__(self, f):
self.f = f

def __get__(self, obj, owner):
return self.f(owner)

import numpy.typing
from .common import (
CBPacketType,
Expand Down
6 changes: 4 additions & 2 deletions src/pycbsdk/cbhw/packet/header/v311.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from ctypes import *


from ..abstract import classproperty


class CBPacketHeader(Structure):
_pack_ = 1
_fields_ = [
Expand All @@ -13,7 +16,6 @@ class CBPacketHeader(Structure):
), # Number of 32-bit elements in packet body. * 4 to get number of bytes.
]

@classmethod
@property
@classproperty
def HEADER_FORMAT(cls):
return "<LHBB"
4 changes: 2 additions & 2 deletions src/pycbsdk/cbhw/packet/header/v40.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from ctypes import *
from ..abstract import classproperty


class CBPacketHeader(Structure):
Expand All @@ -15,7 +16,6 @@ class CBPacketHeader(Structure):
("reserved", 2 * c_uint8),
]

@classmethod
@property
@classproperty
def HEADER_FORMAT(cls):
return "<QHBHBH"
4 changes: 2 additions & 2 deletions src/pycbsdk/cbhw/packet/header/v41.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from ctypes import *
from ..abstract import classproperty
from ..common import print_pretty


Expand All @@ -17,7 +18,6 @@ class CBPacketHeader(Structure):
("reserved", c_uint8), # Changed in this version; used to be 2 * c_uint8
]

@classmethod
@property
@classproperty
def HEADER_FORMAT(cls):
return "<QHHHBB"
Loading