Skip to content

NKTPDLL¤

NKTDLL (Interface) ¤

NKTDLL(equipment: Equipment)

              flowchart LR
              msl.equipment_resources.nkt.nktpdll.NKTDLL[NKTDLL]
              msl.equipment.schema.Interface[Interface]

                              msl.equipment.schema.Interface --> msl.equipment_resources.nkt.nktpdll.NKTDLL
                


              click msl.equipment_resources.nkt.nktpdll.NKTDLL href "" "msl.equipment_resources.nkt.nktpdll.NKTDLL"
              click msl.equipment.schema.Interface href "" "msl.equipment.schema.Interface"
            

Wrapper around the NKTPDLL.dll SDK from NKT Photonics.

Regular-expression patterns that are used to select this Resource when connect() is called.

manufacturer=r"^NKT"
model=r"^NKTDLL$"

Parameters:

Name Type Description Default
equipment Equipment

An Equipment instance.

required

A Connection instance supports the following properties for the NKT wrapper.

Connection Properties:

Name Type Description
sdk_path str

The path to the SDK library. Default: "NKTPDLL.dll"

open_port bool

Whether to automatically open the port. Default: True

auto bool

Whether to open the port with bus scanning. Default: True

live bool

Whether to open the port in live mode. Default: True

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
def __init__(self, equipment: Equipment) -> None:
    """Wrapper around the `NKTPDLL.dll` SDK from [NKT Photonics](https://www.nktphotonics.com/).

    Regular-expression patterns that are used to select this Resource when
    [connect()][msl.equipment.schema.Equipment.connect] is called.
    ```python
    manufacturer=r"^NKT"
    model=r"^NKTDLL$"
    ```

    Args:
        equipment: An [Equipment][] instance.

    A [Connection][msl.equipment.schema.Connection] instance supports the following _properties_
    for the NKT wrapper.

    Attributes: Connection Properties:
        sdk_path (str): The path to the SDK library. _Default: `"NKTPDLL.dll"`_
        open_port (bool): Whether to automatically open the port. _Default: `True`_
        auto (bool): Whether to open the port with bus scanning. _Default: `True`_
        live (bool): Whether to open the port in live mode. _Default: `True`_
    """
    super().__init__(equipment)

    assert equipment.connection is not None  # noqa: S101
    address = equipment.connection.address
    self._portname: bytes = address.encode()

    p = equipment.connection.properties
    _load_sdk(p.get("sdk_path", _path), self)
    assert NKTDLL._SDK is not None  # noqa: S101

    self._sdk: CDLL = NKTDLL._SDK
    if p.get("open_port", True):
        NKTDLL.open_ports(address, auto=p.get("auto", True), live=p.get("live", True))

close_ports staticmethod ¤

close_ports(*ports: str) -> None

Close the specified port(s).

Parameters:

Name Type Description Default
ports str

The name(s) of the port(s) to close. If not specified, close all opened ports. Port names are case sensitive.

()
Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
506
507
508
509
510
511
512
513
514
515
516
517
518
@staticmethod
def close_ports(*ports: str) -> None:
    """Close the specified port(s).

    Args:
        ports: The name(s) of the port(s) to close. If not specified, close all opened ports.
            Port names are case sensitive.
    """
    if NKTDLL._SDK is None:
        return

    _names = b",".join(port.encode() for port in ports)
    NKTDLL._SDK.closePorts(_names)

device_create ¤

device_create(device_id: int, *, wait_ready: bool) -> None

Creates a device in the internal device list.

If the open_ports function has been called with live=True then the kernel immediately starts to monitor the device.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
wait_ready bool

False means don't wait for the device to be ready. True means to wait up to 2 seconds for the device to complete its analyse cycle. (All standard registers being successfully read)

required
Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
565
566
567
568
569
570
571
572
573
574
575
576
577
def device_create(self, device_id: int, *, wait_ready: bool) -> None:
    """Creates a device in the internal device list.

    If the [open_ports][msl.equipment_resources.nkt.nktpdll.NKTDLL.open_ports] function has
    been called with `live=True` then the kernel immediately starts to monitor the device.

    Args:
        device_id: The device id (module address).
        wait_ready: `False` means don't wait for the device to be ready. `True` means to
            wait up to 2 seconds for the device to complete its analyse cycle.
            (All standard registers being successfully read)
    """
    self._sdk.deviceCreate(self._portname, device_id, int(bool(wait_ready)))

device_exists ¤

device_exists(device_id: int) -> bool

Checks if a specific device already exists in the internal device list.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required

Returns:

Type Description
bool

Whether the device exists.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
579
580
581
582
583
584
585
586
587
588
589
590
def device_exists(self, device_id: int) -> bool:
    """Checks if a specific device already exists in the internal device list.

    Args:
        device_id: The device id (module address).

    Returns:
        Whether the device exists.
    """
    exists = c_ubyte(0)
    self._sdk.deviceExists(self._portname, device_id, exists)
    return bool(exists.value)

device_get_all_types staticmethod ¤

device_get_all_types(*ports: str, size: int = 255) -> dict[str, dict[str, int]]

Returns all device types (module types) from the internal device list.

Parameters:

Name Type Description Default
ports str

A port or multiple ports. If not specified then the get_open_ports method is called.

()
size int

The maximum number of bytes that the device list can be.

255

Returns:

Type Description
dict[str, dict[str, int]]

The port names are the keys and each value is dict with the module type as the keys and its corresponding device ID as the value.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
@staticmethod
def device_get_all_types(*ports: str, size: int = 255) -> dict[str, dict[str, int]]:
    """Returns all device types (module types) from the internal device list.

    Args:
        ports: A port or multiple ports. If not specified then the
            [get_open_ports][msl.equipment_resources.nkt.nktpdll.NKTDLL.get_open_ports]
            method is called.
        size: The maximum number of bytes that the device list can be.

    Returns:
        The port names are the keys and each value is [dict][] with the
            module type as the keys and its corresponding device ID as the value.
    """
    if NKTDLL._SDK is None:
        msg = "NKTError: You must first call NKT.load_sdk()"
        raise RuntimeError(msg)

    if not ports:
        opened_ports = [port.encode() for port in NKTDLL.get_open_ports()]
    else:
        opened_ports = [port.encode() for port in ports]

    out: dict[str, dict[str, int]] = {}
    length = c_ubyte(size)
    types = create_string_buffer(size)
    for port in opened_ports:
        NKTDLL._SDK.deviceGetAllTypes(port, types, length)
        key = port.decode()
        out[key] = {}
        for dev_id, typ in enumerate(types.raw):
            if typ != 0:
                out[key][f"0x{typ:02X}"] = dev_id
    return out

device_get_boot_loader_version ¤

device_get_boot_loader_version(device_id: int) -> int

Returns the boot-loader version (int) for a given device id.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated read.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required

Returns:

Type Description
int

The boot-loader version.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
def device_get_boot_loader_version(self, device_id: int) -> int:
    """Returns the boot-loader version (int) for a given device id.

    It is not necessary to open the port, create the device or register before
    using this function, since it will do a dedicated read.

    Args:
        device_id: The device id (module address).

    Returns:
        The boot-loader version.
    """
    version = c_ushort(0)
    self._sdk.deviceGetBootloaderVersion(self._portname, device_id, version)
    return version.value

device_get_boot_loader_version_str ¤

device_get_boot_loader_version_str(device_id: int) -> str

Returns the boot-loader version (string) for a given device id.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated read.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required

Returns:

Type Description
str

The boot-loader version.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
def device_get_boot_loader_version_str(self, device_id: int) -> str:
    """Returns the boot-loader version (string) for a given device id.

    It is not necessary to open the port, create the device or register before
    using this function, since it will do a dedicated read.

    Args:
        device_id: The device id (module address).

    Returns:
        The boot-loader version.
    """
    size = c_ubyte(255)
    version = create_string_buffer(size.value)
    self._sdk.deviceGetBootloaderVersionStr(self._portname, device_id, version, size)
    return bytes(version.value).decode()

device_get_error_code ¤

device_get_error_code(device_id: int) -> int

Returns the error code for a given device id.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated read.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required

Returns:

Type Description
int

The error code.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
def device_get_error_code(self, device_id: int) -> int:
    """Returns the error code for a given device id.

    It is not necessary to open the port, create the device or register before
    using this function, since it will do a dedicated read.

    Args:
        device_id: The device id (module address).

    Returns:
        The error code.
    """
    error_code = c_ushort(0)
    self._sdk.deviceGetErrorCode(self._portname, device_id, error_code)
    return error_code.value

device_get_firmware_version ¤

device_get_firmware_version(device_id: int) -> int

Returns the firmware version (int) for a given device id.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated read.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required

Returns:

Type Description
int

The firmware version.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
def device_get_firmware_version(self, device_id: int) -> int:
    """Returns the firmware version (int) for a given device id.

    It is not necessary to open the port, create the device or register before
    using this function, since it will do a dedicated read.

    Args:
        device_id: The device id (module address).

    Returns:
        The firmware version.
    """
    version = c_ushort(0)
    self._sdk.deviceGetFirmwareVersion(self._portname, device_id, version)
    return version.value

device_get_firmware_version_str ¤

device_get_firmware_version_str(device_id: int) -> str

Returns the firmware version (string) for a given device id.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated read.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required

Returns:

Type Description
str

The firmware version.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
def device_get_firmware_version_str(self, device_id: int) -> str:
    """Returns the firmware version (string) for a given device id.

    It is not necessary to open the port, create the device or register before
    using this function, since it will do a dedicated read.

    Args:
        device_id: The device id (module address).

    Returns:
        The firmware version.
    """
    size = c_ubyte(255)
    version = create_string_buffer(size.value)
    self._sdk.deviceGetFirmwareVersionStr(self._portname, device_id, version, size)
    return bytes(version.value).decode()

