Feature request: Otii TCP API

I would like to see which channels are enabled in the recording.

enabled_channels = recording.get_enabled_channels(device.id)

I try to see which channels have data using this code.

# Define all possible Otii channels manually
available_channels = [
              "mc", "mp", "mv",  # Main channels
              "ac", "ap", "av",  # ADC channels
              "sp", "sn",        # Sense+ / Sense-
              "vb", "vj",        # Voltage channels
              "tp",              # Temperature
              "rx",              # UART logs
              "i1", "i2"         # Digital inputs
          ]
for channel_name in available_channels:
    try:
        info = recording.get_channel_info(device.id, channel_name)
        if not info:
            print(f"Warning: No info found for channel {channel_name}. Skipping...")
            continue
    except Exception as e:
        print(f"Error retrieving channel info for '{channel_name}': {e}")
        continue

But i get broken pipe errors.

channel  mc
/snapshot/client/common/lib/model/recordingRequests.js:534
        const [measurementData] = recording.measurements.filter(m => m.id === measurement.id);
                                                                                          ^

TypeError: Cannot read properties of undefined (reading 'id')
    at /snapshot/client/common/lib/model/recordingRequests.js:534:91
    at Array.filter (<anonymous>)
    at RecordingRequests.getChannelInfo (/snapshot/client/common/lib/model/recordingRequests.js:534:58)
    at TcpServer._TcpServer_handleRequest (/snapshot/client/common/lib/model/tcpserver.js:723:85)
    at TcpServer.onData (/snapshot/client/common/lib/model/tcpserver.js:192:95)
    at Object.onClientData (/snapshot/client/common/lib/model/tcpserver.js:181:22)
    at Socket.<anonymous> (/snapshot/client/common/lib/model/createServer.js:19:21)
    at Socket.emit (node:events:537:28)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)

Node.js v18.5.0
the recording in device service is <otii_tcp_client.recording.Recording object at 0x7f8de33680>
Returning license and logging out...
An error occurred while returning license and logging out: [Errno 32] Broken pipe

In this example channel “ap” and “av” where enabled, but it would be nice if I don’t have to store this for every recording.

Hi Jarne,

Welcome to the forum.

The broken pipe is caused by a bug in the tcp api error handling.
We will fix this in the next Otii release.

Adding a get_enabled_channels() api to the recording is a very good idea and we will add it to our list of future features.

Best regards,
Andreas