def get_device_info( self, dev_no: int = 0 ) -> Tuple[ANC350LibDeviceType, int, str, str, bool]: """Device Information Returns available information about a device. The function can not be called before ``discover`` but the devices don't have to be connected with ``connect``. All Pointers to output parameters may be zero to ignore the respective value. Args: dev_no: Sequence number of the device. Must be smaller than the return value from the last ``ANC_discover`` call (default: 0). Returns: A tuple containing the device's information: 0. dev_type: Type of the ANC350 device 1. id: Programmed hardware ID of the device 2. serial: The device's serial number 3. address: The device's interface address if applicable. Returns the IP address in dotted-decimal notation or the string "USB", respectively 4. connected: True, if the device is already connected Raises: ANC350LibError is raised, if the function call fails """ c_dev_no = c_uint32(dev_no) c_dev_type = c_int32() c_id = c_int8() c_serial = c_string(16) c_address = c_string(16) c_connected = c_int32() try: return_code = self._dll.ANC_getDeviceInfo(c_dev_no, byref(c_dev_type), byref(c_id), byref(c_serial), byref(c_address), byref(c_connected)) except Exception as exc: raise ANC350v3LibError( "Unexpected error in ANC_getDeviceInfo") from exc ANC350v3LibError.check_error(return_code, "ANC_getDeviceInfo") return ANC350LibDeviceType(c_dev_type.value), c_id.value,\ c_serial.value.decode(self._encoding), c_address.value.decode(self._encoding),\ bool(c_connected.value)
def get_actuator_name(self, dev_handle: c_void_p, axis_no: int) -> str: """Get Actuator Name Get the name of the currently selected actuator Args: dev_handle: Handle of the device to access axis_no: Axis number (0..2) Returns: Name of the actuator Raises: ANC350LibError is raised, if the function call fails """ c_axis_no = c_uint32(axis_no) c_name = c_string(20) try: return_code = self._dll.ANC_getActuatorName( dev_handle, c_axis_no, byref(c_name)) except Exception as exc: raise ANC350v3LibError( "Unexpected error in ANC_getActuatorName") from exc ANC350v3LibError.check_error(return_code, "ANC_getActuatorName") return c_name.value.decode(self._encoding)
def get_lut_name(self, dev_handle: c_void_p, axis_no: int) -> str: """Get LUT Name Get the name of the currently selected sensor look-up table. The function is only available in RES devices. Args: dev_handle: Handle of the device to access axis_no: Axis number (0..2) Returns: Name of the look-up table. Raises: ANC350LibError is raised, if the function call fails """ c_axis_no = c_uint32(axis_no) c_name = c_string(20) try: return_code = self._dll.ANC_getLutName(dev_handle, c_axis_no, byref(c_name)) except Exception as exc: raise ANC350v3LibError("Unexpected error in ANC_getLutName") from exc ANC350v3LibError.check_error(return_code, "ANC_getLutName") return c_name.value.decode(self._encoding)
def load_lut_file(self, dev_handle: c_void_p, axis_no: int, file_name: str) -> None: """Load Lookup Table Loads a sensor lookup table from a file into the device. The function is only available in RES devices. Args: dev_handle: Handle of the device to access axis_no: Axis number (0..2) file_name: Name of the LUT file to read, optionally with path. Raises: ANC350LibError is raised, if the function call fails """ c_axis_no = c_uint32(axis_no) c_file_name = c_string(file_name.encode(self._encoding)) try: return_code = self._dll.ANC_loadLutFile(dev_handle, c_axis_no, byref(c_file_name)) except Exception as exc: raise ANC350v3LibError("Unexpected error in ANC_loadLutFile") from exc ANC350v3LibError.check_error(return_code, "ANC_loadLutFile")
def register_external_ip(self, hostname: str) -> bool: """Register IP Device in external Network ``discover`` is able to find devices connected via TCP/IP in the same network segment, but it can't "look through" routers. To connect devices in external networks, reachable by routing, the IP addresses of those devices have to be registered prior to calling ``discover``. The function registers one device and can be called several times. The function will return True, if the name resolution succeeds (False otherwise); it doesn't test if the device is reachable. Registered and reachable devices will be found by ``discover``. Args: hostname: Hostname or IP Address in dotted decimal notation of the device to register. Returns: True, if the name resolution succeeds. This doesn't guarantee that the device is reachable. False, if the hostname couldn't be resolved. Raises: ANC350LibError is raised, if the function call fails """ c_hostname = c_string(hostname.encode(self._encoding)) try: return_code = self._dll.ANC_registerExternalIp(byref(c_hostname)) except Exception as exc: raise ANC350v3LibError("Unexpected error in ANC_registerExternalIp") from exc # This function returns 0 (ANC_Ok) if the hostname was added successfully (otherwise it # returns 9 (ANC_NoDevice)). So, don't raise an exception if this is the case. if return_code == 9: return False else: ANC350v3LibError.check_error(return_code, "ANC_registerExternalIp") # If no other error was raised, registering the hostname was successful return True
from ctypes import windll, c_int, c_string, byref # load 'Ehllapi.dll' (from current dir), and function 'hllapi' from the DLL Ehllap32 = windll.ehllapi hllapi = Ehllap32.hllapi # prepare the arguments with types and initial values h_func = c_int(1) h_text = c_string('A') h_len = c_int(1) h_ret = c_int(999) # call the function hllapi(byref(h_func), h_text, byref(h_len), byref(h_ret)) # print the resulting values of all arguments after the call print h_func.value, h_text.value, h_len.value, h_ret.value