device_get_live ¤

device_get_live(device_id: int) -> bool

Returns the internal device live status for a specific device id.

Requires the port being already opened with the open_ports function and the device being already created, either automatically or with the device_create function.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required

Returns:

Type Description
bool

Whether live mode is enabled.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
def device_get_live(self, device_id: int) -> bool:
    """Returns the internal device live status for a specific device id.

    Requires the port being already opened with the
    [open_ports][msl.equipment_resources.nkt.nktpdll.NKTDLL.open_ports]
    function and the device being already created, either automatically or with the
    [device_create][msl.equipment_resources.nkt.nktpdll.NKTDLL.device_create] function.

    Args:
        device_id: The device id (module address).

    Returns:
        Whether live mode is enabled.
    """
    live_mode = c_ubyte(0)
    self._sdk.deviceGetLive(self._portname, device_id, live_mode)
    return bool(live_mode.value)

device_get_mode ¤

device_get_mode(device_id: int) -> DeviceMode

Returns the internal device mode for a specific device id.

Requires the port being already opened with the open_ports function and the device being already created, either automatically or with the device_create function.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required

Returns:

Type Description
DeviceMode

The device mode type.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
def device_get_mode(self, device_id: int) -> DeviceMode:
    """Returns the internal device mode for a specific device id.

    Requires the port being already opened with the
    [open_ports][msl.equipment_resources.nkt.nktpdll.NKTDLL.open_ports]
    function and the device being already created, either automatically or with the
    [device_create][msl.equipment_resources.nkt.nktpdll.NKTDLL.device_create] function.

    Args:
        device_id: The device id (module address).

    Returns:
        The device mode type.
    """
    dev_mode = c_ubyte(0)
    self._sdk.deviceGetMode(self._portname, device_id, dev_mode)
    return DeviceMode(dev_mode.value)

device_get_module_serial_number_str ¤

device_get_module_serial_number_str(device_id: int) -> str

Returns the module serial number (string) for a given device id.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated read.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required

Returns:

Type Description
str

The serial number.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
def device_get_module_serial_number_str(self, device_id: int) -> str:
    """Returns the module serial number (string) for a given device id.

    It is not necessary to open the port, create the device or register before
    using this function, since it will do a dedicated read.

    Args:
        device_id: The device id (module address).

    Returns:
        The serial number.
    """
    size = c_ubyte(255)
    serial = create_string_buffer(size.value)
    self._sdk.deviceGetModuleSerialNumberStr(self._portname, device_id, serial, size)
    return bytes(serial.value).decode()

device_get_part_number_str ¤

device_get_part_number_str(device_id: int) -> str

Returns the part number for a given device id.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated read.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required

Returns:

Type Description
str

The part number.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
def device_get_part_number_str(self, device_id: int) -> str:
    """Returns the part number for a given device id.

    It is not necessary to open the port, create the device or register before
    using this function, since it will do a dedicated read.

    Args:
        device_id: The device id (module address).

    Returns:
        The part number.
    """
    size = c_ubyte(255)
    part = create_string_buffer(size.value)
    self._sdk.deviceGetPartNumberStr(self._portname, device_id, part, size)
    return bytes(part.value).decode()

device_get_pcb_serial_number_str ¤

device_get_pcb_serial_number_str(device_id: int) -> str

Returns the PCB serial number (string) for a given device id.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated read.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required

Returns:

Type Description
str

The part number.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
def device_get_pcb_serial_number_str(self, device_id: int) -> str:
    """Returns the PCB serial number (string) for a given device id.

    It is not necessary to open the port, create the device or register before
    using this function, since it will do a dedicated read.

    Args:
        device_id: The device id (module address).

    Returns:
        The part number.
    """
    size = c_ubyte(255)
    serial = create_string_buffer(size.value)
    self._sdk.deviceGetPCBSerialNumberStr(self._portname, device_id, serial, size)
    return bytes(serial.value).decode()

device_get_pcb_version ¤

device_get_pcb_version(device_id: int) -> int

Returns the PCB version for a given device id.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated read.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required

Returns:

Type Description
int

The PCB version number.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
def device_get_pcb_version(self, device_id: int) -> int:
    """Returns the PCB version for a given device id.

    It is not necessary to open the port, create the device or register before
    using this function, since it will do a dedicated read.

    Args:
        device_id: The device id (module address).

    Returns:
        The PCB version number.
    """
    version = c_ubyte(0)
    self._sdk.deviceGetPCBVersion(self._portname, device_id, version)
    return version.value

device_get_status_bits ¤

device_get_status_bits(device_id: int) -> int

Returns the status bits for a given device id.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated read.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required

Returns:

Type Description
int

The status bits.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
def device_get_status_bits(self, device_id: int) -> int:
    """Returns the status bits for a given device id.

    It is not necessary to open the port, create the device or register before
    using this function, since it will do a dedicated read.

    Args:
        device_id: The device id (module address).

    Returns:
        The status bits.
    """
    status = c_ushort(0)
    self._sdk.deviceGetStatusBits(self._portname, device_id, status)
    return status.value

device_get_type ¤

device_get_type(device_id: int) -> int

Returns the module type for a specific device id.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated read.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required

Returns:

Type Description
int

The module type.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
def device_get_type(self, device_id: int) -> int:
    """Returns the module type for a specific device id.

    It is not necessary to open the port, create the device or register before
    using this function, since it will do a dedicated read.

    Args:
        device_id: The device id (module address).

    Returns:
        The module type.
    """
    dev_type = c_ubyte(0)
    self._sdk.deviceGetType(self._portname, device_id, dev_type)
    return dev_type.value

device_remove ¤

device_remove(device_id: int) -> None

Remove a specific device from the internal device list.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
809
810
811
812
813
814
815
def device_remove(self, device_id: int) -> None:
    """Remove a specific device from the internal device list.

    Args:
        device_id: The device id (module address).
    """
    self._sdk.deviceRemove(self._portname, device_id)

device_remove_all ¤

device_remove_all() -> None

Remove all devices from the internal device list.

No confirmation is given, the list is simply cleared.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
817
818
819
820
821
822
def device_remove_all(self) -> None:
    """Remove all devices from the internal device list.

    No confirmation is given, the list is simply cleared.
    """
    self._sdk.deviceRemoveAll(self._portname)

device_set_live ¤

device_set_live(device_id: int, *, enabled: bool) -> None

Sets the internal device live status for a specific device id (module address).

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
enabled bool

Whether to enable (True) or disable (False) live status.

required
Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
824
825
826
827
828
829
830
831
def device_set_live(self, device_id: int, *, enabled: bool) -> None:
    """Sets the internal device live status for a specific device id (module address).

    Args:
        device_id: The device id (module address).
        enabled: Whether to enable (`True`) or disable (`False`) live status.
    """
    self._sdk.deviceSetLive(self._portname, device_id, int(enabled))

disconnect ¤

disconnect() -> None

Disconnect from the port.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
833
834
835
836
837
def disconnect(self) -> None:  # pyright: ignore[reportImplicitOverride]
    """Disconnect from the port."""
    if hasattr(self, "_address") and self._portname:
        self.close_ports(self._portname.decode())
        self._portname = b""

get_all_ports staticmethod ¤

get_all_ports(size: int = 255) -> list[str]

Returns a list of all ports.

Parameters:

Name Type Description Default
size int

The maximum size of the string buffer to fetch the results.

255

Returns:

Type Description
list[str]

A list of port names.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
@staticmethod
def get_all_ports(size: int = 255) -> list[str]:
    """Returns a list of all ports.

    Args:
        size: The maximum size of the string buffer to fetch the results.

    Returns:
        A list of port names.
    """
    if NKTDLL._SDK is None:
        msg = "NKTError: You must first call NKT.load_sdk()"
        raise RuntimeError(msg)

    length = c_ushort(size)
    names = create_string_buffer(size)
    NKTDLL._SDK.getAllPorts(names, length)
    return [name for name in bytes(names.value).decode().split(",") if name]

get_legacy_bus_scanning staticmethod ¤

get_legacy_bus_scanning() -> bool

Get the bus-scanning mode.

Returns:

Type Description
bool

True if in legacy mode, False if in normal mode.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
870
871
872
873
874
875
876
877
878
879
880
881
@staticmethod
def get_legacy_bus_scanning() -> bool:
    """Get the bus-scanning mode.

    Returns:
        `True` if in legacy mode, `False` if in normal mode.
    """
    if NKTDLL._SDK is None:
        msg = "NKTError: You must first call NKT.load_sdk()"
        raise RuntimeError(msg)

    return bool(NKTDLL._SDK.getLegacyBusScanning())

get_modules ¤

get_modules(size: int = 255) -> dict[str, int]

Returns all device types (module types) from the device.

Parameters:

Name Type Description Default
size int

The maximum number of bytes that the device list can be.

255

Returns:

Type Description
dict[str, int]

The module type as the keys and its corresponding device ID as the value.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
858
859
860
861
862
863
864
865
866
867
868
def get_modules(self, size: int = 255) -> dict[str, int]:
    """Returns all device types (module types) from the device.

    Args:
        size: The maximum number of bytes that the device list can be.

    Returns:
        The module type as the keys and its corresponding device ID as the value.
    """
    a = self._portname.decode()
    return NKTDLL.device_get_all_types(a, size=size)[a]

get_open_ports staticmethod ¤

get_open_ports(size: int = 255) -> list[str]

Returns a list of already-opened ports.

Parameters:

