Docs - Examples - scan-query
This example scans a whole nework range (1-254) searching for ATEM switchers and reads some settings:
$ python3 scan-query.py -h
[Tue Nov 24 22:28:52 2020] PyATEMMax demo script: scan-query
usage: scan-query.py [-h] [-m MIXEFFECT] range
positional arguments:
range IP address range (e.g) 192.168.1
optional arguments:
-h, --help show this help message and exit
-m MIXEFFECT, --mixeffect MIXEFFECT
select mix effect (0/1), default 0
It tries to connect to all the addresses in the range, reads a few settings and reports result.
$ python3 scan-query.py 192.168.1
[Tue Nov 24 22:30:07 2020] PyATEMMax demo script: scan-query
[Tue Nov 24 22:30:07 2020] Scanning network range 192.168.1.* for ATEM switchers
[Tue Nov 24 22:30:19 2020] ATEM Television Studio HD found at 192.168.1.111 - Master Volume: 0.0dB - PVW: CAM1 - PGM: HPDK
[Tue Nov 24 22:30:33 2020] FINISHED: 1 ATEM switchers found.
Code walkthrough
Start with the usual initial steps (explained in Examples)
Start working with the switcher:
First, the ATEMMax
object is created and the hit count is initialized:
After that, a loop starts for values (1-254):
- The corresponding ip address is built
- The script tries to connect to the switcher and shows a message if the connection could be established. See the parameters in
waitForConnection()
infinite=False
means we don’t want to wait forever. The library will use the default wait time.waitForFullHandshake=False
means we want to stop waiting as soon as the first message has been received from the switcher (because we’re doing ascan
, we just care about connectivity, not data)
- If this first wait succeeds it means we received a response to the initial connection request.
- At this point we can keep on waiting for the complete reception of the data snapshot from the switcher.
infinite=False
means we don’t want to wait forever. The library will use the default wait time.waitForFullHandshake
isTrue
by default, which means we want to wait until the whole set of switcher settings has been received.
- Once the switcher data has been received, data can be read and displayed