DATADEMON TUNNEL / PREVIEW

Choose a task.Follow the steps.

Install the agent and sign in with ddemon login for personal use. Open a guide below. Replace example paths, email addresses and UPPERCASE placeholders with your own values.

Test real hardware from cloud CI

Serial + GPIO · your hardware

Run your device test in a cloud job: talk to the board over serial, trigger a configured GPIO line, and check the board's response.

Before you start Connect your serial board, controller or instrument to an approved source, and configure a Linux GPIO bank if your test uses pins. Use suitable wiring and updated agents. Cloud CI also needs CI hardware access enabled at the edge and a verified Linux x86-64 job image. Manual GitHub Actions runs passed on a Pi 1B and Uno; check compatibility and fixture safety for your own hardware. The tested direct-wire fixture needs supervision because its inactive state on power loss is unverified. Hardware and CI-runner production qualification remain pending.

  1. Publish the two bench resources

    Choose the serial asset from the gateway's approved inventory. The GPIO shortcut selects its sole approved bank; with multiple banks, use the exact asset selector.

    Paired owner computer
    ddemon discover --device SOURCE_DEVICE
    Paired owner computer
    ddemon publish SERIAL_ASSET --from SOURCE_DEVICE --name lab-uart
    Paired owner computer
    ddemon publish gpio --from SOURCE_DEVICE --name lab-gpio
  2. Create a separate CI key for each resource

    On a personal account, use the primary device; on a business account, use an owner or admin. Store each shown-once value in your CI secret store.

    Primary device or business owner/admin
    ddemon keys create lab-uart --name ci-serial
    Primary device or business owner/admin
    ddemon keys create lab-gpio --name ci-gpio
  3. Run Python in your CI job

    Install your device test, its dependencies and the agent in the job image. Supply DATADEMON_SERIAL_KEY and DATADEMON_GPIO_KEY from your CI secret store. Save your test as tests/check_device.py.

    Linux CI job
    python tests/check_device.py

    Python runs in the CI job and calls DataDemon CLI commands to open serial access and control GPIO. The gateway exposes the configured hardware; your Python test supplies the device protocol and pass/fail assertions.

    Copy a working Python example

    Pulse a line. Read the board's response. This example uses the Uno HIL1 demo firmware at 115200 baud, 8N1. It arms input D2, pulses the approved enable GPIO line for 100 ms, then requires a matching serial EVENT. Use a suitable, approved circuit with an inactive rest state.

    Use Python 3.11 or newer and install pyserial in your job image:

    Install the Python dependency
    python -m pip install pyserial

    Copy the complete script into tests/check_device.py. Match GPIO_LINE, UNO_PIN and BAUD_RATE to your fixture. For another board, replace the ARM, EVENT and DISARM checks with its actual serial protocol.

    tests/check_device.py · complete script
    """Save as tests/check_device.py. Requires Python 3.11+, pyserial and ddemon."""
    
    import json
    import os
    from pathlib import Path
    import secrets
    import select
    import signal
    import subprocess
    import sys
    import tempfile
    import time
    
    import serial
    
    # Match your approved GPIO bank and the Uno HIL1 demo firmware.
    GPIO_LINE = "enable"
    UNO_PIN = "D2"
    BAUD_RATE = 115200
    PULSE_MS = 100
    
    
    def check_device():
        serial_env = cli_environment("DATADEMON_SERIAL_KEY")
        gpio_env = cli_environment("DATADEMON_GPIO_KEY")
        with tempfile.TemporaryDirectory(prefix="hardware-ci-") as directory:
            link = Path(directory).resolve() / "board.serial"
            access = subprocess.Popen(
                ["ddemon", "access", "--foreground", "--fail-closed",
                 "--link", str(link), "--session-timeout", "180", "--json"],
                env=serial_env, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL,
                start_new_session=True,
            )
            ready = False
            try:
                wait_ready(access, link)
                ready = True
                with serial.Serial(str(link), BAUD_RATE, timeout=0.1,
                                   write_timeout=1) as port:
                    gpio(gpio_env, "read")  # Require the inactive rest state.
                    run_id = secrets.token_hex(8)
                    armed = f"ARMED {run_id}".encode()
                    expect(port, access, armed, seconds=8,
                           send=f"ARM {run_id} pin={UNO_PIN}\n".encode(),
                           ignore=(b"READY HIL1",))
                    gpio(gpio_env, "pulse", str(PULSE_MS))  # Send once.
                    expect(port, access,
                           f"EVENT {run_id} pin={UNO_PIN} seq=1".encode(),
                           ignore=(armed,))
                    gpio(gpio_env, "read")  # Confirm the line is back at rest.
                    port.write(b"DISARM\n")
                    expect(port, access, b"DISARMED")
            finally:
                stop_serial(access, link, ready)
        print("PASS: GPIO pulse produced the expected serial response")
    
    
    # Helpers: separate keys, bounded waits, checked results and owned cleanup.
    def cli_environment(key_name):
        key = os.environ[key_name].strip()
        if not key:
            raise RuntimeError("Both resource keys are required")
        env = {name: value for name, value in os.environ.items()
               if name not in {"DATADEMON_SERIAL_KEY", "DATADEMON_GPIO_KEY",
                               "DATADEMON_CI_KEY"}}
        env["DATADEMON_CI_KEY"] = key
        return env
    
    
    def gpio(env, operation, *arguments):
        process = subprocess.Popen(
            ["ddemon", "gpio", operation, GPIO_LINE, *arguments, "--json"],
            env=env, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL,
            start_new_session=True,
        )
        try:
            output, _ = process.communicate(timeout=45)
        except BaseException:
            # A packaged CLI may include a launcher and a child runtime. Retire
            # the owned group on timeout/cancellation without repeating its pulse.
            try:
                os.killpg(process.pid, signal.SIGTERM)
            except ProcessLookupError:
                pass
            try:
                process.communicate(timeout=5)
            except subprocess.TimeoutExpired:
                try:
                    os.killpg(process.pid, signal.SIGKILL)
                except ProcessLookupError:
                    pass
                process.communicate(timeout=2)
            finally:
                # A launcher can exit before an unresponsive child. Retire any
                # remaining member of this owned group even after the launcher ends.
                try:
                    os.killpg(process.pid, signal.SIGKILL)
                except ProcessLookupError:
                    pass
            raise
        if process.returncode:
            raise RuntimeError("GPIO access failed; the pulse will not be retried")
        data = json.loads(output)
        if (data.get("operation") != operation or data.get("line") != GPIO_LINE
                or data.get("state") != "inactive"
                or data.get("lease_closed") is not True
                or data.get("restoration_verified") is not True
                or (operation == "pulse" and data.get("duration_ms") != PULSE_MS)):
            raise RuntimeError("GPIO result or lease release was not confirmed")
    
    
    def wait_ready(access, link):
        deadline = time.monotonic() + 35
        line = bytearray()
        while time.monotonic() < deadline:
            if not select.select([access.stdout], [], [], 0.1)[0]:
                continue
            byte = os.read(access.stdout.fileno(), 1)
            if not byte or len(line) >= 8192:
                raise RuntimeError("Serial access ended before readiness")
            line.extend(byte)
            if byte != b"\n":
                continue
            event = json.loads(line)
            line.clear()
            if event.get("event") == "ready":
                if event.get("data", {}).get("endpoint") != str(link):
                    raise RuntimeError("Serial endpoint does not match")
                return
            if event.get("event") in {"error", "changed", "stopped"}:
                raise RuntimeError("Serial access failed before readiness")
        raise RuntimeError("Serial readiness timed out")
    
    
    def expect(port, access, expected, seconds=10, send=None, ignore=()):
        deadline, next_send = time.monotonic() + seconds, 0
        line = bytearray()
        while time.monotonic() < deadline:
            if access.poll() is not None:
                raise RuntimeError("Serial access ended during the test")
            if send is not None and time.monotonic() >= next_send:
                port.write(send)  # ARM is safe to repeat while the Uno resets.
                next_send = time.monotonic() + 0.5
            line.extend(port.read_until(b"\n", size=256))
            if len(line) > 256:
                raise RuntimeError("Serial response is too long")
            if not line.endswith(b"\n"):
                continue
            received = bytes(line).rstrip(b"\r\n")
            line.clear()
            if received == expected:
                return
            if received not in ignore:
                raise RuntimeError("Unexpected serial response")
        raise RuntimeError("Expected serial response did not arrive")
    
    
    def stop_serial(access, link, ready):
        if access.poll() is None:
            try:
                os.killpg(access.pid, signal.SIGINT)
            except ProcessLookupError:
                pass
        try:
            output, _ = access.communicate(timeout=30)
        except subprocess.TimeoutExpired:
            try:
                os.killpg(access.pid, signal.SIGKILL)
            except ProcessLookupError:
                pass
            access.communicate(timeout=2)
            raise RuntimeError("Serial cleanup timed out") from None
        if ready:
            events = [json.loads(line) for line in output.splitlines() if line]
            stopped = [event for event in events if event.get("event") == "stopped"]
            if (access.returncode not in {0, 130} or len(stopped) != 1
                    or stopped[0].get("data", {}).get("reason") != "interrupted"
                    or any(event.get("event") in {"error", "changed", "ready"}
                           for event in events)
                    or link.exists() or link.is_symlink()):
                raise RuntimeError("Serial release was not confirmed")
    
    
    def interrupted(_signum, _frame):
        raise KeyboardInterrupt
    
    
    if __name__ == "__main__":
        signal.signal(signal.SIGTERM, interrupted)
        try:
            check_device()
        except RuntimeError as error:
            print(f"FAIL: {error}", file=sys.stderr)
            sys.exit(1)
        except (Exception, KeyboardInterrupt):
            print("FAIL: hardware access, test or cleanup failed", file=sys.stderr)
            sys.exit(1)
    

    Run the command above with both CI keys supplied. Success prints PASS: GPIO pulse produced the expected serial response. Missing or incorrect replies, failed access and unconfirmed cleanup return a nonzero exit code. The pulse is sent once and is never retried.

    CLI commands your Python test calls

    Start serial access as a subprocess. Pass only the serial key as DATADEMON_CI_KEY for that subprocess; remove both test key variables from its environment. Replace SERIAL_LINK with a vacant path in a private temporary directory.

    Started by Python, using the serial key
    ddemon access --foreground --fail-closed --link SERIAL_LINK --json

    Wait for the JSON ready event, then open SERIAL_LINK in Python, for example with pyserial. Keep the serial subprocess running while the test calls GPIO commands. Pass only the GPIO key as DATADEMON_CI_KEY to each GPIO subprocess, again removing both test key variables.

    Called by Python, using the GPIO key
    ddemon gpio pulse GPIO_LINE 100 --json

    Choose GPIO_LINE from the bank's line list and use a suitable, approved circuit. This requests a 100 ms pulse. Keys select resources automatically; GPIO access covers the whole configured bank. Serial and GPIO use separate leases, without an atomic reservation.