Name Type Description Default
size int

The maximum size of the string buffer to fetch the results.

255

Returns:

Type Description
list[str]

A list of port names that are already open.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
@staticmethod
def get_open_ports(size: int = 255) -> list[str]:
    """Returns a list of already-opened ports.

    Args:
        size: The maximum size of the string buffer to fetch the results.

    Returns:
        A list of port names that are already open.
    """
    if NKTDLL._SDK is None:
        msg = "NKTError: You must first call NKT.load_sdk()"
        raise RuntimeError(msg)

    length = c_ushort(size)
    names = create_string_buffer(size)
    NKTDLL._SDK.getOpenPorts(names, length)
    return [name for name in bytes(names.value).decode().split(",") if name]

get_port_error_msg ¤

get_port_error_msg() -> str

Retrieve error message for the port.

Returns:

Type Description
str

The error message. An empty string indicates no error.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
902
903
904
905
906
907
908
909
910
911
def get_port_error_msg(self) -> str:
    """Retrieve error message for the port.

    Returns:
        The error message. An empty string indicates no error.
    """
    length = c_ushort(255)
    msg = create_string_buffer(length.value)
    self._sdk.getPortErrorMsg(self._portname, msg, length)
    return bytes(msg.value).decode()

get_port_status ¤

get_port_status() -> PortStatus

Get the status of the port.

Returns:

Type Description
PortStatus

The port status.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
913
914
915
916
917
918
919
920
921
def get_port_status(self) -> PortStatus:
    """Get the status of the port.

    Returns:
        The port status.
    """
    status = c_ubyte(0)
    self._sdk.getPortStatus(self._portname, status)
    return PortStatus(status.value)

load_sdk staticmethod ¤

load_sdk(path: PathLike | None = None) -> None

Load the SDK.

Parameters:

Name Type Description Default
path PathLike | None

The path to NKTPDLL.dll. Reads from the NKTP_SDK_PATH environment variable if not specified.

None
Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
520
521
522
523
524
525
526
527
528
@staticmethod
def load_sdk(path: PathLike | None = None) -> None:
    """Load the SDK.

    Args:
        path: The path to `NKTPDLL.dll`. Reads from the `NKTP_SDK_PATH` environment
            variable if not specified.
    """
    _load_sdk(_path if not path else os.fsdecode(path))

open_ports staticmethod ¤

open_ports(*names: str, auto: bool = True, live: bool = True) -> None

Open the specified port(s).

Repeated calls to this function is allowed to reopen and/or rescan for devices.

Parameters:

Name Type Description Default
names str

If not specified then open all available ports are opened. Port names are case sensitive. Example port names are "AcoustikPort1", "COM6".

()
auto bool

If True then automatically start bus scanning and add the found devices in the internal device list. If False then bus scanning and device creation is not automatically handled. The port is automatically closed if no devices are found.

True
live bool

If True then keep all the found or created devices in live mode, which means the inter-bus kernel keeps monitoring all the found devices and their registers. Please note that this will keep the modules watchdog alive as long as the port is open. If False then disable continuous monitoring of the registers. No callback is possible on register changes, so you must call the register_read, register_write and register_write_read methods.

True
Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
@staticmethod
def open_ports(*names: str, auto: bool = True, live: bool = True) -> None:
    """Open the specified port(s).

    Repeated calls to this function is allowed to reopen and/or rescan for devices.

    Args:
        names: If not specified then open all available ports are opened. Port
            names are case sensitive. Example port names are `"AcoustikPort1"`, `"COM6"`.
        auto: If `True` then automatically start bus scanning and add the
            found devices in the internal device list. If `False` then
            bus scanning and device creation is not automatically handled. The
            port is automatically closed if no devices are found.
        live: If `True` then keep all the found or created devices in live
            mode, which means the inter-bus kernel keeps monitoring all the found
            devices and their registers. Please note that this will keep the modules
            watchdog alive as long as the port is open. If `False` then disable
            continuous monitoring of the registers. No callback is possible on register
            changes, so you must call the [register_read][msl.equipment_resources.nkt.nktpdll.NKTDLL.register_read],
            [register_write][msl.equipment_resources.nkt.nktpdll.NKTDLL.register_write] and
            [register_write_read][msl.equipment_resources.nkt.nktpdll.NKTDLL.register_write_read]
            methods.
    """
    if NKTDLL._SDK is None:
        msg = "NKTError: You must first call NKT.load_sdk()"
        raise RuntimeError(msg)

    _names = b",".join(name.encode() for name in names)
    NKTDLL._SDK.openPorts(_names, int(bool(auto)), int(bool(live)))

point_to_point_port_add ¤

point_to_point_port_add(port: PointToPoint) -> None

Creates or modifies a point-to-point port.

Parameters:

Name Type Description Default
port PointToPoint

A point-to-point port.

required
Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
def point_to_point_port_add(self, port: PointToPoint) -> None:
    """Creates or modifies a point-to-point port.

    Args:
        port: A point-to-point port.
    """
    self._sdk.pointToPointPortAdd(
        self._portname,
        port.host_address.encode(),
        port.host_port,
        port.client_address.encode(),
        port.client_port,
        port.protocol,
        port.ms_timeout,
    )

point_to_point_port_del ¤

point_to_point_port_del() -> None

Delete the point-to-point port.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
969
970
971
def point_to_point_port_del(self) -> None:
    """Delete the point-to-point port."""
    self._sdk.pointToPointPortDel(self._portname)

point_to_point_port_get ¤

point_to_point_port_get() -> PointToPoint

Retrieve the information about the point-to-point port setting.

Returns:

Type Description
PointToPoint

The information about the point-to-point port setting.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
def point_to_point_port_get(self) -> PointToPoint:
    """Retrieve the information about the point-to-point port setting.

    Returns:
        The information about the point-to-point port setting.
    """
    host_length = c_ubyte(255)
    host_address = create_string_buffer(host_length.value)
    host_port = c_ushort(0)
    client_length = c_ubyte(255)
    client_address = create_string_buffer(client_length.value)
    client_port = c_ushort(0)
    protocol = c_ubyte(0)
    ms_timeout = c_ubyte(0)
    self._sdk.pointToPointPortGet(
        self._portname,
        host_address,
        host_length,
        host_port,
        client_address,
        client_length,
        client_port,
        protocol,
        ms_timeout,
    )
    return PointToPoint(
        host_address=host_address.value.decode(),
        host_port=host_port.value,
        client_address=client_address.value.decode(),
        client_port=client_port.value,
        protocol=protocol.value,
        ms_timeout=ms_timeout.value,
    )

register_create ¤

register_create(
    device_id: int,
    reg_id: int,
    priority: int | RegisterPriority,
    data: int | RegisterData,
) -> None

Creates a register in the internal register list.

If the open_ports function has been called with live=True then the kernel immediately starts to monitor the register.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
priority int | RegisterPriority

The monitoring priority.

required
data int | RegisterData

The register data type. Not used internally but could be used in a common callback function to determine the data type.

required
Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
def register_create(
    self, device_id: int, reg_id: int, priority: int | RegisterPriority, data: int | RegisterData
) -> None:
    """Creates a register in the internal register list.

    If the [open_ports][msl.equipment_resources.nkt.nktpdll.NKTDLL.open_ports] function has
    been called with `live=True` then the kernel immediately starts to monitor the register.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
        priority: The monitoring priority.
        data: The register data type. Not used internally but could be used in a
            common callback function to determine the data type.
    """
    self._sdk.registerCreate(self._portname, device_id, reg_id, RegisterPriority(priority), RegisterData(data))

register_exists ¤

register_exists(device_id: int, reg_id: int) -> bool

Checks if a specific register already exists in the internal register list.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required

Returns:

Type Description
bool

Whether the register exists.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
def register_exists(self, device_id: int, reg_id: int) -> bool:
    """Checks if a specific register already exists in the internal register list.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).

    Returns:
        Whether the register exists.
    """
    exists = c_ubyte(0)
    self._sdk.registerExists(self._portname, device_id, reg_id, exists)
    return bool(exists.value)

register_get_all ¤

register_get_all(device_id: int) -> list[int]

Returns the register ids (register addresses) from the internal register list.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required

Returns:

Type Description
list[int]

The register ids.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
def register_get_all(self, device_id: int) -> list[int]:
    """Returns the register ids (register addresses) from the internal register list.

    Args:
        device_id: The device id (module address).

    Returns:
        The register ids.
    """
    size = c_ubyte(255)
    regs = create_string_buffer(size.value)
    self._sdk.registerGetAll(self._portname, device_id, regs, size)
    ids: list[int] = list(regs.value)
    return ids

register_read ¤

register_read(device_id: int, reg_id: int, index: int = -1) -> bytes

Reads a register value and returns the result.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated read.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
index int

Value index. Typically -1, but could be used to extract data from a specific position in the register. Index is byte counted.

-1

Returns:

Type Description
bytes

The register value.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
def register_read(self, device_id: int, reg_id: int, index: int = -1) -> bytes:
    """Reads a register value and returns the result.

    It is not necessary to open the port, create the device or register before
    using this function, since it will do a dedicated read.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
        index: Value index. Typically -1, but could be used to extract data from
            a specific position in the register. Index is byte counted.

    Returns:
        The register value.
    """
    size = c_ubyte(255)
    data = create_string_buffer(size.value)
    self._sdk.registerRead(self._portname, device_id, reg_id, data, size, index)
    return data.raw[: size.value]

register_read_ascii ¤

register_read_ascii(device_id: int, reg_id: int, index: int = -1) -> str

Reads an ascii string from the register.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated read.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
index int

Value index. Typically -1, but could be used to extract data from a specific position in the register. Index is byte counted.

