Skip to content
This repository was archived by the owner on Mar 11, 2026. It is now read-only.

Commit a6d0664

Browse files
authored
Merge pull request #24 from CerebusOSS/dev
main <- Dev
2 parents 7949e52 + 6b0810e commit a6d0664

5 files changed

Lines changed: 14 additions & 301 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,4 @@ cython_debug/
161161
# "I am become God." -Chad
162162

163163
src/pycbsdk/__version__.py
164+
uv.lock

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ config = cbsdk.get_config(nsp_obj)
2525
print(config)
2626
```
2727

28-
You may also try the provided test script with `python -m pycbsdk.examples.print_rates` or via the shortcut: `pycbsdk-rates`.
28+
You may also try one of the provided test scripts
29+
30+
* `python -m pycbsdk.examples.print_rates` or via the entrypoint `pycbsdk-rates`.
31+
* `python -m pycbsdk.examples.comments`
2932

3033
## Introduction
3134

@@ -37,6 +40,8 @@ However, it's pretty useful as is! And so far it has been good-enough for some q
3740

3841
## Design
3942

43+
![Alt text](./docs/img/pycbsdk_design.svg)
44+
4045
Upon initialization, the `NSPDevice` instance configures its sockets (but no connection yet), it allocates memory for its mirror of the device state, and it registers callbacks to monitor config state.
4146

4247
When the connection to the device is established, two threads are created and started:
@@ -65,8 +70,6 @@ This and more should appear in the documentation at some point in the future...
6570

6671
* This library takes exclusive control over the UDP socket on port 51002 and thus cannot be used with Central, nor any other instance of `pycbsdk`. You only get one instance of `pycbsdk` _or_ Central per machine.
6772
* [CereLink](https://github.com/CerebusOSS/CereLink)'s cerebus.cbpy uses shared memory and therefore can work in parallel to Central or other cbpy instances.
68-
* The API is still very sparse and limited in functionality.
69-
* For now, Python still has the GIL. This means that despite using threading, if your callback functions are slow and hold up the PacketHandlerThread, this could hold up datagram retrieval and ultimately cause packets to be dropped.
70-
* Callbacks may enqueue the data for a longer-running `multiprocessing` process to handle.
71-
* Switch to [No GIL Python](https://peps.python.org/pep-0703/) as soon as it is available.
72-
* Use pycbsdk to prototype an application in a language that uses real parallelism.
73+
* The API is sparse but is filling out over time. Use the issue tracker to make requests for features that you need.
74+
* For now, our dependencies are not compatible with NoGIL Python 3.13. This means that despite using threading, if your callback functions are slow and hold up the PacketHandlerThread, this could hold up datagram retrieval and ultimately cause packets to be dropped.
75+
* Socket configuration is still finicky and platform-specific. On Windows you might need to supply the address of the local adapter pycbsdk is binding (e.g., `--client-addr 192.168.137.198`), but on MacOS you must bind `INADDR_ANY`, or `--client-addr 0.0.0.0`, which is the default in most cases and can be omitted.

src/pycbsdk/cbhw/device/nsp.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,8 @@ def get_config(
10151015
# Clear out our existing config
10161016
self._config["proc_chans"] = 0
10171017
self._config["channel_infos"] = {}
1018-
self._config["sysfreq"] = None
1018+
# Do not clear sysfreq if we already have it as this cannot change.
1019+
self._config["sysfreq"] = self._config.get("sysfreq", None)
10191020
time.sleep(0.1)
10201021
pkt = self.packet_factory.make_packet(
10211022
None,

src/pycbsdk/examples/comments.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ def main(
7777

7878
try:
7979
while True:
80-
input("Press any key to begin entering comment...")
81-
comment = input("Enter comment: ")
80+
input("Press <enter> to start a new comment...")
81+
comment = input("Input comment: ")
8282
ts = nsp_obj.last_time
8383
print(f"Sending comment {comment} with timestamp {ts}")
8484
cbsdk.set_comment(nsp_obj, comment, ts)

0 commit comments

Comments
 (0)