Result and cleanup Your Python test must close the port, stop and wait for the serial subprocess, and confirm release on success, failure or cancellation. Each GPIO operation releases its own lease. Busy, offline, failed access or failed cleanup must fail the job. Keep keys in trusted runtime steps, out of images and logs. Use the full key ID from ddemon keys list with ddemon keys revoke KEY_ID to retire access.

Try serial or GPIO from a paired computer first

Choose a vacant SERIAL_LINK path in a private temporary directory. Keep this command running; after its JSON ready event, your separate Python test can open that local port.

Paired macOS or Linux computer
ddemon access lab-uart --foreground --fail-closed --link SERIAL_LINK --json

Close the port and press Ctrl-C in the access terminal when finished. Inspect the bank's line names and sampled states before choosing a line:

Paired owner computer
ddemon gpio lines --resource lab-gpio

For temporary browser serial access, run ddemon share serial on the attached computer. To receive a temporary share as a local port, run the printed ddemon serial connect SHARE_URL command. Windows receiving needs a Pico Serial Hub or approved virtual-COM pair.

Reach a private service

Remote Desktop or one TCP endpoint

Before you start Both computers are paired to your account. For this example, Remote Desktop is already enabled on the source and you have its normal login credentials.

  1. Enable background operation once

    Run on both paired computers
    ddemon background enable
  2. Publish the desktop privately

    Computer with Remote Desktop
    ddemon publish rdp --name desktop
  3. Connect from your other computer

    Your other paired computer
    ddemon access desktop

    Use the generated local endpoint and .rdp file with your installed client. Opening the client requires your confirmation or an explicit option. DataDemon does not enable Remote Desktop or handle its credentials.

