opengearwire 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- opengearwire-0.3.0/LICENSE +21 -0
- opengearwire-0.3.0/PKG-INFO +182 -0
- opengearwire-0.3.0/README.md +154 -0
- opengearwire-0.3.0/opengearwire/__init__.py +29 -0
- opengearwire-0.3.0/opengearwire/__main__.py +134 -0
- opengearwire-0.3.0/opengearwire/_protocol.py +616 -0
- opengearwire-0.3.0/opengearwire/client.py +453 -0
- opengearwire-0.3.0/opengearwire/docs/PROTOCOL.md +292 -0
- opengearwire-0.3.0/opengearwire/fixtures/dashboard-session.jsonl +3941 -0
- opengearwire-0.3.0/opengearwire/model.py +326 -0
- opengearwire-0.3.0/opengearwire/py.typed +0 -0
- opengearwire-0.3.0/opengearwire/snapshot.py +83 -0
- opengearwire-0.3.0/opengearwire/testing.py +262 -0
- opengearwire-0.3.0/opengearwire.egg-info/PKG-INFO +182 -0
- opengearwire-0.3.0/opengearwire.egg-info/SOURCES.txt +19 -0
- opengearwire-0.3.0/opengearwire.egg-info/dependency_links.txt +1 -0
- opengearwire-0.3.0/opengearwire.egg-info/entry_points.txt +2 -0
- opengearwire-0.3.0/opengearwire.egg-info/requires.txt +9 -0
- opengearwire-0.3.0/opengearwire.egg-info/top_level.txt +1 -0
- opengearwire-0.3.0/pyproject.toml +53 -0
- opengearwire-0.3.0/setup.cfg +4 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Lucas Romanenko
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: opengearwire
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Python library for openGear frames (Ross OGX) over the openGear Protocol, TCP 5253: frame health, every card's parameters, pushed changes
|
|
5
|
+
Author: Lucas Romanenko
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Repository, https://github.com/lucas-romanenko/opengearwire
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
14
|
+
Classifier: Development Status :: 3 - Alpha
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Topic :: Multimedia :: Video
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Provides-Extra: test
|
|
21
|
+
Requires-Dist: pytest; extra == "test"
|
|
22
|
+
Requires-Dist: pytest-timeout; extra == "test"
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: pytest; extra == "dev"
|
|
25
|
+
Requires-Dist: pytest-timeout; extra == "dev"
|
|
26
|
+
Requires-Dist: ruff; extra == "dev"
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# opengearwire
|
|
30
|
+
|
|
31
|
+
Python library for **openGear frames** (Ross OGX and the partner cards in
|
|
32
|
+
them) over the openGear Protocol, OGP, on TCP 5253: the frame's health
|
|
33
|
+
and every card's parameters, read the way Ross DashBoard reads them.
|
|
34
|
+
|
|
35
|
+
[](https://github.com/lucas-romanenko/opengearwire/actions/workflows/ci.yml) [](LICENSE) 
|
|
36
|
+
|
|
37
|
+
Everything here was decoded from a packet capture of DashBoard 10 reading
|
|
38
|
+
a real frame, checked against Ross's public OGP application note, and is
|
|
39
|
+
tested by replaying that capture (sanitized) against the client. The
|
|
40
|
+
wire format is in [`opengearwire/docs/PROTOCOL.md`](opengearwire/docs/PROTOCOL.md).
|
|
41
|
+
|
|
42
|
+
## Status
|
|
43
|
+
|
|
44
|
+
- **0.3.0, read-only.** Verified against one capture: an OGX frame with
|
|
45
|
+
an MFC-8322-S controller and ten DRA-8804 reclocking DAs. 3,940 of its
|
|
46
|
+
3,941 messages decode completely; the client rebuilds the same
|
|
47
|
+
parameter tree DashBoard got.
|
|
48
|
+
- **No writes** except the connection hello DashBoard itself sends
|
|
49
|
+
(it sets nothing). Setting changes come once one is captured.
|
|
50
|
+
- Run against the live frame: its snapshot has every parameter the
|
|
51
|
+
capture has.
|
|
52
|
+
|
|
53
|
+
## One client at a time
|
|
54
|
+
|
|
55
|
+
An **MFC-8322-S controller takes one control connection at a time**.
|
|
56
|
+
While DashBoard is connected, the frame hangs up on this library, and
|
|
57
|
+
while the library is connected, DashBoard is locked out. Confirmed both
|
|
58
|
+
ways on a live frame; Ross's MFC manual (Table 1, Feature Comparison)
|
|
59
|
+
lists more than one concurrent TCP control connection for the MFC-OG3-N
|
|
60
|
+
only.
|
|
61
|
+
|
|
62
|
+
So: **connect, read, disconnect quickly.** Keep a `Frame` open only
|
|
63
|
+
while someone is looking at what it reads, never in the background, and
|
|
64
|
+
keep `watch` short; close DashBoard before running the CLI. When the frame hangs up before answering anything after the hello,
|
|
65
|
+
the library raises `FrameBusy` (a `FrameError`) saying so; a hang-up
|
|
66
|
+
later in a read is the plain `FrameError`.
|
|
67
|
+
|
|
68
|
+
## Install
|
|
69
|
+
|
|
70
|
+
```sh
|
|
71
|
+
pip install opengearwire
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Python 3.10 or newer. Standard library only.
|
|
75
|
+
|
|
76
|
+
## Usage
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from opengearwire import Frame
|
|
80
|
+
|
|
81
|
+
with Frame("192.0.2.10") as f:
|
|
82
|
+
f.discover() # [0, 2, 4, ...]: slots that answered (0 = controller)
|
|
83
|
+
f.identify() # {0: "MFC-8322-S", 2: "DRA-8804", ...}
|
|
84
|
+
f.describe() # every parameter, value and menu of every slot
|
|
85
|
+
card = f.device(4)
|
|
86
|
+
print(card.find("Enable Equalizer").display) # ['Enabled', 'Enabled'] (channel A, B)
|
|
87
|
+
print(card.find(0x0704).display) # 'Locked - 1.5G'
|
|
88
|
+
for change in f.watch(10): # what the frame pushed in 10 s
|
|
89
|
+
print(change.slot, change.name, change.old, "->", change.new)
|
|
90
|
+
snap = f.snapshot() # plain dicts: frame health + every card, json.dumps-ready
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
- `Frame(host, port=5253, timeout=5.0, retry_after=2.5, retries=3)`.
|
|
94
|
+
`timeout` is **no-progress**: seconds without a byte from the frame
|
|
95
|
+
(which reports its status every second), not a total. An unanswered
|
|
96
|
+
request is resent after `retry_after` seconds, as DashBoard does;
|
|
97
|
+
after `retries` the rest goes on, and it is asked again in one final
|
|
98
|
+
round at the end. What still has no answer is listed in
|
|
99
|
+
`Frame.unanswered` (slot, request, OID and name, or menu / object) and
|
|
100
|
+
in the snapshot's `unanswered`.
|
|
101
|
+
- `discover()` listens: every card reports on its own within about a
|
|
102
|
+
second, and it stops as soon as the controller's Active Cards count is
|
|
103
|
+
reached. It assumes no layout: any of the 20 slots, single- or
|
|
104
|
+
double-width cards.
|
|
105
|
+
- `describe(slots=None, menus=True)`, `describe_oids(slot, oids)`,
|
|
106
|
+
`read(slot, *oids_or_names)` (fresh values), `watch(seconds)`,
|
|
107
|
+
`snapshot()`.
|
|
108
|
+
- `Parameter.value` is the decoded value; `.display` is what DashBoard
|
|
109
|
+
shows (choice labels, active alarm names, IP addresses); `.severity`
|
|
110
|
+
is 0/1/2 for alarm tables. In the snapshot each parameter has
|
|
111
|
+
`value` and, where they differ, `display` beside it (Channel A Status:
|
|
112
|
+
`"value": 16, "display": ["No input"]`).
|
|
113
|
+
- `Tree.apply(message)` builds the same tree from any message source (a
|
|
114
|
+
capture, a test), with no network.
|
|
115
|
+
|
|
116
|
+
Nothing runs on a timer: each call does what it says on one connection
|
|
117
|
+
and returns. One request in flight per device, all devices in parallel.
|
|
118
|
+
|
|
119
|
+
## Command line
|
|
120
|
+
|
|
121
|
+
```sh
|
|
122
|
+
opengearwire 192.0.2.10 slots # occupied slots and their products
|
|
123
|
+
opengearwire 192.0.2.10 params 4 # every parameter of slot 4
|
|
124
|
+
opengearwire 192.0.2.10 read 4 0x0b04 # fresh value(s) by OID or exact name
|
|
125
|
+
opengearwire 192.0.2.10 watch 10 # pushed changes for 10 s
|
|
126
|
+
opengearwire 192.0.2.10 snapshot # the whole frame as JSON
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
`--json` for machine output, `--timeout` for the silence limit.
|
|
130
|
+
Requests the frame never answered are listed on stderr (and in the
|
|
131
|
+
snapshot's `unanswered`).
|
|
132
|
+
`python -m opengearwire` works too.
|
|
133
|
+
|
|
134
|
+
## Testing without a frame
|
|
135
|
+
|
|
136
|
+
`opengearwire.testing` is a fake frame for your own tests and for
|
|
137
|
+
developing an app: it listens on 127.0.0.1 and answers from the bundled
|
|
138
|
+
capture (sanitized), including the frame's one-client-at-a-time
|
|
139
|
+
behaviour.
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
from opengearwire import Frame, FrameBusy
|
|
143
|
+
from opengearwire.testing import FakeFrame
|
|
144
|
+
|
|
145
|
+
fake = FakeFrame() # a free port on 127.0.0.1: fake.port
|
|
146
|
+
with Frame("127.0.0.1", fake.port) as f:
|
|
147
|
+
f.discover()
|
|
148
|
+
fake.report(18, 0x0705, b"12 (1694A) / 8 (1855A)\x00") # a card pushes a change
|
|
149
|
+
print(f.watch(0.5))
|
|
150
|
+
fake.busy = True # "DashBoard is connected": every client is turned away (FrameBusy)
|
|
151
|
+
fake.close()
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
```sh
|
|
155
|
+
python -m opengearwire.testing --port 5253 # a fake frame to point an app at
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Development
|
|
159
|
+
|
|
160
|
+
```sh
|
|
161
|
+
pip install -e ".[dev]"
|
|
162
|
+
python -m pytest
|
|
163
|
+
ruff check . && ruff format --check .
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
The suite needs no hardware: it runs `opengearwire.testing`'s fake
|
|
167
|
+
frame on 127.0.0.1, answering from the captured session. To make a
|
|
168
|
+
fixture from a new capture (it replaces serials, MAC, names, passwords and
|
|
169
|
+
IP addresses and refuses to write if any original survives):
|
|
170
|
+
|
|
171
|
+
```sh
|
|
172
|
+
python tools/fixture_from_capture.py CAPTURE.pcapng opengearwire/fixtures/NAME.jsonl
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Raw captures never go into git (`.gitignore` blocks them).
|
|
176
|
+
|
|
177
|
+
A release is a tag `v<version>` matching `project.version`: the tag push
|
|
178
|
+
publishes it to PyPI (`.github/workflows/publish.yml`, trusted
|
|
179
|
+
publishing, no token in the repository).
|
|
180
|
+
|
|
181
|
+
Not affiliated with or endorsed by Ross Video Ltd. openGear, DashBoard
|
|
182
|
+
and OGX are trademarks of Ross Video.
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# opengearwire
|
|
2
|
+
|
|
3
|
+
Python library for **openGear frames** (Ross OGX and the partner cards in
|
|
4
|
+
them) over the openGear Protocol, OGP, on TCP 5253: the frame's health
|
|
5
|
+
and every card's parameters, read the way Ross DashBoard reads them.
|
|
6
|
+
|
|
7
|
+
[](https://github.com/lucas-romanenko/opengearwire/actions/workflows/ci.yml) [](LICENSE) 
|
|
8
|
+
|
|
9
|
+
Everything here was decoded from a packet capture of DashBoard 10 reading
|
|
10
|
+
a real frame, checked against Ross's public OGP application note, and is
|
|
11
|
+
tested by replaying that capture (sanitized) against the client. The
|
|
12
|
+
wire format is in [`opengearwire/docs/PROTOCOL.md`](opengearwire/docs/PROTOCOL.md).
|
|
13
|
+
|
|
14
|
+
## Status
|
|
15
|
+
|
|
16
|
+
- **0.3.0, read-only.** Verified against one capture: an OGX frame with
|
|
17
|
+
an MFC-8322-S controller and ten DRA-8804 reclocking DAs. 3,940 of its
|
|
18
|
+
3,941 messages decode completely; the client rebuilds the same
|
|
19
|
+
parameter tree DashBoard got.
|
|
20
|
+
- **No writes** except the connection hello DashBoard itself sends
|
|
21
|
+
(it sets nothing). Setting changes come once one is captured.
|
|
22
|
+
- Run against the live frame: its snapshot has every parameter the
|
|
23
|
+
capture has.
|
|
24
|
+
|
|
25
|
+
## One client at a time
|
|
26
|
+
|
|
27
|
+
An **MFC-8322-S controller takes one control connection at a time**.
|
|
28
|
+
While DashBoard is connected, the frame hangs up on this library, and
|
|
29
|
+
while the library is connected, DashBoard is locked out. Confirmed both
|
|
30
|
+
ways on a live frame; Ross's MFC manual (Table 1, Feature Comparison)
|
|
31
|
+
lists more than one concurrent TCP control connection for the MFC-OG3-N
|
|
32
|
+
only.
|
|
33
|
+
|
|
34
|
+
So: **connect, read, disconnect quickly.** Keep a `Frame` open only
|
|
35
|
+
while someone is looking at what it reads, never in the background, and
|
|
36
|
+
keep `watch` short; close DashBoard before running the CLI. When the frame hangs up before answering anything after the hello,
|
|
37
|
+
the library raises `FrameBusy` (a `FrameError`) saying so; a hang-up
|
|
38
|
+
later in a read is the plain `FrameError`.
|
|
39
|
+
|
|
40
|
+
## Install
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
pip install opengearwire
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Python 3.10 or newer. Standard library only.
|
|
47
|
+
|
|
48
|
+
## Usage
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from opengearwire import Frame
|
|
52
|
+
|
|
53
|
+
with Frame("192.0.2.10") as f:
|
|
54
|
+
f.discover() # [0, 2, 4, ...]: slots that answered (0 = controller)
|
|
55
|
+
f.identify() # {0: "MFC-8322-S", 2: "DRA-8804", ...}
|
|
56
|
+
f.describe() # every parameter, value and menu of every slot
|
|
57
|
+
card = f.device(4)
|
|
58
|
+
print(card.find("Enable Equalizer").display) # ['Enabled', 'Enabled'] (channel A, B)
|
|
59
|
+
print(card.find(0x0704).display) # 'Locked - 1.5G'
|
|
60
|
+
for change in f.watch(10): # what the frame pushed in 10 s
|
|
61
|
+
print(change.slot, change.name, change.old, "->", change.new)
|
|
62
|
+
snap = f.snapshot() # plain dicts: frame health + every card, json.dumps-ready
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
- `Frame(host, port=5253, timeout=5.0, retry_after=2.5, retries=3)`.
|
|
66
|
+
`timeout` is **no-progress**: seconds without a byte from the frame
|
|
67
|
+
(which reports its status every second), not a total. An unanswered
|
|
68
|
+
request is resent after `retry_after` seconds, as DashBoard does;
|
|
69
|
+
after `retries` the rest goes on, and it is asked again in one final
|
|
70
|
+
round at the end. What still has no answer is listed in
|
|
71
|
+
`Frame.unanswered` (slot, request, OID and name, or menu / object) and
|
|
72
|
+
in the snapshot's `unanswered`.
|
|
73
|
+
- `discover()` listens: every card reports on its own within about a
|
|
74
|
+
second, and it stops as soon as the controller's Active Cards count is
|
|
75
|
+
reached. It assumes no layout: any of the 20 slots, single- or
|
|
76
|
+
double-width cards.
|
|
77
|
+
- `describe(slots=None, menus=True)`, `describe_oids(slot, oids)`,
|
|
78
|
+
`read(slot, *oids_or_names)` (fresh values), `watch(seconds)`,
|
|
79
|
+
`snapshot()`.
|
|
80
|
+
- `Parameter.value` is the decoded value; `.display` is what DashBoard
|
|
81
|
+
shows (choice labels, active alarm names, IP addresses); `.severity`
|
|
82
|
+
is 0/1/2 for alarm tables. In the snapshot each parameter has
|
|
83
|
+
`value` and, where they differ, `display` beside it (Channel A Status:
|
|
84
|
+
`"value": 16, "display": ["No input"]`).
|
|
85
|
+
- `Tree.apply(message)` builds the same tree from any message source (a
|
|
86
|
+
capture, a test), with no network.
|
|
87
|
+
|
|
88
|
+
Nothing runs on a timer: each call does what it says on one connection
|
|
89
|
+
and returns. One request in flight per device, all devices in parallel.
|
|
90
|
+
|
|
91
|
+
## Command line
|
|
92
|
+
|
|
93
|
+
```sh
|
|
94
|
+
opengearwire 192.0.2.10 slots # occupied slots and their products
|
|
95
|
+
opengearwire 192.0.2.10 params 4 # every parameter of slot 4
|
|
96
|
+
opengearwire 192.0.2.10 read 4 0x0b04 # fresh value(s) by OID or exact name
|
|
97
|
+
opengearwire 192.0.2.10 watch 10 # pushed changes for 10 s
|
|
98
|
+
opengearwire 192.0.2.10 snapshot # the whole frame as JSON
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
`--json` for machine output, `--timeout` for the silence limit.
|
|
102
|
+
Requests the frame never answered are listed on stderr (and in the
|
|
103
|
+
snapshot's `unanswered`).
|
|
104
|
+
`python -m opengearwire` works too.
|
|
105
|
+
|
|
106
|
+
## Testing without a frame
|
|
107
|
+
|
|
108
|
+
`opengearwire.testing` is a fake frame for your own tests and for
|
|
109
|
+
developing an app: it listens on 127.0.0.1 and answers from the bundled
|
|
110
|
+
capture (sanitized), including the frame's one-client-at-a-time
|
|
111
|
+
behaviour.
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
from opengearwire import Frame, FrameBusy
|
|
115
|
+
from opengearwire.testing import FakeFrame
|
|
116
|
+
|
|
117
|
+
fake = FakeFrame() # a free port on 127.0.0.1: fake.port
|
|
118
|
+
with Frame("127.0.0.1", fake.port) as f:
|
|
119
|
+
f.discover()
|
|
120
|
+
fake.report(18, 0x0705, b"12 (1694A) / 8 (1855A)\x00") # a card pushes a change
|
|
121
|
+
print(f.watch(0.5))
|
|
122
|
+
fake.busy = True # "DashBoard is connected": every client is turned away (FrameBusy)
|
|
123
|
+
fake.close()
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
```sh
|
|
127
|
+
python -m opengearwire.testing --port 5253 # a fake frame to point an app at
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Development
|
|
131
|
+
|
|
132
|
+
```sh
|
|
133
|
+
pip install -e ".[dev]"
|
|
134
|
+
python -m pytest
|
|
135
|
+
ruff check . && ruff format --check .
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
The suite needs no hardware: it runs `opengearwire.testing`'s fake
|
|
139
|
+
frame on 127.0.0.1, answering from the captured session. To make a
|
|
140
|
+
fixture from a new capture (it replaces serials, MAC, names, passwords and
|
|
141
|
+
IP addresses and refuses to write if any original survives):
|
|
142
|
+
|
|
143
|
+
```sh
|
|
144
|
+
python tools/fixture_from_capture.py CAPTURE.pcapng opengearwire/fixtures/NAME.jsonl
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Raw captures never go into git (`.gitignore` blocks them).
|
|
148
|
+
|
|
149
|
+
A release is a tag `v<version>` matching `project.version`: the tag push
|
|
150
|
+
publishes it to PyPI (`.github/workflows/publish.yml`, trusted
|
|
151
|
+
publishing, no token in the repository).
|
|
152
|
+
|
|
153
|
+
Not affiliated with or endorsed by Ross Video Ltd. openGear, DashBoard
|
|
154
|
+
and OGX are trademarks of Ross Video.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT
|
|
2
|
+
"""opengearwire: read openGear frames (Ross OGX and partners) over OGP.
|
|
3
|
+
|
|
4
|
+
Read-only for now. ``Frame`` connects and reads; ``Tree`` holds what was
|
|
5
|
+
read; ``snapshot`` turns it into plain data. ``docs/PROTOCOL.md`` is the
|
|
6
|
+
wire format.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
__version__ = "0.3.0"
|
|
10
|
+
|
|
11
|
+
from ._protocol import ProtocolError, RemoteError
|
|
12
|
+
from .client import Frame, FrameBusy, FrameError
|
|
13
|
+
from .model import Change, Device, Parameter, Tree, address_of, slot_of
|
|
14
|
+
from .snapshot import snapshot
|
|
15
|
+
|
|
16
|
+
__all__ = [
|
|
17
|
+
"Change",
|
|
18
|
+
"Device",
|
|
19
|
+
"Frame",
|
|
20
|
+
"FrameBusy",
|
|
21
|
+
"FrameError",
|
|
22
|
+
"Parameter",
|
|
23
|
+
"ProtocolError",
|
|
24
|
+
"RemoteError",
|
|
25
|
+
"Tree",
|
|
26
|
+
"address_of",
|
|
27
|
+
"slot_of",
|
|
28
|
+
"snapshot",
|
|
29
|
+
]
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT
|
|
2
|
+
"""opengearwire HOST COMMAND: read a frame from the command line.
|
|
3
|
+
|
|
4
|
+
opengearwire 192.0.2.10 slots occupied slots and their products
|
|
5
|
+
opengearwire 192.0.2.10 params 4 every parameter of slot 4
|
|
6
|
+
opengearwire 192.0.2.10 read 4 0x0b04 fresh value(s) by OID or name
|
|
7
|
+
opengearwire 192.0.2.10 watch 10 pushed changes for 10 s
|
|
8
|
+
opengearwire 192.0.2.10 snapshot the whole frame as JSON
|
|
9
|
+
|
|
10
|
+
Slot 0 is the frame controller. Every command opens one connection,
|
|
11
|
+
does what it says and closes; nothing is ever written to the frame.
|
|
12
|
+
The frame takes one client at a time: close DashBoard first.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
import argparse
|
|
16
|
+
import json
|
|
17
|
+
import sys
|
|
18
|
+
|
|
19
|
+
from . import _protocol as P
|
|
20
|
+
from .client import PORT, Frame, FrameError
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _fmt(v) -> str:
|
|
24
|
+
if isinstance(v, list):
|
|
25
|
+
return ", ".join(str(x) for x in v)
|
|
26
|
+
return str(v)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def main(argv=None) -> int:
|
|
30
|
+
ap = argparse.ArgumentParser(prog="opengearwire", description=__doc__.split("\n")[0])
|
|
31
|
+
ap.add_argument("host")
|
|
32
|
+
ap.add_argument("--port", type=int, default=PORT)
|
|
33
|
+
ap.add_argument(
|
|
34
|
+
"--timeout",
|
|
35
|
+
type=float,
|
|
36
|
+
default=5.0,
|
|
37
|
+
help="seconds of silence from the frame before giving up (default 5)",
|
|
38
|
+
)
|
|
39
|
+
ap.add_argument("--json", action="store_true", help="JSON output")
|
|
40
|
+
sub = ap.add_subparsers(dest="cmd", required=True)
|
|
41
|
+
sub.add_parser("slots")
|
|
42
|
+
p = sub.add_parser("params")
|
|
43
|
+
p.add_argument("slot", type=int)
|
|
44
|
+
p = sub.add_parser("read")
|
|
45
|
+
p.add_argument("slot", type=int)
|
|
46
|
+
p.add_argument("keys", nargs="+", help="OIDs (0x0b04) or exact names")
|
|
47
|
+
p = sub.add_parser("watch")
|
|
48
|
+
p.add_argument("seconds", type=float)
|
|
49
|
+
sub.add_parser("snapshot")
|
|
50
|
+
a = ap.parse_args(argv)
|
|
51
|
+
|
|
52
|
+
try:
|
|
53
|
+
with Frame(a.host, a.port, timeout=a.timeout) as f:
|
|
54
|
+
return _run(f, a)
|
|
55
|
+
except (OSError, FrameError, P.ProtocolError) as e:
|
|
56
|
+
print(f"opengearwire: {a.host}: {e}", file=sys.stderr)
|
|
57
|
+
return 1
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def _run(f: Frame, a) -> int:
|
|
61
|
+
out = sys.stdout
|
|
62
|
+
if a.cmd == "slots":
|
|
63
|
+
f.discover()
|
|
64
|
+
rows = list(f.identify().items())
|
|
65
|
+
if a.json:
|
|
66
|
+
json.dump([{"slot": s, "product": p} for s, p in rows], out, indent=2)
|
|
67
|
+
out.write("\n")
|
|
68
|
+
else:
|
|
69
|
+
for s, p in rows:
|
|
70
|
+
out.write(f"{s:>3} {p}\n")
|
|
71
|
+
elif a.cmd == "params":
|
|
72
|
+
f.describe([a.slot])
|
|
73
|
+
dev = f.device(a.slot)
|
|
74
|
+
if a.json:
|
|
75
|
+
json.dump(dev.to_dict(), out, indent=2)
|
|
76
|
+
out.write("\n")
|
|
77
|
+
else:
|
|
78
|
+
for o in dev.oids:
|
|
79
|
+
p = dev.params[o]
|
|
80
|
+
d = p.descriptor
|
|
81
|
+
rw = "rw" if d and d.writable else "ro"
|
|
82
|
+
kind = d.type_name if d else "?"
|
|
83
|
+
out.write(f"0x{o:04x} {rw} {kind:9} {p.name!r:32} {_fmt(p.display)}\n")
|
|
84
|
+
elif a.cmd == "read":
|
|
85
|
+
keys = [int(k, 16) if k.lower().startswith("0x") else k for k in a.keys]
|
|
86
|
+
if all(isinstance(k, int) for k in keys):
|
|
87
|
+
f.describe_oids(a.slot, keys) # descriptors decode the values
|
|
88
|
+
else:
|
|
89
|
+
f.describe([a.slot], menus=False) # names need the whole list
|
|
90
|
+
vals = f.read(a.slot, *keys)
|
|
91
|
+
dev = f.device(a.slot)
|
|
92
|
+
rows = [(o, dev.params[o]) for o in vals]
|
|
93
|
+
if a.json:
|
|
94
|
+
json.dump([p.to_dict() for _, p in rows], out, indent=2)
|
|
95
|
+
out.write("\n")
|
|
96
|
+
else:
|
|
97
|
+
for o, p in rows:
|
|
98
|
+
out.write(f"0x{o:04x} {p.name!r}: {_fmt(p.display)}\n")
|
|
99
|
+
elif a.cmd == "watch":
|
|
100
|
+
f.discover()
|
|
101
|
+
for ch in f.watch(a.seconds):
|
|
102
|
+
if a.json:
|
|
103
|
+
out.write(
|
|
104
|
+
json.dumps(
|
|
105
|
+
{
|
|
106
|
+
"slot": ch.slot,
|
|
107
|
+
"oid": f"0x{ch.oid:04x}",
|
|
108
|
+
"name": ch.name,
|
|
109
|
+
"old": ch.old,
|
|
110
|
+
"new": ch.new,
|
|
111
|
+
}
|
|
112
|
+
)
|
|
113
|
+
+ "\n"
|
|
114
|
+
)
|
|
115
|
+
else:
|
|
116
|
+
out.write(f"slot {ch.slot} 0x{ch.oid:04x} {ch.name!r}: {ch.old!r} -> {ch.new!r}\n")
|
|
117
|
+
elif a.cmd == "snapshot":
|
|
118
|
+
f.discover()
|
|
119
|
+
f.describe()
|
|
120
|
+
json.dump(f.snapshot(), out, indent=2)
|
|
121
|
+
out.write("\n")
|
|
122
|
+
if f.unanswered:
|
|
123
|
+
print(f"opengearwire: {len(f.unanswered)} request(s) never answered", file=sys.stderr)
|
|
124
|
+
for u in f.unanswered:
|
|
125
|
+
what = u.get("oid") or ", ".join(
|
|
126
|
+
f"{k} {u[k]}" for k in ("menuset", "menu", "object", "offset") if k in u
|
|
127
|
+
)
|
|
128
|
+
name = f" {u['name']!r}" if "name" in u else ""
|
|
129
|
+
print(f" slot {u['slot']} {u['request']} {what}{name}", file=sys.stderr)
|
|
130
|
+
return 0
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
if __name__ == "__main__":
|
|
134
|
+
sys.exit(main())
|