pydbxdriverack 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,19 @@
1
+ import importlib.metadata
2
+
3
+ from .connection import PA2AuthError, PA2Connection, PA2ConnectionError
4
+ from .device import PA2Device
5
+ from .discovery import async_discover_devices
6
+
7
+ try:
8
+ __version__ = importlib.metadata.version("pydbxdriverack")
9
+ except importlib.metadata.PackageNotFoundError:
10
+ __version__ = "0.0.1"
11
+
12
+ __all__ = [
13
+ "PA2Connection",
14
+ "PA2ConnectionError",
15
+ "PA2AuthError",
16
+ "PA2Device",
17
+ "async_discover_devices",
18
+ "__version__",
19
+ ]
@@ -0,0 +1,211 @@
1
+ """Connection and authentication management for DBX DriveRack."""
2
+
3
+ import asyncio
4
+ import logging
5
+ import re
6
+ from typing import Callable, Optional, Union
7
+
8
+ from .const import DEFAULT_PASS, DEFAULT_USER, PORT
9
+
10
+ _LOGGER = logging.getLogger(__name__)
11
+
12
+ # Matches: verb "path" "value" (value is optional)
13
+ LINE_RE = re.compile(r'^([a-z]+)\s+"([^"]+)"(?:\s+"([^"]*)")?')
14
+
15
+
16
+ class PA2ConnectionError(Exception):
17
+ """Exception raised for connection errors."""
18
+
19
+
20
+ class PA2AuthError(PA2ConnectionError):
21
+ """Exception raised for authentication errors."""
22
+
23
+
24
+ class PA2Connection:
25
+ """Class to make authenticated requests over the PA2 TCP protocol."""
26
+
27
+ def __init__(self, host: str, password: str = DEFAULT_PASS):
28
+ """Initialize the connection."""
29
+ self.host = host
30
+ self.password = password
31
+ self._reader: Optional[asyncio.StreamReader] = None
32
+ self._writer: Optional[asyncio.StreamWriter] = None
33
+ self._online: bool = False
34
+
35
+ self._pending_requests: dict[str, asyncio.Future] = {}
36
+ self._subscriptions: dict[str, Callable] = {}
37
+ self._read_task: Optional[asyncio.Task] = None
38
+
39
+ @property
40
+ def is_online(self) -> bool:
41
+ """Return True when the underlying socket is connected and writable."""
42
+ return self._online and self._writer is not None and not self._writer.is_closing()
43
+
44
+ def _ensure_online(self):
45
+ """Fail fast when callers attempt an operation while offline."""
46
+ if not self.is_online:
47
+ raise PA2ConnectionError("Device is offline.")
48
+
49
+ def _mark_offline(self, reason: str = "Device is offline."):
50
+ """Mark the connection offline and fail all in-flight requests."""
51
+ self._online = False
52
+ for future in self._pending_requests.values():
53
+ if not future.done():
54
+ future.set_exception(PA2ConnectionError(reason))
55
+ self._pending_requests.clear()
56
+
57
+ async def connect(self):
58
+ """Connect to the device and authenticate."""
59
+ try:
60
+ self._reader, self._writer = await asyncio.open_connection(self.host, PORT)
61
+ except OSError as err:
62
+ raise PA2ConnectionError(f"Failed to connect to {self.host}:{PORT}") from err
63
+
64
+ # Read the banner "HiQnet Console"
65
+ banner = await self._reader.readline()
66
+ if not banner:
67
+ raise PA2ConnectionError("Connection closed before banner.")
68
+
69
+ # Send authentication
70
+ auth_cmd = f'connect {DEFAULT_USER} "{self.password}"\r\n'
71
+ self._writer.write(auth_cmd.encode("utf-8"))
72
+ await self._writer.drain()
73
+
74
+ # Check authentication response
75
+ auth_resp = await self._reader.readline()
76
+ auth_resp_str = auth_resp.decode("utf-8").strip()
77
+ if not auth_resp_str:
78
+ auth_resp = await self._reader.readline()
79
+ auth_resp_str = auth_resp.decode("utf-8").strip()
80
+ if "logged in" not in auth_resp_str:
81
+ await self.disconnect()
82
+ raise PA2AuthError(f"Authentication failed: {auth_resp_str}")
83
+
84
+ # Start the background read loop
85
+ self._online = True
86
+ self._read_task = asyncio.create_task(self._read_loop())
87
+
88
+ async def disconnect(self):
89
+ """Disconnect and cleanup."""
90
+ self._mark_offline()
91
+ if self._read_task:
92
+ self._read_task.cancel()
93
+ self._read_task = None
94
+ if self._writer:
95
+ self._writer.close()
96
+ await self._writer.wait_closed()
97
+ self._writer = None
98
+ self._reader = None
99
+
100
+ async def request(
101
+ self, verb: str, path: str, value: Optional[str] = None, wait_for_response: bool = True
102
+ ) -> Union[str, asyncio.Future[str]]:
103
+ """Send a request and wait for a response."""
104
+ self._ensure_online()
105
+
106
+ future: asyncio.Future[str] = asyncio.get_running_loop().create_future()
107
+ # In this protocol, the device echoes back the path. We use the path to resolve futures.
108
+ self._pending_requests[path] = future
109
+
110
+ cmd = f'{verb} "{path}"'
111
+ if value is not None:
112
+ cmd += f' "{value}"'
113
+ cmd += "\r\n"
114
+
115
+ if not self._writer:
116
+ raise PA2ConnectionError("Writer is not available. Connection may be closed.")
117
+
118
+ try:
119
+ self._writer.write(cmd.encode("utf-8"))
120
+ await self._writer.drain()
121
+ except (ConnectionError, OSError) as err:
122
+ self._mark_offline()
123
+ raise PA2ConnectionError("Device went offline while sending command.") from err
124
+
125
+ # Wait for the background loop to resolve the future
126
+ if wait_for_response:
127
+ return await future
128
+ return ""
129
+
130
+ async def send_asyncget(self, path: str):
131
+ """Send a fire-and-forget request, often used for polling meters."""
132
+ self._ensure_online()
133
+
134
+ cmd = f'asyncget "{path}"\r\n'
135
+
136
+ if not self._writer:
137
+ raise PA2ConnectionError("Writer is not available. Connection may be closed.")
138
+
139
+ try:
140
+ self._writer.write(cmd.encode("utf-8"))
141
+ await self._writer.drain()
142
+ except (ConnectionError, OSError) as err:
143
+ self._mark_offline()
144
+ raise PA2ConnectionError("Device went offline while sending asyncget.") from err
145
+
146
+ def subscribe(self, path: str, callback: Callable):
147
+ """Register a callback for unsolicited state pushes (subr)."""
148
+ self._subscriptions[path] = callback
149
+
150
+ async def send_sub(self, path: str):
151
+ """Tell the device to start pushing updates for a path."""
152
+ self._ensure_online()
153
+
154
+ if not self._writer:
155
+ raise PA2ConnectionError("Writer is not available. Connection may be closed.")
156
+
157
+ cmd = f'sub "{path}"\r\n'
158
+ try:
159
+ self._writer.write(cmd.encode("utf-8"))
160
+ await self._writer.drain()
161
+ except (ConnectionError, OSError) as err:
162
+ self._mark_offline()
163
+ raise PA2ConnectionError("Device went offline while subscribing.") from err
164
+
165
+ async def _read_loop(self):
166
+ """Continuously read lines from the device and route them."""
167
+ try:
168
+ if self._reader is None:
169
+ raise PA2ConnectionError("Not connected to device.")
170
+ while not self._reader.at_eof():
171
+ line = await self._reader.readline()
172
+ if not line:
173
+ break
174
+
175
+ text = line.decode("utf-8").strip()
176
+ if not text:
177
+ continue
178
+
179
+ match = LINE_RE.match(text)
180
+ if match:
181
+ verb, path, value = match.groups()
182
+ # Debug print to see what the device is actually sending back
183
+ # print(f"DEBUG: RX: {verb} '{path}' '{value}'")
184
+
185
+ # Normalize the path for matching (strip trailing slashes)
186
+ normalized_path = path.rstrip("\\")
187
+
188
+ if verb in ("get", "setr", "error"):
189
+ # Match against normalized keys
190
+ for key in list(self._pending_requests.keys()):
191
+ if key.rstrip("\\") == normalized_path:
192
+ if verb == "error":
193
+ self._pending_requests[key].set_exception(
194
+ PA2ConnectionError(f"Err: {value}")
195
+ )
196
+ else:
197
+ self._pending_requests[key].set_result(value)
198
+ del self._pending_requests[key]
199
+ break
200
+
201
+ # Handle unsolicited pushes and polled meter returns
202
+ if verb in ("subr", "setr", "get", "set"):
203
+ if path in self._subscriptions:
204
+ self._subscriptions[path](value)
205
+ except asyncio.CancelledError:
206
+ pass
207
+ except Exception as e:
208
+ self._mark_offline(f"Connection dropped: {e}")
209
+ _LOGGER.error("Error in PA2 read loop: %s", e)
210
+ else:
211
+ self._mark_offline("Connection closed by device.")
@@ -0,0 +1,36 @@
1
+ """Constants for pydbxdriverack."""
2
+
3
+ PORT = 19272
4
+ DEFAULT_USER = "administrator"
5
+ DEFAULT_PASS = "administrator"
6
+
7
+ # Protocol verbs
8
+ VERB_GET = "get"
9
+ VERB_ASYNCGET = "asyncget"
10
+ VERB_SET = "set"
11
+ VERB_SUB = "sub"
12
+
13
+ # Paths
14
+ PATH_DEVICE_NAME = r"\\Node\SV\DeviceName"
15
+ PATH_CLASS_NAME = r"\\Node\AT\Class_Name"
16
+ PATH_SOFTWARE_VER = r"\\Node\AT\Software_Version"
17
+
18
+ PATH_NUM_BANDS = r"\\Preset\Crossover\AT\NumBands"
19
+ PATH_MONO_SUB = r"\\Preset\Crossover\AT\MonoSub"
20
+
21
+ PATH_CURRENT_PRESET = r"\\Storage\Presets\SV\CurrentPreset"
22
+ PATH_RECALL_PRESET = "\\\\Storage\\Presets\\SV\\Recall\\"
23
+ PATH_PRESET_NAME_PREFIX = r"\\Storage\Presets\SV\Name_"
24
+
25
+ PATH_AFS_ENABLE = r"\\Preset\Afs\SV\AFS"
26
+ PATH_AFS_MODE = r"\\Preset\Afs\SV\FilterMode"
27
+
28
+ # Available bands and channels
29
+ BANDS = ("Low", "Mid", "High")
30
+ CHANNELS = ("Left", "Right")
31
+
32
+ # Protocol values
33
+ VAL_ON = "On"
34
+ VAL_OFF = "Off"
35
+ VAL_TRUE = "1"
36
+ VAL_FALSE = "0"
@@ -0,0 +1,244 @@
1
+ """Data models for interacting with the PA2 Device."""
2
+
3
+ from typing import Any, Callable, Optional
4
+
5
+ from .connection import PA2Connection, PA2ConnectionError
6
+ from .const import (
7
+ CHANNELS,
8
+ PATH_AFS_ENABLE,
9
+ PATH_AFS_MODE,
10
+ PATH_CLASS_NAME,
11
+ PATH_CURRENT_PRESET,
12
+ PATH_DEVICE_NAME,
13
+ PATH_MONO_SUB,
14
+ PATH_NUM_BANDS,
15
+ PATH_PRESET_NAME_PREFIX,
16
+ PATH_RECALL_PRESET,
17
+ PATH_SOFTWARE_VER,
18
+ VAL_FALSE,
19
+ VAL_OFF,
20
+ VAL_ON,
21
+ VAL_TRUE,
22
+ )
23
+
24
+
25
+ class PA2Device:
26
+ """Class that represents the dbx DriveRack PA2 data and state."""
27
+
28
+ def __init__(self, connection: PA2Connection):
29
+ """Initialize the device API."""
30
+ self._conn = connection
31
+
32
+ # Hardware Info
33
+ self.device_name: str = "Unknown"
34
+ self.class_name: str = "Unknown"
35
+ self.software_version: str = "Unknown"
36
+
37
+ # Topology
38
+ self.num_bands: int = 2
39
+ self.mono_sub: bool = False
40
+
41
+ # Live State
42
+ self.current_preset: Optional[int] = None
43
+
44
+ # Expose subscriptions to allow HA to hook into state pushes
45
+ self._conn.subscribe(PATH_CURRENT_PRESET, self._handle_preset_change)
46
+
47
+ async def async_update_info(self):
48
+ """Fetch base hardware info and topology. Call this once after connecting."""
49
+ self.device_name = str(await self._conn.request("get", PATH_DEVICE_NAME))
50
+ self.class_name = str(await self._conn.request("get", PATH_CLASS_NAME))
51
+ self.software_version = str(await self._conn.request("get", PATH_SOFTWARE_VER))
52
+
53
+ try:
54
+ self.num_bands = int(str(await self._conn.request("get", PATH_NUM_BANDS)))
55
+ except Exception:
56
+ pass
57
+
58
+ try:
59
+ mono_str = await self._conn.request("get", PATH_MONO_SUB)
60
+ self.mono_sub = mono_str == VAL_TRUE
61
+ except Exception:
62
+ pass
63
+
64
+ # Ensure we subscribe to current preset changes
65
+ await self._conn.send_sub(PATH_CURRENT_PRESET)
66
+
67
+ def _handle_preset_change(self, value: str):
68
+ """Internal callback for when the preset changes live."""
69
+ if value and value.isdigit():
70
+ self.current_preset = int(value)
71
+
72
+ # --- PRESETS ---
73
+
74
+ async def async_get_preset_names(self, max_slots: int = 50) -> dict[int, str]:
75
+ """Discover preset names by querying slot sequences until an error."""
76
+ presets: dict[int, str] = {}
77
+ for slot in range(1, max_slots + 1):
78
+ try:
79
+ name = str(await self._conn.request("get", f"{PATH_PRESET_NAME_PREFIX}{slot}"))
80
+ if name:
81
+ presets[slot] = name
82
+ except Exception:
83
+ # Reached end of preset list
84
+ break
85
+ return presets
86
+
87
+ async def async_recall_preset(self, slot: int):
88
+ """Recall a preset and wait for confirmation."""
89
+ await self._conn.request("set", PATH_RECALL_PRESET, str(slot), False)
90
+
91
+ # --- MUTES ---
92
+
93
+ async def async_set_mute(self, band: str, channel: str, is_muted: bool):
94
+ """Mute or unmute a specific band/channel.
95
+ band: 'Low', 'Mid', 'High'
96
+ channel: 'Left', 'Right'
97
+ """
98
+ val = VAL_TRUE if is_muted else VAL_FALSE
99
+ path = rf"\\Preset\OutputGains\SV\{band}{channel}OutputMute"
100
+ await self._conn.request("set", path, val)
101
+
102
+ async def async_unmute_all(self):
103
+ """Unmute all configured output bands."""
104
+ bands_to_unmute = ["High", "Low"]
105
+ if self.num_bands == 3 or (self.num_bands == 2 and self.mono_sub):
106
+ bands_to_unmute.append("Mid")
107
+
108
+ for band in bands_to_unmute:
109
+ for channel in CHANNELS:
110
+ path = rf"\\Preset\OutputGains\SV\{band}{channel}OutputMute"
111
+ await self._conn.request("set", path, VAL_FALSE)
112
+
113
+ async def async_get_mute_state(self, band: str, channel: str) -> bool:
114
+ """Poll the current mute state of a band/channel."""
115
+ path = rf"\\Preset\OutputGains\SV\{band}{channel}OutputMute"
116
+ resp = await self._conn.request("get", path)
117
+ return bool(resp == VAL_ON)
118
+
119
+ # --- ADVANCED FEEDBACK SUPPRESSION (AFS) ---
120
+
121
+ async def async_get_afs_status(self) -> dict:
122
+ """Fetch current AFS status and mode."""
123
+ enabled = await self._conn.request("get", PATH_AFS_ENABLE)
124
+ mode = await self._conn.request("get", PATH_AFS_MODE)
125
+ return {"enabled": enabled == VAL_ON, "mode": mode}
126
+
127
+ async def async_set_afs_enabled(self, enabled: bool):
128
+ """Enable or disable AFS."""
129
+ val = VAL_ON if enabled else VAL_OFF
130
+ await self._conn.request("set", PATH_AFS_ENABLE, val)
131
+
132
+ async def async_set_afs_mode(self, mode: str):
133
+ """Set AFS mode: 'Live' or 'Fixed'."""
134
+ if mode not in ["Live", "Fixed"]:
135
+ raise ValueError("Mode must be 'Live' or 'Fixed'")
136
+ await self._conn.request("set", PATH_AFS_MODE, mode)
137
+
138
+ async def async_monitor_afs_filters(self, callback: Callable):
139
+ """
140
+ Listen for live AFS filter allocations (Larsen effect).
141
+ Callback signature: func(band_index: int, frequency: str, active: bool)
142
+ """
143
+ for i in range(1, 13):
144
+ # The exact path the device uses for the frequency parameter
145
+ path = rf"\\Preset\Afs\SV\Band_{i}_Frequency"
146
+
147
+ # We use a factory function to properly bind the loop variable 'i'
148
+ def create_cb(band_idx):
149
+ def cb(val):
150
+ # If the value is "-", the filter has been cleared
151
+ active = val != "-"
152
+ callback(band_idx, val, active)
153
+
154
+ return cb
155
+
156
+ # Register the callback in the connection router
157
+ self._conn.subscribe(path, create_cb(i))
158
+
159
+ # Subscribe to the path so the device knows to push updates to us
160
+ await self._conn.send_sub(path)
161
+
162
+ # --- METERS & LIMITERS ---
163
+
164
+ def _meter_path(self, type_: str, band: str = "", channel: str = "") -> str:
165
+ if type_ == "input":
166
+ return rf"\\Preset\InputMeters\SV\{channel}Input" + "\\"
167
+ if type_ == "output":
168
+ return rf"\\Preset\OutputMeters\SV\{band}{channel}Output" + "\\"
169
+ if type_ == "clip":
170
+ return rf"\\Preset\InputMeters\SV\{channel}InputClip" + "\\"
171
+ if type_ == "limiter":
172
+ return rf"\\Preset\{band} Outputs Limiter\SV\ThresholdMeter" + "\\"
173
+ return ""
174
+
175
+ async def async_poll_meters(self) -> dict[str, dict[str, Any]]:
176
+ """Fire asyncget requests for all relevant meters to poll current status."""
177
+ paths = [
178
+ self._meter_path("input", channel="Left"),
179
+ self._meter_path("input", channel="Right"),
180
+ self._meter_path("clip", channel="Left"),
181
+ self._meter_path("clip", channel="Right"),
182
+ ]
183
+
184
+ active_bands = ["High", "Low"]
185
+ if self.num_bands == 3 or (self.num_bands == 2 and self.mono_sub):
186
+ active_bands.append("Mid")
187
+
188
+ for band in active_bands:
189
+ paths.append(self._meter_path("limiter", band=band))
190
+ for channel in CHANNELS:
191
+ paths.append(self._meter_path("output", band=band, channel=channel))
192
+
193
+ # Because we poll continuously in HA, we just send asyncget.
194
+ # State drops into the read_loop. To capture them cleanly in this function,
195
+ # you can temporarily hook futures or just use the device subscriptions.
196
+ # Below is a quick sync-wrapper pattern to fetch all at once.
197
+
198
+ results: dict[str, str] = {}
199
+ for path in paths:
200
+ try:
201
+ # We use synchronous 'get' here for a reliable API return format.
202
+ # In a high-speed HA UI, you would bind callbacks to connection.subscribe
203
+ # and use connection.send_asyncget(path).
204
+ results[path] = str(await self._conn.request("get", path))
205
+ except PA2ConnectionError:
206
+ results[path] = "error"
207
+
208
+ return self._parse_meter_results(results, active_bands)
209
+
210
+ def _parse_meter_results(
211
+ self, raw_data: dict[str, str], active_bands: list[str]
212
+ ) -> dict[str, dict[str, Any]]:
213
+ """Organize flat path strings into a readable dict."""
214
+ data: dict[str, dict[str, Any]] = {
215
+ "input": {
216
+ "Left": {"level": None, "clip": False},
217
+ "Right": {"level": None, "clip": False},
218
+ },
219
+ "output": {},
220
+ "limiter": {},
221
+ }
222
+
223
+ # Populate input meters
224
+ for ch in CHANNELS:
225
+ data["input"][ch]["level"] = raw_data.get(self._meter_path("input", channel=ch))
226
+ data["input"][ch]["clip"] = (
227
+ raw_data.get(self._meter_path("clip", channel=ch)) == VAL_TRUE
228
+ )
229
+
230
+ # Populate output meters and limiters
231
+ for band in active_bands:
232
+ data["output"][band] = {}
233
+ for ch in CHANNELS:
234
+ data["output"][band][ch] = raw_data.get(
235
+ self._meter_path("output", band=band, channel=ch)
236
+ )
237
+
238
+ lim_val = raw_data.get(self._meter_path("limiter", band=band))
239
+ data["limiter"][band] = {
240
+ "triggered": lim_val != "Under" and lim_val is not None,
241
+ "raw_value": lim_val,
242
+ }
243
+
244
+ return data
@@ -0,0 +1,61 @@
1
+ """UDP Discovery protocol for DBX DriveRack PA2."""
2
+
3
+ import asyncio
4
+ import logging
5
+ from typing import Callable
6
+
7
+ from .const import PORT
8
+
9
+ _LOGGER = logging.getLogger(__name__)
10
+
11
+
12
+ class PA2DiscoveryProtocol(asyncio.DatagramProtocol):
13
+ """Protocol to listen for DriveRack discovery broadcasts."""
14
+
15
+ def __init__(self, on_device_found: Callable):
16
+ self.on_device_found = on_device_found
17
+
18
+ def connection_made(self, transport):
19
+ self.transport = transport
20
+
21
+ def datagram_received(self, data, addr):
22
+ msg = data.decode("utf-8", errors="ignore").strip()
23
+ # Ensure it identifies as dbxDriveRackPA2
24
+ if (
25
+ 'get "\\\\Node\\AT\\Class_Name" "dbxDriveRackPA2"' in msg
26
+ or 'get "\\Node\\AT\\Class_Name" "dbxDriveRackPA2"' in msg
27
+ ):
28
+ self.on_device_found(addr[0])
29
+
30
+
31
+ async def async_discover_devices(timeout: int = 3) -> list[str]:
32
+ """Broadcast UDP packets and return a list of discovered IPs."""
33
+ loop = asyncio.get_running_loop()
34
+ discovered_ips = set()
35
+
36
+ def _on_found(ip: str):
37
+ discovered_ips.add(ip)
38
+
39
+ # Setup the UDP listener/broadcaster
40
+ transport, protocol = await loop.create_datagram_endpoint(
41
+ lambda: PA2DiscoveryProtocol(_on_found), local_addr=("0.0.0.0", 0), allow_broadcast=True
42
+ )
43
+
44
+ try:
45
+ # Fire the required UDP probes to the PA2 port
46
+ queries = [
47
+ b"delay 100\n",
48
+ b"get \\Node\\AT\\Class_Name\n",
49
+ b"get \\Node\\AT\\Instance_Name\n",
50
+ b"get \\Node\\AT\\Software_Version\n",
51
+ ]
52
+
53
+ for q in queries:
54
+ transport.sendto(q, ("<broadcast>", PORT))
55
+
56
+ # Wait for devices to reply
57
+ await asyncio.sleep(timeout)
58
+ finally:
59
+ transport.close()
60
+
61
+ return list(discovered_ips)
@@ -0,0 +1,123 @@
1
+ Metadata-Version: 2.4
2
+ Name: pydbxdriverack
3
+ Version: 0.1.0
4
+ Summary: Python library for connecting and managing DBX DriveRack devices
5
+ Project-URL: Homepage, https://github.com/matteogheza/pydbxdriverack
6
+ Project-URL: Documentation, https://github.com/matteogheza/pydbxdriverack?tab=readme-ov-file#usage
7
+ Project-URL: Repository, https://github.com/matteogheza/pydbxdriverack.git
8
+ Project-URL: Issues, https://github.com/matteogheza/pydbxdriverack/issues
9
+ Author-email: Matteo Gheza <me@matteogheza.it>
10
+ License-Expression: GPL-3.0-only
11
+ Keywords: audio,connection,dbx,device,driverack,dsp
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Other Audience
15
+ Classifier: Intended Audience :: System Administrators
16
+ Classifier: Natural Language :: English
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Programming Language :: Python :: 3.14
24
+ Classifier: Programming Language :: Python :: 3.15
25
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
26
+ Classifier: Topic :: System :: Hardware :: Hardware Drivers
27
+ Requires-Python: >=3.9
28
+ Description-Content-Type: text/markdown
29
+
30
+ # pydbxdriverack
31
+
32
+ Python library for discovering, connecting to, and controlling dbx DriveRack PA2 devices.
33
+
34
+ ## Features
35
+
36
+ - Discover PA2 devices on the local network (UDP broadcast)
37
+ - Connect and authenticate over TCP
38
+ - Read device info (name, class, firmware)
39
+ - Recall presets and list preset names
40
+ - Control output mutes
41
+ - Read meter and limiter data
42
+ - Monitor AFS (Advanced Feedback Suppression) state
43
+
44
+ ## 🤖 AI Assistance Disclosure
45
+
46
+ Parts of this project were developed with the assistance of Artificial Intelligence. AI tools were utilized as an accelerator to:
47
+ * Co-author and refine segments of the core library code.
48
+ * Help parse and structure raw data payloads during the reverse-engineering of the original hardware protocol.
49
+ * Transform early functional prototypes into a structured, production-ready package architecture.
50
+ * Generate test suites (`pytest`) and draft structural documentation.
51
+
52
+ While AI assisted in speeding up the development workflow, all architectural decisions, hardware testing, protocol verification, and final code reviews were executed entirely by the author to ensure reliability and accuracy.
53
+
54
+ ---
55
+
56
+ ## Installation
57
+
58
+ Install from source:
59
+
60
+ ```bash
61
+ pip install .
62
+ ```
63
+
64
+ For development dependencies:
65
+
66
+ ```bash
67
+ pip install -e .
68
+ pip install pytest pytest-cov pytest-asyncio black ruff mypy pre-commit
69
+ ```
70
+
71
+ ## Quick Start
72
+
73
+ ```python
74
+ import asyncio
75
+
76
+ from pydbxdriverack.connection import PA2Connection
77
+ from pydbxdriverack.device import PA2Device
78
+ from pydbxdriverack.discovery import async_discover_devices
79
+
80
+
81
+ async def main() -> None:
82
+ devices = await async_discover_devices(timeout=3)
83
+ if not devices:
84
+ print("No DriveRack PA2 found")
85
+ return
86
+
87
+ host = devices[0]
88
+ conn = PA2Connection(host, password="administrator")
89
+ await conn.connect()
90
+
91
+ try:
92
+ pa2 = PA2Device(conn)
93
+ await pa2.async_update_info()
94
+
95
+ print("Connected to:", pa2.device_name)
96
+ print("Firmware:", pa2.software_version)
97
+
98
+ # Example: unmute all outputs
99
+ await pa2.async_unmute_all()
100
+ finally:
101
+ await conn.disconnect()
102
+
103
+
104
+ if __name__ == "__main__":
105
+ asyncio.run(main())
106
+ ```
107
+
108
+ ## Running Tests
109
+
110
+ ```bash
111
+ pytest
112
+ ```
113
+
114
+ ## Project Layout
115
+
116
+ - `src/pydbxdriverack/connection.py`: TCP connection and protocol request handling
117
+ - `src/pydbxdriverack/device.py`: High-level device API
118
+ - `src/pydbxdriverack/discovery.py`: UDP discovery
119
+ - `src/pydbxdriverack/const.py`: Protocol constants and paths
120
+
121
+ ## License
122
+
123
+ GPL-3.0-only
@@ -0,0 +1,8 @@
1
+ pydbxdriverack/__init__.py,sha256=UWrcGjVb6-l59y0unsfGnB_TZXsdcCHP5f3ZsGj78Xw,466
2
+ pydbxdriverack/connection.py,sha256=BMHmnP4kJVxaQLXWhzXV_dhY8X-JawzElgYgezpqAHk,8166
3
+ pydbxdriverack/const.py,sha256=BVBQnB0gNPWcqiJ4gdwoj91zn1GpVOlso3XfB7VKuac,888
4
+ pydbxdriverack/device.py,sha256=PrXsPBzYnLJXM1lomU0tWRzX8Tuh844mG2j8zoSvkKw,9312
5
+ pydbxdriverack/discovery.py,sha256=Vz7XVfBldcMWvyfBo3zKGJ-HkZBwxnO9XFLKsmlbgDk,1800
6
+ pydbxdriverack-0.1.0.dist-info/METADATA,sha256=OPGsczRh0uNNFwewpRno26rPdYbcJlGXum-K4jOkwpE,3823
7
+ pydbxdriverack-0.1.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
8
+ pydbxdriverack-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.30.1
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any