When you are done These named services run in the background after the command exits. ddemon access desktop --stop stops your local endpoint; ddemon unpublish desktop removes the source route.

Use a web app or another TCP service instead

For a private web app, publish its origin and then access its name from a paired computer:

Computer running the app
ddemon publish http://localhost:3000 --name my-app
Your other paired computer
ddemon access my-app

For another TCP service, publish one fixed tcp://HOST:PORT origin. Direct stock-client TCP/RDP access needs an enabled edge port pool and explicit network admission.

Send or receive files

Browser downloads and Linux uploads

Before you start Install the agent and sign in on the computer holding the files. The file chooser is Preview and requires a compatible installed agent. If your agent does not offer it, use the terminal alternative below.

  1. Open the file sharing window

    Computer holding the file
    ddemon share files --ui

    Choose a file or folder, the audience and expiry, then create the link. Keep the agent terminal open and this device online.

  2. Send the generated URL

    Copy and send the link yourself. If you chose a specific person, they sign in with that email and download in their browser.

When you are done Press Ctrl-C to close access. The link expires after one hour by default.

Use a file path in the terminal

Replace the path and recipient email with your own. The recipient signs in with that email.

Computer holding the file
ddemon share files ./report.pdf --recipient reviewer@example.com
Receive browser uploads on Linux

