Endpoints and Autodetection
LUCIDAC Endpoints are URL-like notations for addressing the connection to a LUCIDAC device. The concept is described in the Firmware docs and is similar to the NI VISA resource syntax
Which endpoint notation and protocol support is available depends on the client implementation. Lucipy understands the following endpoints:
serial:/- USB Serial terminals speaking JSONLtcp:/- “Raw” TCP/IP speaking JSONLsim:/- A shorthand to the integrated simulator
For convenience, the client code allows for autodetection of the endpoint using MDNS/Zeroconf. This works by making an instance without providing the endpoint:
>>> from lucipy import LUCIDAC
>>> hc = LUCIDAC() # this will trigger the autodetection
Direct access to the underlying API should not be neccessary, but is possible
with import lucipy.detect. The folling reference shows the exposed
functions.
Note
As a design philosophy in lucipy, there are no dependencies. Therefore, autodetection will only work if you have the zeroconf and/or pySerial libraries installed.
If these dependencies are not installed, the code will print warnings suggesting
you to install them in order to make autodetection work. That means that a line
such as hc = LUCIDAC() will not work without an endpoint argument to the
LUCIDAC() call.
Code refererence
This is a small interactive command line script for discovering/detecting LUCIDACs. It will look for the Teensy Microcontroller (Hybrid Controller) both directly connected over USB Serial Device as well as Network services announced by MDNS/Zeroconf over the network (local IPv4 broadcast domain). The network lookup happens typically within a few hundred milliseconds. If you want to wait for more then one device, use the –all option.
- class lucipy.detect.Endpoint(endpoint)[source]
A LUCIDAC endpoint is actually something like an URI. There is no proper URI object in python so this is where we are.
cf. urllib.urlparse @see synchc.endpoint2socket
>>> Endpoint.fromDevice("/dev/ttyACM0") Endpoint("serial://dev/ttyACM0") >>> Endpoint.fromJSONL("localhost", 1234).parse().hostname 'localhost'
- lucipy.detect.can_resolve(hostname, target_ip: str | None = None) str | None[source]
gethostbyname but without the exceptions, i.e. with a boolean representation of the return value
- lucipy.detect.can_resolve_to(hostname, expected_ip: str)[source]
Checks whether the host system can resolve a given (zeroconf) DNS name
- lucipy.detect.detect_usb_teensys() list[Endpoint][source]
Yields all found endpoints on local system using serial.tools.list_ports, requires pyserial
- lucipy.detect.detect_network_teensys(zeroconf_timeout=500) list[Endpoint][source]
Yields all endpoints in the local broadcast domain using Zeroconf, requires python zeroconf package
- lucipy.detect.detect(single=False, prefer_network=True, zeroconf_timeout=500) Endpoint | None | list[Endpoint][source]
Yields or returns possible endpoints.
- Parameters:
single – Return only one found instance or None, if nothing found. If this option is False, this function will return an iterator, i.e. behave as generator.
zeroconf_timeout – Maximum search time: How long to wait for zeroconf answers, in milliseconds. Set to 0 or None for unlimited search.
prefer_network – Yield network result first. Typically a TCP/IP connection is faster and more reliable then the USBSerial.