Skip to main content

Your first capture

Connect, open a demo device, capture, count the edges, close. No hardware needed: the program runs against se254, a demo device every server offers.

Make sure a server is running first: either the ScanaStudio application, or the scanastudio-server binary it installs, run on its own. Both are covered under Installation.

from ikalogic_scanastudio import ScanaStudio, Trigger

with ScanaStudio.connect() as server:
print(server.info)

for device in server.devices():
print(" ", device.key, device.name)

workspace = server.create("se254")
print(f"\nopened {workspace.device_name} "
f"with {len(workspace.channels)} channels")

last = workspace.capture.run(
samples=1_000_000,
sample_rate=25_000_000,
trigger=Trigger.immediate(),
)
seconds = workspace.capture.seconds(last)
print(f"captured {last} samples ({seconds:.3f} s) "
f"at {workspace.capture.sample_rate} S/s")

edges = sum(1 for _ in workspace.data.transitions(channel=0))
print(f"channel 0 holds {edges} transitions")

workspace.close()

Run it:

python first_capture.py

What it prints​

On the se254 demo device:

ScanaStudio 6.0.23 (cd798ee), protocol 8
se254 SE254 (demo)
sq25 SQ25 (demo)
sq50 SQ50 (demo)
sq100 SQ100 (demo)
sq200 SQ200 (demo)
sp209 SP209 (demo)
sp209i SP209I (demo)
sp259 SP259 (demo)
sp259i SP259I (demo)
sp1018 SP1018 (demo)
sp1036 SP1036 (demo)
sp1054 SP1054 (demo)

opened SE254 (demo) with 4 channels
captured 1000000 samples (0.040 s) at 25000000 S/s
channel 0 holds 216 transitions

The transition count changes on every run, since a demo device generates a new pseudo-random signal each time. The version line shows the server you run, and any hardware connected to it is listed before the demo devices.

What just happened​

  1. connect() connected to the server at ws://127.0.0.1:4911 and checked that both sides speak the same protocol version.
  2. devices() listed what the server can open: your hardware, plus the demo devices.
  3. create("se254") created a workspace: a session that owns the device, the capture, and everything attached to it.
  4. capture.run() armed the acquisition and waited for it. It returns the index of the last sample captured.
  5. transitions(0) read the edges on channel 0. Bulk data is only transferred when you read it.
  6. close() ended the workspace on the server.
A demo device generates noise

se254 produces pseudo-random signals, not protocol traffic. It exercises the whole path (capture, decode, measure, export), which makes it useful for writing and testing a script, but it will not show you a real I²C address.

Closing the connection is not closing the workspace

workspace.close() ends the session on the server. Disconnecting does not: the capture keeps running and you can attach to it later. See Headless datalogger.

Next​