Choose an existing Linux folder on a supported local filesystem. The recipient can upload new files through the printed URL.

Linux computer receiving files
ddemon receive ./incoming --recipient reviewer@example.com

Keep the terminal open; press Ctrl-C to stop. Saved files remain. Public and background receiving are unavailable.

Use an SFTP client instead

Requires an enabled edge SFTP pool. Replace the example network with your recipient's public IPv4 address and /32.

Computer holding the folder
ddemon share sftp ./shared --recipient reviewer@example.com --allowed-cidr 203.0.113.44/32

The recipient signs in and uses the printed SFTP instructions. Ctrl-C closes access.

Print somewhere else

One selected printer · Preview

Before you start The printer is installed and works locally. Physical printer and native-client qualification remain limited.

  1. Find your printer's ID

    Computer connected to the printer
    ddemon printers
  2. Share browser printing with one person

    Computer connected to the printer
    ddemon share printer --printer PRINTER_ID --recipient reviewer@example.com --no-ipp
  3. Send the generated URL

    The recipient signs in and submits their document to that queue. DataDemon uses the installed printer and driver.

When you are done Press Ctrl-C to close access. The link also expires automatically. Closing a share does not recall a document already sent to the printer.

Use native printing

Omit --no-ipp to include authenticated native IPPS setup. This needs compatible, qualified printer capabilities. Keep the native setup URI and files private.

Use resources on another computer

Publish an approved app from your laptop

Before you start The source is paired to your account, has HTTP supervision locally enabled, and is running the app. Only the primary device can approve or revoke paired devices.

  1. Choose the source and its app

    Your paired laptop
    ddemon devices
    Your paired laptop
    ddemon discover --device SOURCE_DEVICE

    This reads the source's approved inventory. Choose HTTP_ASSET from that result.

  2. Publish it privately

    Your paired laptop
    ddemon publish HTTP_ASSET --from SOURCE_DEVICE --name lab-app
  3. Open the app

    Any paired computer
    ddemon access lab-app

When you are done The source keeps serving after your laptop disconnects. Run ddemon unpublish lab-app from a paired computer to remove the route.

Pair the source first

Start enrollment on the new computer, then approve its printed code on your signed-in primary device:

New source computer
ddemon enroll
Signed-in primary device
ddemon devices approve CODE

Pairing alone does not enable resource supervision. On the source, use ddemon help setup to review the locally approved resource categories.