-1

Returns:

Type Description
str

The ascii value.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
def register_read_ascii(self, device_id: int, reg_id: int, index: int = -1) -> str:
    """Reads an ascii string from the register.

    It is not necessary to open the port, create the device or register before
    using this function, since it will do a dedicated read.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
        index: Value index. Typically -1, but could be used to extract data from
            a specific position in the register. Index is byte counted.

    Returns:
        The ascii value.
    """
    size = c_ubyte(255)
    data = create_string_buffer(size.value)
    self._sdk.registerReadAscii(self._portname, device_id, reg_id, data, size, index)
    return bytes(data.value).decode()

register_read_f32 ¤

register_read_f32(device_id: int, reg_id: int, index: int = -1) -> float

Reads 32-bit float value from the register.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated read.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
index int

Value index. Typically -1, but could be used to extract data from a specific position in the register. Index is byte counted.

-1

Returns:

Type Description
float

The 32-bit float value.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
def register_read_f32(self, device_id: int, reg_id: int, index: int = -1) -> float:
    """Reads 32-bit float value from the register.

    It is not necessary to open the port, create the device or register before
    using this function, since it will do a dedicated read.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
        index: Value index. Typically -1, but could be used to extract data from
            a specific position in the register. Index is byte counted.

    Returns:
        The 32-bit float value.
    """
    data = c_float(0)
    self._sdk.registerReadF32(self._portname, device_id, reg_id, data, index)
    return data.value

register_read_f64 ¤

register_read_f64(device_id: int, reg_id: int, index: int = -1) -> float

Reads 64-bit double value from the register.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated read.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
index int

Value index. Typically -1, but could be used to extract data from a specific position in the register. Index is byte counted.

-1

Returns:

Type Description
float

The 64-bit double value.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
def register_read_f64(self, device_id: int, reg_id: int, index: int = -1) -> float:
    """Reads 64-bit double value from the register.

    It is not necessary to open the port, create the device or register before
    using this function, since it will do a dedicated read.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
        index: Value index. Typically -1, but could be used to extract data from
            a specific position in the register. Index is byte counted.

    Returns:
        The 64-bit double value.
    """
    data = c_double(0)
    self._sdk.registerReadF64(self._portname, device_id, reg_id, data, index)
    return data.value

register_read_s16 ¤

register_read_s16(device_id: int, reg_id: int, index: int = -1) -> int

Reads 16-bit signed short value from the register.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated read.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
index int

Value index. Typically -1, but could be used to extract data from a specific position in the register. Index is byte counted.

-1

Returns:

Type Description
int

The 16-bit signed short value.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
def register_read_s16(self, device_id: int, reg_id: int, index: int = -1) -> int:
    """Reads 16-bit signed short value from the register.

    It is not necessary to open the port, create the device or register before
    using this function, since it will do a dedicated read.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
        index: Value index. Typically -1, but could be used to extract data from
            a specific position in the register. Index is byte counted.

    Returns:
        The 16-bit signed short value.
    """
    data = c_short(0)
    self._sdk.registerReadS16(self._portname, device_id, reg_id, data, index)
    return data.value

register_read_s32 ¤

register_read_s32(device_id: int, reg_id: int, index: int = -1) -> int

Reads 32-bit signed long value from the register.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated read.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
index int

Value index. Typically -1, but could be used to extract data from a specific position in the register. Index is byte counted.

-1

Returns:

Type Description
int

The 32-bit signed long value.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
def register_read_s32(self, device_id: int, reg_id: int, index: int = -1) -> int:
    """Reads 32-bit signed long value from the register.

    It is not necessary to open the port, create the device or register before
    using this function, since it will do a dedicated read.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
        index: Value index. Typically -1, but could be used to extract data from
            a specific position in the register. Index is byte counted.

    Returns:
        The 32-bit signed long value.
    """
    data = c_long(0)
    self._sdk.registerReadS32(self._portname, device_id, reg_id, data, index)
    return data.value

register_read_s64 ¤

register_read_s64(device_id: int, reg_id: int, index: int = -1) -> int

Reads 64-bit signed long long value from the register.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated read.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
index int

Value index. Typically -1, but could be used to extract data from a specific position in the register. Index is byte counted.

-1

Returns:

Type Description
int

The 64-bit signed long long value.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
def register_read_s64(self, device_id: int, reg_id: int, index: int = -1) -> int:
    """Reads 64-bit signed long long value from the register.

    It is not necessary to open the port, create the device or register before
    using this function, since it will do a dedicated read.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
        index: Value index. Typically -1, but could be used to extract data from
            a specific position in the register. Index is byte counted.

    Returns:
        The 64-bit signed long long value.
    """
    data = c_longlong(0)
    self._sdk.registerReadS64(self._portname, device_id, reg_id, data, index)
    return data.value

register_read_s8 ¤

register_read_s8(device_id: int, reg_id: int, index: int = -1) -> int

Reads 8-bit signed char value from the register.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated read.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
index int

Value index. Typically -1, but could be used to extract data from a specific position in the register. Index is byte counted.

-1

Returns:

Type Description
int

The 8-bit signed char value.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
def register_read_s8(self, device_id: int, reg_id: int, index: int = -1) -> int:
    """Reads 8-bit signed char value from the register.

    It is not necessary to open the port, create the device or register before
    using this function, since it will do a dedicated read.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
        index: Value index. Typically -1, but could be used to extract data from
            a specific position in the register. Index is byte counted.

    Returns:
        The 8-bit signed char value.
    """
    data = c_byte(0)
    self._sdk.registerReadS8(self._portname, device_id, reg_id, data, index)
    return data.value

register_read_u16 ¤

register_read_u16(device_id: int, reg_id: int, index: int = -1) -> int

Reads 16-bit unsigned short value from the register.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated read.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
index int

Value index. Typically -1, but could be used to extract data from a specific position in the register. Index is byte counted.

-1

Returns:

Type Description
int

The 16-bit unsigned short value.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
def register_read_u16(self, device_id: int, reg_id: int, index: int = -1) -> int:
    """Reads 16-bit unsigned short value from the register.

    It is not necessary to open the port, create the device or register before
    using this function, since it will do a dedicated read.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
        index: Value index. Typically -1, but could be used to extract data from
            a specific position in the register. Index is byte counted.

    Returns:
        The 16-bit unsigned short value.
    """
    data = c_ushort(0)
    self._sdk.registerReadU16(self._portname, device_id, reg_id, data, index)
    return data.value

register_read_u32 ¤

register_read_u32(device_id: int, reg_id: int, index: int = -1) -> int

Reads 32-bit unsigned long value from the register.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated read.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
index int

Value index. Typically -1, but could be used to extract data from a specific position in the register. Index is byte counted.

-1

Returns:

Type Description
int

The 32-bit unsigned long value.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
def register_read_u32(self, device_id: int, reg_id: int, index: int = -1) -> int:
    """Reads 32-bit unsigned long value from the register.

    It is not necessary to open the port, create the device or register before
    using this function, since it will do a dedicated read.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
        index: Value index. Typically -1, but could be used to extract data from
            a specific position in the register. Index is byte counted.

    Returns:
        The 32-bit unsigned long value.
    """
    data = c_ulong(0)
    self._sdk.registerReadU32(self._portname, device_id, reg_id, data, index)
    return data.value

register_read_u64 ¤

register_read_u64(device_id: int, reg_id: int, index: int = -1) -> int

Reads 64-bit unsigned long long value from the register.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated read.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
index int

Value index. Typically -1, but could be used to extract data from a specific position in the register. Index is byte counted.

-1

Returns:

Type Description
int

The 64-bit unsigned long long value.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
def register_read_u64(self, device_id: int, reg_id: int, index: int = -1) -> int:
    """Reads 64-bit unsigned long long value from the register.

    It is not necessary to open the port, create the device or register before
    using this function, since it will do a dedicated read.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
        index: Value index. Typically -1, but could be used to extract data from
            a specific position in the register. Index is byte counted.

    Returns:
        The 64-bit unsigned long long value.
    """
    data = c_ulonglong(0)
    self._sdk.registerReadU64(self._portname, device_id, reg_id, data, index)
    return data.value

register_read_u8 ¤

register_read_u8(device_id: int, reg_id: int, index: int = -1) -> int

Reads 8-bit unsigned char value from the register.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated read.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
index int

Value index. Typically -1, but could be used to extract data from a specific position in the register. Index is byte counted.

-1

Returns:

Type Description
int

The 8-bit unsigned char value.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
def register_read_u8(self, device_id: int, reg_id: int, index: int = -1) -> int:
    """Reads 8-bit unsigned char value from the register.

    It is not necessary to open the port, create the device or register before
    using this function, since it will do a dedicated read.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
        index: Value index. Typically -1, but could be used to extract data from
            a specific position in the register. Index is byte counted.

    Returns:
        The 8-bit unsigned char value.
    """
    data = c_ubyte(0)
    self._sdk.registerReadU8(self._portname, device_id, reg_id, data, index)
    return data.value

register_remove ¤

register_remove(device_id: int, reg_id: int) -> None

Remove a specific register from the internal register list.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1283
1284
1285
1286
1287
1288
1289
1290
def register_remove(self, device_id: int, reg_id: int) -> None:
    """Remove a specific register from the internal register list.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
    """
    self._sdk.registerRemove(self._portname, device_id, reg_id)

register_remove_all ¤

register_remove_all(device_id: int) -> None

Remove all registers from the internal register list.

