Skip to main content

Thorlabs APT protocol

A functional implementation of the Thorlabs APT protocol

Outgoing messages

Outgoing messages are python functions in the top level namespace. Each function has parameters relevant to the particular message, all messages have source and dest parameters. The function names are lower-cased from the names in the documentation and the "MGMSG_" has been omitted. These functions return bytes, they do not send the message over the transport layer

For example:

>>> import thorlabs_apt_protocol as apt
>>> 
>>> apt.mot_move_home(source=1, dest=0x50 ,chan_ident=1)
b'C\x04\x01\x00P\x01'
>>> apt.mot_move_absolute(source=1, dest=0x50, chan_ident=1, position=2048)
b'S\x04\x06\x00\xd0\x01\x01\x00\x00\x08\x00\x00'

Incoming messages

Functions which allow for parsing bytes into dictionaries are also provided, but are not imported into the top level namespace by default. The recommended way of parsing is to use the provided Unpacker object.

This object takes a file-like object (such as a pyserial Serial instance) and provides a generator to parse the incomming messages. If no file object is provided, and internal BytesIO instance is used, and can be provided with bytes via the feed method. The generator yields namedtuple instances.

Usage with pyserial:

>>> import thorlabs_apt_protocol as apt
>>> import serial
>>> 
>>> port = serial.Serial("/dev/ttyUSB0", 115200, rtscts=True, timeout=0.1)
>>> port.rts = True
>>> port.reset_input_buffer()
>>> port.reset_output_buffer()
>>> port.rts = False
>>> port.write(apt.hw_no_flash_programming(source=1, dest=0x50))
>>> unpacker = apt.Unpacker(port)
>>> for msg in unpacker:
...     print(msg)
... 
>>> 

On Windows, you must toggle a driver setting to make the COM port appear:

Within Device Manager, right click on the APT device (under USB devices), and go to Properties. On the Advanced tab, check the box that says Load VCP (VCP stands for Virtual COM Port). Unplug and replug the USB cable to make it load the COM Port.

If the Advanced tab does not appear, I was able to use FTDI's FT_PROG. With all other Thorlabs programs not running, click Devices > Scan for devices. Review over the provided ID information to ensure that you are editing the correct device, FTDI provides serial communication for many different devices from several manufacturers, it is very possible you have multiple devices which show up. Under the Hardware Specific, uncheck the Load D2XX box. This box is a bit of a misnomer, as it really means "Load only D2XX", as when unchecked the D2XX driver (which the Thorlabs provided programs use) is still loaded, but the VCP driver is also loaded. Click Devices > Program.

Upon reconnecting (unplug and replug USB) the Advanced tab should appear as above, but the Load VCP driver option may not be checked yet.

Release files for thorlabs-apt-protocol 29.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for thorlabs-apt-protocol 29.0.0
File Size Uploaded
thorlabs-apt-protocol-29.0.0.tar.gz 24.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for thorlabs-apt-protocol 29.0.0
File Interpreter ABI Platform
thorlabs_apt_protocol-29.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 46.7 kB

Release files / thorlabs-apt-protocol-29.0.0.tar.gz

Download URL thorlabs-apt-protocol-29.0.0.tar.gz
Size 24.3 kB
Tags Source
SHA-256 checksum
How to use checksums
caf99ff88043d2f070196903c09299bc8d8ec9da063be4c3c3832fe829772d32
BLAKE2b-256 checksum
How to use checksums
602c7f2b14dbb15c2dce463fd780a7391d5612227cb5973cad157e3526dcf562
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.26.0

Release files / thorlabs_apt_protocol-29.0.0-py3-none-any.whl

Download URL thorlabs_apt_protocol-29.0.0-py3-none-any.whl
Size 22.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4dad11e1b4131e4b235ab939949d9f8ee12c518a93184f495fc30fcd3cffaf22
BLAKE2b-256 checksum
How to use checksums
b1928c7c5d91fdc4229f0dc58370c540508f05dc4335747c6ce19079ba7e2bb9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.26.0

Release history Release notifications | RSS feed

This release

29.0.0 This release

2 release files

25.1.0

2 release files

25.0.1

2 release files

25.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page