"""Basic handler module for testserver. :author: Stefan Lehmann :license: MIT, see license file or https://opensource.org/licenses/MIT :created on: 2017-09-15 """ from typing import List, Union import struct from .handler import AbstractHandler, AmsPacket, AmsResponseData, logger from pyads import constants class BasicHandler(AbstractHandler): """Basic request handler. Basic request handler to print the request data and return some default values. """ def handle_request(self, request: AmsPacket) -> AmsResponseData: """Handle incoming requests and send a response.""" # Extract command id from the request command_id_bytes = request.ams_header.command_id command_id = struct.unpack(" 0: # Create response of repeated 0x0F with a null terminator for strings response_value = ( ("\x0F" * (response_length - 1)) + "\x00").encode( "utf-8" ) else: response_value = b"" response_content = struct.pack("