No confirmation given, the list is simply cleared.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1292
1293
1294
1295
1296
1297
1298
1299
1300
def register_remove_all(self, device_id: int) -> None:
    """Remove all registers from the internal register list.

    No confirmation given, the list is simply cleared.

    Args:
        device_id: The device id (module address).
    """
    self._sdk.registerRemoveAll(self._portname, device_id)

register_write ¤

register_write(
    device_id: int, reg_id: int, data: bytes, index: int = -1
) -> None

Writes a register value.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated write.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
data bytes

The data to write to the register.

required
index int

Value index. Typically -1, but could be used to write a value in a multi-value register.

-1
Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
def register_write(self, device_id: int, reg_id: int, data: bytes, index: int = -1) -> None:
    """Writes a register value.

    It is not necessary to open the port, create the device or register before
    using this function, since it will do a dedicated write.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
        data: The data to write to the register.
        index: Value index. Typically -1, but could be used to write a value in a multi-value register.
    """
    self._sdk.registerWrite(self._portname, device_id, reg_id, data, len(data), index)

register_write_ascii ¤

register_write_ascii(
    device_id: int,
    reg_id: int,
    string: str,
    *,
    write_eol: bool = False,
    index: int = -1
) -> None

Writes a string to the register value.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated write.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
string str

The string to write to the register.

required
write_eol bool

Whether to append the End Of Line character (a null character) to the string.

False
index int

Value index. Typically -1, but could be used to write a value in a mixed-type register.

-1
Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
def register_write_ascii(
    self, device_id: int, reg_id: int, string: str, *, write_eol: bool = False, index: int = -1
) -> None:
    """Writes a string to the register value.

    It is not necessary to open the port, create the device or register before
    using this function, since it will do a dedicated write.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
        string: The string to write to the register.
        write_eol: Whether to append the End Of Line character (a null character) to the string.
        index: Value index. Typically -1, but could be used to write a value in a mixed-type register.
    """
    buffer = create_string_buffer(string.encode("ascii"))
    self._sdk.registerWriteAscii(self._portname, device_id, reg_id, buffer, int(write_eol), index)

register_write_f32 ¤

register_write_f32(
    device_id: int, reg_id: int, value: float, index: int = -1
) -> None

Writes a 32-bit float register value.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated write.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
value float

The 32-bit float to write to the register.

required
index int

Value index. Typically -1, but could be used to write a value in a multi-value register.

-1
Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
def register_write_f32(self, device_id: int, reg_id: int, value: float, index: int = -1) -> None:
    """Writes a 32-bit float register value.

    It is not necessary to open the port, create the device or register before
    using this function, since it will do a dedicated write.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
        value: The 32-bit float to write to the register.
        index: Value index. Typically -1, but could be used to write a value in a multi-value register.
    """
    self._sdk.registerWriteF32(self._portname, device_id, reg_id, value, index)

register_write_f64 ¤

register_write_f64(
    device_id: int, reg_id: int, value: float, index: int = -1
) -> None

Writes a 64-bit double register value.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated write.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
value float

The 64-bit double to write to the register.

required
index int

Value index. Typically -1, but could be used to write a value in a multi-value register.

-1
Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
def register_write_f64(self, device_id: int, reg_id: int, value: float, index: int = -1) -> None:
    """Writes a 64-bit double register value.

    It is not necessary to open the port, create the device or register before
    using this function, since it will do a dedicated write.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
        value: The 64-bit double to write to the register.
        index: Value index. Typically -1, but could be used to write a value in a multi-value register.
    """
    self._sdk.registerWriteF64(self._portname, device_id, reg_id, value, index)

register_write_read ¤

register_write_read(
    device_id: int, reg_id: int, data: bytes, index: int = -1
) -> bytes

Writes then reads a register value.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated write followed by a dedicated read.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
data bytes

The data to write to the register.

required
index int

Value index. Typically -1, but could be used to write a value in a multi-value register.

-1

Returns:

Type Description
bytes

The data that was written to the register.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
def register_write_read(self, device_id: int, reg_id: int, data: bytes, index: int = -1) -> bytes:
    """Writes then reads a register value.

    It is not necessary to open the port, create the device or register before using
    this function, since it will do a dedicated write followed by a dedicated read.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
        data: The data to write to the register.
        index: Value index. Typically -1, but could be used to write a value in a multi-value register.

    Returns:
        The data that was written to the register.
    """
    size = c_ubyte(255)
    read = create_string_buffer(size.value)
    self._sdk.registerWriteRead(self._portname, device_id, reg_id, data, len(data), index, read, size, index)
    return read.raw[: size.value]

register_write_read_ascii ¤

register_write_read_ascii(
    device_id: int,
    reg_id: int,
    string: str,
    *,
    write_eol: bool = False,
    index: int = -1
) -> str

Writes then reads a string register value.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated write followed by a dedicated read.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
string str

The string to write to the register.

required
write_eol bool

Whether to append the End Of Line character (a null character) to the string.

False
index int

Value index. Typically -1, but could be used to write a value in a multi-value register.

-1

Returns:

Type Description
str

The string that was written to the register.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
def register_write_read_ascii(
    self, device_id: int, reg_id: int, string: str, *, write_eol: bool = False, index: int = -1
) -> str:
    """Writes then reads a string register value.

    It is not necessary to open the port, create the device or register before using
    this function, since it will do a dedicated write followed by a dedicated read.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
        string: The string to write to the register.
        write_eol: Whether to append the End Of Line character (a null character) to the string.
        index: Value index. Typically -1, but could be used to write a value in a multi-value register.

    Returns:
        The string that was written to the register.
    """
    ascii_value = create_string_buffer(string.encode("ascii"))
    size = c_ubyte(255)
    read = create_string_buffer(size.value)
    self._sdk.registerWriteReadAscii(
        self._portname, device_id, reg_id, ascii_value, int(write_eol), read, size, index
    )
    return bytes(read.value).decode("ascii")

register_write_read_f32 ¤

register_write_read_f32(
    device_id: int, reg_id: int, value: float, index: int = -1
) -> float

Writes then reads a 32-bit float register value.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated write followed by a dedicated read.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
value float

The 32-bit float value to write to the register.

required
index int

Value index. Typically -1, but could be used to write a value in a multi-value register.

-1

Returns:

Type Description
float

The 32-bit float value that was written to the register.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
def register_write_read_f32(self, device_id: int, reg_id: int, value: float, index: int = -1) -> float:
    """Writes then reads a 32-bit float register value.

    It is not necessary to open the port, create the device or register before using
    this function, since it will do a dedicated write followed by a dedicated read.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
        value: The 32-bit float value to write to the register.
        index: Value index. Typically -1, but could be used to write a value in a multi-value register.

    Returns:
        The 32-bit float value that was written to the register.
    """
    read = c_float(0)
    self._sdk.registerWriteReadF32(self._portname, device_id, reg_id, value, read, index)
    return read.value

register_write_read_f64 ¤

register_write_read_f64(
    device_id: int, reg_id: int, value: float, index: int = -1
) -> float

Writes then reads a 64-bit double register value.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated write followed by a dedicated read.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
value float

The 64-bit double value to write to the register.

required
index int

Value index. Typically -1, but could be used to write a value in a multi-value register.

-1

Returns:

Type Description
float

The 64-bit double value that was written to the register.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
def register_write_read_f64(self, device_id: int, reg_id: int, value: float, index: int = -1) -> float:
    """Writes then reads a 64-bit double register value.

    It is not necessary to open the port, create the device or register before using
    this function, since it will do a dedicated write followed by a dedicated read.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
        value: The 64-bit double value to write to the register.
        index: Value index. Typically -1, but could be used to write a value in a multi-value register.

    Returns:
        The 64-bit double value that was written to the register.
    """
    read = c_double(0)
    self._sdk.registerWriteReadF64(self._portname, device_id, reg_id, value, read, index)
    return read.value

register_write_read_s16 ¤

register_write_read_s16(
    device_id: int, reg_id: int, value: int, index: int = -1
) -> int

Writes then reads a 16-bit signed short register value.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated write followed by a dedicated read.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
value int

The 16-bit signed short value to write to the register.

required
index int

Value index. Typically -1, but could be used to write a value in a multi-value register.

-1

Returns:

Type Description
int

The 16-bit signed short value that was written to the register.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
def register_write_read_s16(self, device_id: int, reg_id: int, value: int, index: int = -1) -> int:
    """Writes then reads a 16-bit signed short register value.

    It is not necessary to open the port, create the device or register before using
    this function, since it will do a dedicated write followed by a dedicated read.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
        value: The 16-bit signed short value to write to the register.
        index: Value index. Typically -1, but could be used to write a value in a multi-value register.

    Returns:
        The 16-bit signed short value that was written to the register.
    """
    read = c_short(0)
    self._sdk.registerWriteReadS16(self._portname, device_id, reg_id, value, read, index)
    return read.value

register_write_read_s32 ¤

register_write_read_s32(
    device_id: int, reg_id: int, value: int, index: int = -1
) -> int

Writes then reads a 32-bit signed long register value.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated write followed by a dedicated read.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
value int

The 32-bit signed long value to write to the register.

required
index int

Value index. Typically -1, but could be used to write a value in a multi-value register.

-1

Returns:

Type Description
int

The 32-bit signed long value that was written to the register.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
def register_write_read_s32(self, device_id: int, reg_id: int, value: int, index: int = -1) -> int:
    """Writes then reads a 32-bit signed long register value.

    It is not necessary to open the port, create the device or register before using
    this function, since it will do a dedicated write followed by a dedicated read.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
        value: The 32-bit signed long value to write to the register.
        index: Value index. Typically -1, but could be used to write a value in a multi-value register.

    Returns:
        The 32-bit signed long value that was written to the register.
    """
    read = c_long(0)
    self._sdk.registerWriteReadS32(self._portname, device_id, reg_id, value, read, index)
    return read.value

register_write_read_s64 ¤

register_write_read_s64(
    device_id: int, reg_id: int, value: int, index: int = -1
) -> int

Writes then reads a 64-bit signed long long register value.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated write followed by a dedicated read.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
value int

The 64-bit signed long long value to write to the register.

required
index int

Value index. Typically -1, but could be used to write a value in a multi-value register.

-1

Returns:

Type Description
int

The 64-bit signed long long value that was written to the register.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
def register_write_read_s64(self, device_id: int, reg_id: int, value: int, index: int = -1) -> int:
    """Writes then reads a 64-bit signed long long register value.

    It is not necessary to open the port, create the device or register before using
    this function, since it will do a dedicated write followed by a dedicated read.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
        value: The 64-bit signed long long value to write to the register.
        index: Value index. Typically -1, but could be used to write a value in a multi-value register.

    Returns:
        The 64-bit signed long long value that was written to the register.
    """
    read = c_longlong(0)
    self._sdk.registerWriteReadS64(self._portname, device_id, reg_id, value, read, index)
    return read.value

register_write_read_s8 ¤

register_write_read_s8(
    device_id: int, reg_id: int, value: int, index: int = -1
) -> int

Writes then reads a 8-bit signed char register value.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated write followed by a dedicated read.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
value int

The 8-bit signed char value to write to the register.

required
index int

Value index. Typically -1, but could be used to write a value in a multi-value register.

-1

Returns:

Type Description
int

The 8-bit signed char value that was written to the register.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
def register_write_read_s8(self, device_id: int, reg_id: int, value: int, index: int = -1) -> int:
    """Writes then reads a 8-bit signed char register value.

    It is not necessary to open the port, create the device or register before using
    this function, since it will do a dedicated write followed by a dedicated read.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
        value: The 8-bit signed char value to write to the register.
        index: Value index. Typically -1, but could be used to write a value in a multi-value register.

    Returns:
        The 8-bit signed char value that was written to the register.
    """
    read = c_byte(0)
    self._sdk.registerWriteReadS8(self._portname, device_id, reg_id, value, read, index)
    return read.value

register_write_read_u16 ¤

register_write_read_u16(
    device_id: int, reg_id: int, value: int, index: int = -1
) -> int

Writes then reads a 16-bit unsigned short register value.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated write followed by a dedicated read.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
value int

The 16-bit unsigned short value to write to the register.

required
index int

Value index. Typically -1, but could be used to write a value in a multi-value register.

-1

Returns:

Type Description
int

The 16-bit unsigned short value that was written to the register.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
def register_write_read_u16(self, device_id: int, reg_id: int, value: int, index: int = -1) -> int:
    """Writes then reads a 16-bit unsigned short register value.

    It is not necessary to open the port, create the device or register before using
    this function, since it will do a dedicated write followed by a dedicated read.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
        value: The 16-bit unsigned short value to write to the register.
        index: Value index. Typically -1, but could be used to write a value in a multi-value register.

    Returns:
        The 16-bit unsigned short value that was written to the register.
    """
    read = c_ushort(0)
    self._sdk.registerWriteReadU16(self._portname, device_id, reg_id, value, read, index)
    return read.value

register_write_read_u32 ¤

register_write_read_u32(
    device_id: int, reg_id: int, value: int, index: int = -1
) -> int

Writes then reads a 32-bit unsigned long register value.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated write followed by a dedicated read.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
value int

The 32-bit unsigned long value to write to the register.

required
index int

Value index. Typically -1, but could be used to write a value in a multi-value register.

-1

Returns:

Type Description
int

The 32-bit unsigned long value that was written to the register.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
def register_write_read_u32(self, device_id: int, reg_id: int, value: int, index: int = -1) -> int:
    """Writes then reads a 32-bit unsigned long register value.

    It is not necessary to open the port, create the device or register before using
    this function, since it will do a dedicated write followed by a dedicated read.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
        value: The 32-bit unsigned long value to write to the register.
        index: Value index. Typically -1, but could be used to write a value in a multi-value register.

    Returns:
        The 32-bit unsigned long value that was written to the register.
    """
    read = c_ulong(0)
    self._sdk.registerWriteReadU32(self._portname, device_id, reg_id, value, read, index)
    return read.value

register_write_read_u64 ¤

register_write_read_u64(
    device_id: int, reg_id: int, value: int, index: int = -1
) -> int

Writes then reads a 64-bit unsigned long long register value.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated write followed by a dedicated read.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
value int

The 64-bit unsigned long long value to write to the register.

required
index int

Value index. Typically -1, but could be used to write a value in a multi-value register.

-1

Returns:

Type Description
int

The 64-bit unsigned long long value that was written to the register.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
def register_write_read_u64(self, device_id: int, reg_id: int, value: int, index: int = -1) -> int:
    """Writes then reads a 64-bit unsigned long long register value.

    It is not necessary to open the port, create the device or register before using
    this function, since it will do a dedicated write followed by a dedicated read.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
        value: The 64-bit unsigned long long value to write to the register.
        index: Value index. Typically -1, but could be used to write a value in a multi-value register.

    Returns:
        The 64-bit unsigned long long value that was written to the register.
    """
    read = c_ulonglong(0)
    self._sdk.registerWriteReadU64(self._portname, device_id, reg_id, value, read, index)
    return read.value

register_write_read_u8 ¤

register_write_read_u8(
    device_id: int, reg_id: int, value: int, index: int = -1
) -> int

Writes then reads a 8-bit unsigned char register value.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated write followed by a dedicated read.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
value int

The 8-bit unsigned char value to write to the register.

required
index int

Value index. Typically -1, but could be used to write a value in a multi-value register.

-1

Returns:

Type Description
int

The 8-bit unsigned char value that was written to the register.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
def register_write_read_u8(self, device_id: int, reg_id: int, value: int, index: int = -1) -> int:
    """Writes then reads a 8-bit unsigned char register value.

    It is not necessary to open the port, create the device or register before using
    this function, since it will do a dedicated write followed by a dedicated read.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
        value: The 8-bit unsigned char value to write to the register.
        index: Value index. Typically -1, but could be used to write a value in a multi-value register.

    Returns:
        The 8-bit unsigned char value that was written to the register.
    """
    read = c_ubyte(0)
    self._sdk.registerWriteReadU8(self._portname, device_id, reg_id, value, read, index)
    return read.value

register_write_s16 ¤

register_write_s16(
    device_id: int, reg_id: int, value: int, index: int = -1
) -> None

Writes a 16-bit signed short register value.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated write.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
value int

The 16-bit signed short to write to the register.

required
index int

Value index. Typically -1, but could be used to write a value in a multi-value register.

-1
Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
def register_write_s16(self, device_id: int, reg_id: int, value: int, index: int = -1) -> None:
    """Writes a 16-bit signed short register value.

    It is not necessary to open the port, create the device or register before
    using this function, since it will do a dedicated write.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
        value: The 16-bit signed short to write to the register.
        index: Value index. Typically -1, but could be used to write a value in a multi-value register.
    """
    self._sdk.registerWriteS16(self._portname, device_id, reg_id, value, index)

register_write_s32 ¤

register_write_s32(
    device_id: int, reg_id: int, value: int, index: int = -1
) -> None

Writes a 32-bit signed long register value.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated write.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
value int

The 32-bit signed long to write to the register.

required
index int

Value index. Typically -1, but could be used to write a value in a multi-value register.

-1
Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
def register_write_s32(self, device_id: int, reg_id: int, value: int, index: int = -1) -> None:
    """Writes a 32-bit signed long register value.

    It is not necessary to open the port, create the device or register before
    using this function, since it will do a dedicated write.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
        value: The 32-bit signed long to write to the register.
        index: Value index. Typically -1, but could be used to write a value in a multi-value register.
    """
    self._sdk.registerWriteS32(self._portname, device_id, reg_id, value, index)

register_write_s64 ¤

register_write_s64(
    device_id: int, reg_id: int, value: int, index: int = -1
) -> None

Writes a 64-bit signed long long register value.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated write.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
value int

The 64-bit signed long long to write to the register.

required
index int

Value index. Typically -1, but could be used to write a value in a multi-value register.

-1
Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
def register_write_s64(self, device_id: int, reg_id: int, value: int, index: int = -1) -> None:
    """Writes a 64-bit signed long long register value.

    It is not necessary to open the port, create the device or register before
    using this function, since it will do a dedicated write.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
        value: The 64-bit signed long long to write to the register.
        index: Value index. Typically -1, but could be used to write a value in a multi-value register.
    """
    self._sdk.registerWriteS64(self._portname, device_id, reg_id, value, index)

register_write_s8 ¤

register_write_s8(
    device_id: int, reg_id: int, value: int, index: int = -1
) -> None

Writes a 8-bit signed char register value.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated write.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
value int

The 8-bit signed char to write to the register.

required
index int

Value index. Typically -1, but could be used to write a value in a multi-value register.

-1
Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
def register_write_s8(self, device_id: int, reg_id: int, value: int, index: int = -1) -> None:
    """Writes a 8-bit signed char register value.

    It is not necessary to open the port, create the device or register before
    using this function, since it will do a dedicated write.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
        value: The 8-bit signed char to write to the register.
        index: Value index. Typically -1, but could be used to write a value in a multi-value register.
    """
    self._sdk.registerWriteS8(self._portname, device_id, reg_id, value, index)

register_write_u16 ¤

register_write_u16(
    device_id: int, reg_id: int, value: int, index: int = -1
) -> None

Writes a 16-bit unsigned short register value.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated write.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
value int

The 16-bit unsigned short to write to the register.

required
index int

Value index. Typically -1, but could be used to write a value in a multi-value register.

-1
Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
def register_write_u16(self, device_id: int, reg_id: int, value: int, index: int = -1) -> None:
    """Writes a 16-bit unsigned short register value.

    It is not necessary to open the port, create the device or register before
    using this function, since it will do a dedicated write.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
        value: The 16-bit unsigned short to write to the register.
        index: Value index. Typically -1, but could be used to write a value in a multi-value register.
    """
    self._sdk.registerWriteU16(self._portname, device_id, reg_id, value, index)

register_write_u32 ¤

register_write_u32(
    device_id: int, reg_id: int, value: int, index: int = -1
) -> None

Writes a 32-bit unsigned long register value.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated write.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
value int

The 32-bit unsigned long to write to the register.

required
index int

Value index. Typically -1, but could be used to write a value in a multi-value register.

-1
Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
def register_write_u32(self, device_id: int, reg_id: int, value: int, index: int = -1) -> None:
    """Writes a 32-bit unsigned long register value.

    It is not necessary to open the port, create the device or register before
    using this function, since it will do a dedicated write.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
        value: The 32-bit unsigned long to write to the register.
        index: Value index. Typically -1, but could be used to write a value in a multi-value register.
    """
    self._sdk.registerWriteU32(self._portname, device_id, reg_id, value, index)

register_write_u64 ¤

register_write_u64(
    device_id: int, reg_id: int, value: int, index: int = -1
) -> None

Writes a 64-bit unsigned long long register value.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated write.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
value int

The 64-bit unsigned long long to write to the register.

required
index int

Value index. Typically -1, but could be used to write a value in a multi-value register.

-1
Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
def register_write_u64(self, device_id: int, reg_id: int, value: int, index: int = -1) -> None:
    """Writes a 64-bit unsigned long long register value.

    It is not necessary to open the port, create the device or register before
    using this function, since it will do a dedicated write.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
        value: The 64-bit unsigned long long to write to the register.
        index: Value index. Typically -1, but could be used to write a value in a multi-value register.
    """
    self._sdk.registerWriteU64(self._portname, device_id, reg_id, value, index)

register_write_u8 ¤

register_write_u8(
    device_id: int, reg_id: int, value: int, index: int = -1
) -> None

Writes a 8-bit unsigned char register value.

It is not necessary to open the port, create the device or register before using this function, since it will do a dedicated write.

Parameters:

Name Type Description Default
device_id int

The device id (module address).

required
reg_id int

The register id (register address).

required
value int

The 8-bit unsigned char to write to the register.

required
index int

Value index. Typically -1, but could be used to write a value in a multi-value register.

-1
Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
def register_write_u8(self, device_id: int, reg_id: int, value: int, index: int = -1) -> None:
    """Writes a 8-bit unsigned char register value.

    It is not necessary to open the port, create the device or register before
    using this function, since it will do a dedicated write.

    Args:
        device_id: The device id (module address).
        reg_id: The register id (register address).
        value: The 8-bit unsigned char to write to the register.
        index: Value index. Typically -1, but could be used to write a value in a multi-value register.
    """
    self._sdk.registerWriteU8(self._portname, device_id, reg_id, value, index)

set_callback_device_status staticmethod ¤

set_callback_device_status(callback: NKTDeviceStatusCallback | None) -> None

Enables/Disables a callback for device status changes.

See superk_callback.py for an example usage.

Note

Due to a risk of circular runaway leading to stack overflow, it is not allowed to call functions in the DLL from within the callback function. If a call is made to a function in the DLL the function will raise an exception.

Parameters:

Name Type Description Default
callback NKTDeviceStatusCallback | None

A callback function. Pass in None to disable the device-status callback.

required
Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
@staticmethod
def set_callback_device_status(callback: NKTDeviceStatusCallback | None) -> None:
    """Enables/Disables a callback for device status changes.

    See [superk_callback.py](https://github.com/MSLNZ/msl-equipment/blob/main/packages/resources/examples/nkt/superk_callback.py)
    for an example usage.

    !!! note
        Due to a risk of circular runaway leading to stack overflow, it is not allowed
        to call functions in the DLL from within the callback function. If a call is
        made to a function in the DLL the function will raise an exception.

    Args:
        callback: A callback function. Pass in `None` to disable the device-status callback.
    """
    if NKTDLL._SDK is None:
        msg = "NKTError: You must first call NKT.load_sdk()"
        raise RuntimeError(msg)

    if callback is not None and not isinstance(callback, DeviceStatusCallback):
        msg = "NKTError: Must pass in a DeviceStatusCallback object"
        raise TypeError(msg)

    NKTDLL._SDK.setCallbackPtrDeviceInfo(callback)

set_callback_port_status staticmethod ¤

set_callback_port_status(callback: NKTPortStatusCallback | None) -> None

Enables/Disables a callback for port status changes.

Used by the open_ports and close_ports functions.

See superk_callback.py for an example usage.

Note

Due to a risk of circular runaway leading to stack overflow, it is not allowed to call functions in the DLL from within the callback function. If a call is made to a function in the DLL the function will raise an exception.

Parameters:

Name Type Description Default
callback NKTPortStatusCallback | None

A callback function. Pass in None to disable the port-status callback.

required
Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
@staticmethod
def set_callback_port_status(callback: NKTPortStatusCallback | None) -> None:
    """Enables/Disables a callback for port status changes.

    Used by the [open_ports][msl.equipment_resources.nkt.nktpdll.NKTDLL.open_ports] and
    [close_ports][msl.equipment_resources.nkt.nktpdll.NKTDLL.close_ports] functions.

    See [superk_callback.py](https://github.com/MSLNZ/msl-equipment/blob/main/packages/resources/examples/nkt/superk_callback.py)
    for an example usage.

    !!! note
        Due to a risk of circular runaway leading to stack overflow, it is not allowed
        to call functions in the DLL from within the callback function. If a call is
        made to a function in the DLL the function will raise an exception.

    Args:
        callback: A callback function. Pass in `None` to disable the port-status callback.
    """
    if NKTDLL._SDK is None:
        msg = "NKTError: You must first call NKT.load_sdk()"
        raise RuntimeError(msg)

    if callback is not None and not isinstance(callback, PortStatusCallback):
        msg = "NKTError: Must pass in a PortStatusCallback object"
        raise TypeError(msg)

    NKTDLL._SDK.setCallbackPtrPortInfo(callback)

set_callback_register_status staticmethod ¤

set_callback_register_status(
    callback: NKTRegisterStatusCallback | None,
) -> None

Enables/Disables a callback for register status changes.

See superk_callback.py for an example usage.

Note

Due to a risk of circular runaway leading to stack overflow, it is not allowed to call functions in the DLL from within the callback function. If a call is made to a function in the DLL the function will raise an exception.

Parameters:

Name Type Description Default
callback NKTRegisterStatusCallback | None

A callback function. Pass in None to disable the register-status callback.

required
Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
@staticmethod
def set_callback_register_status(callback: NKTRegisterStatusCallback | None) -> None:
    """Enables/Disables a callback for register status changes.

    See [superk_callback.py](https://github.com/MSLNZ/msl-equipment/blob/main/packages/resources/examples/nkt/superk_callback.py)
    for an example usage.

    !!! note
        Due to a risk of circular runaway leading to stack overflow, it is not allowed
        to call functions in the DLL from within the callback function. If a call is
        made to a function in the DLL the function will raise an exception.

    Args:
        callback: A callback function. Pass in `None` to disable the register-status callback.
    """
    if NKTDLL._SDK is None:
        msg = "NKTError: You must first call NKT.load_sdk()"
        raise RuntimeError(msg)

    if callback is not None and not isinstance(callback, RegisterStatusCallback):
        msg = "NKTError: Must pass in a RegisterStatusCallback object"
        raise TypeError(msg)

    NKTDLL._SDK.setCallbackPtrRegisterInfo(callback)

set_legacy_bus_scanning staticmethod ¤

set_legacy_bus_scanning(*, mode: bool) -> None

Set the bus-scanning mode to normal or legacy.

Parameters:

Name Type Description Default
mode bool

If False, bus scanning is set to normal mode and allows for a rolling masterId. In this mode the masterId is changed for each message to allow for out-of-sync detection. If True, bus scanning is set to legacy mode and fixes the masterId at address 66 (0x42). Some older modules do not accept masterIds other than 66 (0x42).

required
Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
@staticmethod
def set_legacy_bus_scanning(*, mode: bool) -> None:
    """Set the bus-scanning mode to normal or legacy.

    Args:
        mode: If `False`, bus scanning is set to normal mode and allows for a
            rolling _masterId_. In this mode the _masterId_ is changed for each
            message to allow for out-of-sync detection. If `True`, bus scanning
            is set to legacy mode and fixes the _masterId_ at address 66 (0x42).
            Some older modules do not accept _masterIds_ other than 66 (0x42).
    """
    if NKTDLL._SDK is None:
        msg = "NKTError: You must first call NKT.load_sdk()"
        raise RuntimeError(msg)

    NKTDLL._SDK.setLegacyBusScanning(int(bool(mode)))

Wrapper around the NKTPDLL.dll SDK from NKT Photonics.

The wrapper was written using v2.1.2.766 of the SDK.

DeviceStatusCallback module-attribute ¤

DeviceStatusCallback = CFUNCTYPE(
    None, c_char_p, c_ubyte, c_ubyte, c_ubyte, c_void_p
)

A callback function when the status of a device changes.

PortStatusCallback module-attribute ¤

PortStatusCallback = CFUNCTYPE(
    None, c_char_p, c_ubyte, c_ubyte, c_ubyte, c_ubyte
)

A callback function when the status of a port changes.

RegisterStatusCallback module-attribute ¤

RegisterStatusCallback = CFUNCTYPE(
    None, c_char_p, c_ubyte, c_ubyte, c_ubyte, c_ubyte, c_ubyte, c_void_p
)

A callback function when the status of a register changes.

DateTime (Structure) ¤

The DateTimeType struct (24 hour format).

Attributes:

Name Type Description
Sec c_uint8

Second.

Min c_uint8

Minute.

Hour c_uint8

Hour.

Day c_uint8

Day.

Month c_uint8

Month.

Year c_uint8

Year.

DeviceMode (IntEnum) ¤

The DeviceModeTypes enum.

Attributes:

Name Type Description
Disabled int

The device is disabled. Not being polled and serviced, 0.

AnalyseInit int

The analyse cycle has been started for the device, 1.

Analyse int

The analyse cycle is in progress. All default registers being read to determine its state, 2.

Normal int

The analyse cycle has completed and the device is ready, 3.

LogDownload int

A log is being downloaded from the device, 4.

Error int

The device is in an error state, 5.

Timeout int

The connection to the device has been lost, 6.

Upload int

The device is in upload mode and can not be used normally, 7.

DeviceStatus (IntEnum) ¤

The DeviceStatusTypes enum.

Attributes:

Name Type Description
ModeChanged int

Data contains 1 unsigned byte DeviceMode, 0.

LiveChanged int

Data contains 1 unsigned byte, 0=live off, 1=live on, 1.

TypeChanged int

Data contains 1 unsigned byte with DeviceType, 2.

PartNumberChanged int

Data contains a zero terminated string with part number, 3.

PCBVersionChanged int

Data contains 1 unsigned byte with PCB version number, 4.

StatusBitsChanged int

Data contains 1 unsigned long with status bits, 5.

ErrorCodeChanged int

Data contains 1 unsigned short with error code, 6.

BlVerChanged int

Data contains a zero terminated string with Bootloader version, 7.

FwVerChanged int

Data contains a zero terminated string with Firmware version, 8.

ModuleSerialChanged int

Data contains a zero terminated string with Module serial number, 9.

PCBSerialChanged int

Data contains a zero terminated string with PCB serial number, 10.

SysTypeChanged int

Data contains 1 unsigned byte with SystemType, 11.

ParameterSet (Structure) ¤

The ParameterSet struct.

This is how a calculation on parameter sets is done internally by modules:

DAC_value = (value * (X/Y)) + Offset

where, value is either ParameterSet.StartVal or ParameterSet.FactoryVal

value = (ADC_value * (X/Y)) + Offset

where, value often is available via another measurement register.

Attributes:

Name Type Description
Unit c_uint8

Unit type as defined in tParamSetUnitTypes.

ErrorHandler c_uint8

Warning/Error handler not used.

StartVal c_ushort

Setpoint for Settings parameter set, unused in Measurement parameter sets.

FactoryVal c_ushort

Factory Setpoint for Settings parameter set, unused in Measurement parameter sets.

ULimit c_ushort

Upper limit.

LLimit c_ushort

Lower limit.

Numerator c_short

Numerator(X) for calculation.

Denominator c_short

Denominator(Y) for calculation.

Offset c_short

Offset for calculation.

PointToPoint dataclass ¤

PointToPoint(
    host_address: str,
    host_port: int,
    client_address: str,
    client_port: int,
    protocol: int,
    ms_timeout: int,
)

A point-to-point port.

Parameters:

Name Type Description Default
host_address str

The local ip address, e.g., "192.168.1.67".

required
host_port int

The local port number.

required
client_address str

The remote ip address, e.g., "192.168.1.100".

required
client_port int

The remote port number.

required
protocol int

Either 0 (TCP) or 1 (UDP).

required
ms_timeout int

Telegram timeout value in milliseconds.

required

PortStatus (IntEnum) ¤

The PortStatusTypes enum.

Attributes:

Name Type Description
Unknown int

Unknown status, 0.

Opening int

The port is opening, 1.

Opened int

The port is now open, 2.

OpenFail int

The port open failed, 3.

ScanStarted int

The port scanning is started, 4.

ScanProgress int

The port scanning progress, 5.

ScanDeviceFound int

The port scan found a device, 6.

ScanEnded int

The port scanning ended, 7.

Closing int

The port is closing, 8.

Closed int

The port is now closed, 9.

Ready int

The port is open and ready, 10.

RegisterData (IntEnum) ¤

The RegisterDataTypes enum.

Attributes:

Name Type Description
UNKNOWN int

Unknown/Undefined data type, 0.

MIXED int

Mixed content data type, 1.

U8 int

8-bit unsigned data type (unsigned char), 2.

S8 int

8-bit signed data type (char), 3.

U16 int

16-bit unsigned data type (unsigned short), 4.

S16 int

16-bit signed data type (short), 5.

U32 int

32-bit unsigned data type (unsigned long), 6.

S32 int

32-bit signed data type (long), 7.

F32 int

32-bit floating point data type (float), 8.

U64 int

64-bit unsigned data type (unsigned long long), 9.

S64 int

64-bit signed data type (long long), 10.

F64 int

64-bit floating point data type (double), 11.

ASCII int

Zero terminated ascii string data type, 12.

ParamSet int

ParameterSet data type, 13.

B8 int

8-bit binary data type (unsigned char), 14.

H8 int

8-bit hexadecimal data type (unsigned char), 15.

B16 int

16-bit binary data type (unsigned short), 16.

H16 int

16-bit hexadecimal data type (unsigned short), 17.

B32 int

32-bit binary data type (unsigned long), 18.

H32 int

32-bit hexadecimal data type (unsigned long), 19.

B64 int

64-bit binary data type (unsigned long long), 20.

H64 int

64-bit hexadecimal data type (unsigned long long), 21.

DATETIME int

DateTime data type, 22.

RegisterPriority (IntEnum) ¤

The RegisterPriorityTypes enum.

Attributes:

Name Type Description
Low int

The register is polled with low priority, 0.

High int

The register is polled with high priority, 1.

RegisterStatus (IntEnum) ¤

The RegisterStatusTypes enum.

Attributes:

Name Type Description
Success int

Register operation was successful 0.

Busy int

Register operation resulted in a busy, 1.

Knackered int

Register operation resulted in a knackered register (a non-existing register), 2.

CRCErr int

Register operation resulted in a CRC error, 3.

Timeout int

Register operation resulted in a timeout, 4.

ComError int

Register operation resulted in a COM error. Out of sync. or garbage error, 5.

Unit (IntEnum) ¤

The ParamSetUnitTypes enum.

Attributes:

Name Type Description
NONE int

None/Unknown, 0.

mV int

mV, 1.

V int

V, 2.

uA int

uA, 3.

mA int

mA, 4.

A int

A, 5.

uW int

uW, 6.

cmW int

mW/100, 7.

dmW int

mW/10, 8.

mW int

mW, 9.

W int

W, 10.

mC int

degC/1000, 11.

cC int

degC/100, 12.

dC int

degC/10, 13.

pm int

pm, 14.

dnm int

nm/10, 15.

nm int

nm, 16.

percent int

%, 17.

perMile int

per mile, 18.

cmA int

mA/100, 19.

dmA int

mA/10, 20.

RPM int

RPM, 21.

dBm int

dBm, 22.

cBm int

dBm/10, 23.

mBm int

dBm/100, 24.

dB int

dB, 25.

cB int

dB/10, 26.

mB int

dB/100, 27.

dpm int

pm/10, 28.

cV int

V/100, 29.

dV int

V/10, 30.

lm int

lm (lumen), 31.

dlm int

lm/10, 32.

clm int

lm/100, 33.

mlm int

lm/1000, 34.

device_status_callback ¤

device_status_callback(f: NKTDeviceStatusCallback) -> _CFunctionType

Use as a decorator for a callback function when the status of a device changes.

See superk_callback.py for an example usage.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
76
77
78
79
80
81
82
def device_status_callback(f: NKTDeviceStatusCallback) -> _CFunctionType:
    """Use as a decorator for a callback function when the status of a device changes.

    See [superk_callback.py](https://github.com/MSLNZ/msl-equipment/blob/main/packages/resources/examples/nkt/superk_callback.py)
    for an example usage.
    """
    return DeviceStatusCallback(f)

port_status_callback ¤

port_status_callback(f: NKTPortStatusCallback) -> _CFunctionType

Use as a decorator for a callback function when the status of a port changes.

See superk_callback.py for an example usage.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
63
64
65
66
67
68
69
def port_status_callback(f: NKTPortStatusCallback) -> _CFunctionType:
    """Use as a decorator for a callback function when the status of a port changes.

    See [superk_callback.py](https://github.com/MSLNZ/msl-equipment/blob/main/packages/resources/examples/nkt/superk_callback.py)
    for an example usage.
    """
    return PortStatusCallback(f)

register_status_callback ¤

register_status_callback(f: NKTRegisterStatusCallback) -> _CFunctionType

Use as a decorator for a callback function when the status of a register changes.

See superk_callback.py for an example usage.

Source code in packages/resources/src/msl/equipment_resources/nkt/nktpdll.py
89
90
91
92
93
94
95
def register_status_callback(f: NKTRegisterStatusCallback) -> _CFunctionType:
    """Use as a decorator for a callback function when the status of a register changes.

    See [superk_callback.py](https://github.com/MSLNZ/msl-equipment/blob/main/packages/resources/examples/nkt/superk_callback.py)
    for an example usage.
    """
    return RegisterStatusCallback(f)