A method for interacting with computing hardware through an application programming interface

Through real-time interaction between API and computing hardware and dynamic resource management, the problems of inaccurate resource allocation, unstable data transmission and unoptimized task scheduling in the existing technology are solved, and efficient resource utilization and stable system operation are achieved.

CN119356896BActive Publication Date: 2025-05-23DEEP THINKING COMPUTER (QINGDAO) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411957546.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-30
Publication Date
2025-05-23
Estimated Expiration
2044-12-30

AI Technical Summary

Technical Problem

Existing API interaction technologies have challenges in resource management, data transmission reliability and task scheduling optimization, including inaccurate resource allocation, inflexible resource management, and incomplete exception handling mechanisms.

Method used

Establish a connection with the computing hardware through the API, monitor the hardware resource status in real time, generate resource lists, dynamically allocate tasks, establish a two-way data channel, and trigger an exception handling mechanism when an exception occurs.

Benefits of technology

It realizes efficient utilization of resources, ensures the reliability of data transmission and the stability of the system, and improves the fault tolerance and computing efficiency of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119356896B_ABST
    Figure CN119356896B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of computer technology, and in particular to a method for interacting with computing hardware through an application programming interface, comprising the following steps: S1: establishing a connection with computing hardware through an API and initializing a communication protocol; S2: obtaining hardware information and generating a resource list according to the hardware resource status; S3: allocating application tasks according to priority and remaining hardware resources through an API according to the hardware resource list; S4: establishing a two-way data channel through an API; S5: in the process of data transmission or task execution, if an exception occurs, immediately triggering an exception handling mechanism through an API; S6: after the task is completed, safely disconnecting the communication with the hardware through an API, releasing occupied resources, and recording an interaction log. The present invention significantly improves the utilization efficiency of computing hardware resources and the fault tolerance of the system by dynamically adjusting task allocation and resource utilization and introducing a perfect exception handling mechanism.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method for interacting with computing hardware through an application programming interface. Background Art

[0002] With the rapid development of information technology, the demand for interaction between computing hardware and applications is growing, especially in distributed computing environments, where applications need to frequently interact with different types of computing hardware. These interactions usually rely on application programming interfaces (APIs) to manage hardware resources and schedule tasks. Through APIs, applications can send requests, receive responses, manage hardware resources, transmit data, and coordinate work between hardware units, greatly improving the efficiency of task processing and the resource utilization of the system. However, in actual operations, the existing API interaction technology still has some technical bottlenecks, especially in how to efficiently and stably manage resources, ensure the reliability of data transmission, and optimize task scheduling. There are still many challenges.

[0003] Although existing technologies can already implement basic hardware resource scheduling and data interaction, existing solutions often have problems such as inaccurate task allocation, inflexible resource management, and imperfect exception handling mechanisms. First, resource allocation in existing systems often fails to be adjusted in real time according to dynamic changes in hardware status, resulting in insufficient resource utilization, or resource competition and task execution delays. Second, communication interruptions or hardware failures are prone to occur during data transmission, but existing exception handling mechanisms cannot respond in a timely and effective manner, affecting system stability. Third, existing task allocation methods mostly rely on static configuration and lack the ability to perform dynamic scheduling based on the real-time resource status of the hardware, resulting in the inability to reasonably handle the priority of task execution under high load conditions. Summary of the invention

[0004] Based on the above objectives, the present invention provides a method for interacting with computing hardware through an application programming interface.

[0005] A method for interacting with computing hardware through an application programming interface, comprising the following steps:

[0006] S1: Establish a connection with the computing hardware through the API, initialize the communication protocol, and set the format, rate, and encryption method of data transmission;

[0007] S2: Send device identification request through API to obtain hardware information, and generate resource list according to hardware resource status to provide basis for subsequent task allocation;

[0008] S3: Based on the hardware resource list, the application tasks are allocated according to priority and remaining hardware resources through the API;

[0009] S4: Establishes a two-way data channel through API, supporting real-time data transmission between applications and computing hardware;

[0010] S5: During data transmission or task execution, if hardware failure, communication interruption or task execution exception occurs, the exception handling mechanism is immediately triggered through the API to ensure continuous operation of the system;

[0011] S6: After the task is completed, the communication with the hardware is securely disconnected through the API, the occupied resources are released, and the interaction log is recorded.

[0012] Optionally, the S1 specifically includes:

[0013] S11: first physically connect the application programming interface to the network port of the computing hardware, and use TCP / IP as a transport layer protocol to establish a communication connection;

[0014] S12: After the connection is established, the API and the computing hardware initialize a handshake protocol and select a communication protocol that is compatible with both parties, wherein the communication protocol includes HTTP, HTTPS, WebSocket or MQTT protocol;

[0015] S13: Set the data transmission format through the API, including JSON, XML or Protocol Buffers;

[0016] S14: Dynamically adjust the data transmission rate according to the network bandwidth of the computing hardware and the task requirements, and use the TCP flow control method, including adjusting the window size and controlling the size of the receiving buffer, to ensure that data loss or delay will not occur during data transmission due to insufficient bandwidth;

[0017] S15: Negotiate with computing hardware through an API and select an encryption method, where the encryption method includes an SSL / TLS protocol, a symmetric encryption algorithm, or an asymmetric encryption algorithm.

[0018] Optionally, the S14 specifically includes:

[0019] S141: monitoring the remaining bandwidth of the current network through the API, and obtaining the network throughput between the computing hardware and the application program, where the throughput is expressed as the amount of data that can be transmitted per unit time;

[0020] S142: According to the requirements of network bandwidth and transmission rate, the TCP flow control method is used to calculate the congestion window size and adjust the data transmission rate; the congestion window size is proportional to the network bandwidth, and the calculation formula of the congestion window size is: ,in, is the current congestion window size, Indicates the expected data transfer volume within a period of time. is the maximum congestion window size, B is the current bandwidth;

[0021] S143: Calculate and adjust the size of the receive buffer based on the real-time bandwidth and congestion window adjustment , to maintain efficient data transmission;

[0022] S144: Congestion window calculated according to the above and receive buffer , dynamically adjust the data transmission rate; the transmission rate The relationship between the congestion window and the network bandwidth is calculated by the following formula: .

[0023] Optionally, the S2 specifically includes:

[0024] S21: Sending a device identification request to the computing hardware through the API, wherein the request includes a unique device identifier and communicates using a standardized network protocol;

[0025] S22: After receiving the device identification request, the computing hardware returns a hardware information response, which includes basic attribute data of the hardware, including processor model, memory size, storage capacity, and network interface status;

[0026] S23: After receiving the hardware response, the API parses the returned hardware information and extracts relevant information, including processor type, memory capacity, hard disk storage space, network bandwidth, and number of remaining computing cores;

[0027] S24: Based on the hardware information obtained through the analysis, the current status of the hardware resources is evaluated, including indicators of processor usage, memory occupancy, storage space remaining amount, and network bandwidth utilization, so as to determine the actual remaining situation of the resources;

[0028] S25: Based on the hardware resource status evaluation result, the API generates a hardware resource list; the list contains detailed resource information of each hardware unit, including CPU usage, memory remaining space, storage remaining space and network bandwidth.

[0029] Optionally, the S3 specifically includes:

[0030] S31: receiving a task list sent by an application program through an API, wherein each task in the task list includes a priority identifier and resource requirement parameters, including the number of processor cores, memory capacity, and storage space requirements;

[0031] S32: sorting the task list based on the priority identifiers in the task list;

[0032] S33: According to the sorted task list, the resources in the hardware resource list are matched through the API to determine the processor, memory and storage resources required for each task, and the feasibility of resource allocation is calculated; and the tasks are allocated to the computing hardware with corresponding remaining resources;

[0033] S34: Sending a task allocation instruction to the selected computing hardware through the API, including a task identifier, allocated resource parameters, and execution instructions, to ensure that the task is correctly executed on the specified hardware according to the allocation result.

[0034] Optionally, the S33 specifically includes:

[0035] S331: Extract resource requirement parameters for each task from the sorted task list, including the number of processor cores required , Memory capacity and storage space ,in, Respectively represent tasks The number of processor cores, memory capacity, and storage space required;

[0036] S332: Extract the remaining resource information of each hardware node from the hardware resource list, including the number of remaining processor cores. , Remaining memory capacity and remaining storage space ,in, Respectively represent hardware The remaining number of processor cores, remaining memory capacity, and remaining storage space;

[0037] S333: Calculate resource matching degree based on the resource requirements of the task and the remaining hardware resources; for each task and hardware nodes , the matching degree is calculated according to the following formula: ,in, Indicates the task With Hardware Node Resource matching degree;

[0038] S334: For each task and hardware nodes , determine whether the feasibility of resource allocation is met; if , it means that the hardware node can meet the resource requirements of the task and can Assign to Hardware Node ; otherwise, the allocation fails.

[0039] Optionally, the S4 specifically includes:

[0040] S41: selecting a communication protocol suitable for bidirectional data transmission through an API, where the communication protocol for bidirectional data transmission includes a WebSocket protocol, an HTTP / 2 protocol, or an MQTT protocol;

[0041] S42: initiating an initial connection request with the computing hardware through the API, and performing a handshake process using the selected communication protocol to ensure that both parties can successfully establish a communication session;

[0042] S43: After establishing the initial connection, perform authentication and authorization process through the API;

[0043] S44: Configure data transmission parameters through API, including packet size, transmission buffer size and data compression options;

[0044] S45: Opens a channel for sending and receiving data between the application and the computing hardware through the API, ensuring that data can be transmitted and received in real time in both directions.

[0045] Optionally, the S5 specifically includes:

[0046] S51: Monitor the status of data transmission and task execution in real time through the API, and use monitoring parameters and thresholds to detect hardware failures, communication interruptions, or abnormal task execution;

[0047] S53: Once an abnormal event is detected, the abnormal handling mechanism is immediately activated through the API;

[0048] S54: Send an exception notification to the user or system administrator through the API to inform the current system status and processing results and provide exception information.

[0049] Optionally, the S53 includes:

[0050] S531: Roll back the computing hardware and application status to the last stable state through the API to prevent data loss or task interruption;

[0051] S532: triggering a task restart procedure through an API, automatically reallocating resources and continuing to execute the task from the node where the exception occurred;

[0052] S5323: Record detailed log information of abnormal events through API, including occurrence time, abnormality type, involved hardware components and abnormality code.

[0053] Optionally, the S6 specifically includes:

[0054] S61: Send a disconnection instruction through the API to notify the computing hardware to terminate the current communication session and prepare to close the two-way data channel;

[0055] S62: receiving a communication termination confirmation signal from the computing hardware through the API, confirming that the bidirectional data channel has been successfully closed;

[0056] S63: Sending a resource release request through an API to instruct the computing hardware to release the processor, memory, and storage resources occupied during the task execution process;

[0057] S64: Use the API to instruct the computing hardware to clean up the cache and temporary data related to the current task;

[0058] S65: Automatically generate and store an interaction log through the API, where the interaction log includes a disconnection timestamp, released resource information, events that occurred during the interaction, and status information.

[0059] Beneficial effects of the present invention:

[0060] The present invention, through real-time monitoring and evaluation of hardware resources, enables the application program to intelligently select the priority of task execution and resource allocation scheme according to the available resources, thus avoiding resource competition and task delay, and ensuring the smooth operation of the system in a multi-tasking environment. This dynamic resource allocation mechanism not only improves the overall performance of the system, but also greatly reduces the occurrence of failures caused by insufficient resources or unreasonable resource allocation, and optimizes computing efficiency.

[0061] The present invention, by introducing a perfect exception handling mechanism in the process of data transmission and task execution, can monitor the communication status and task execution status in real time, and promptly trigger the corresponding processing mechanism when a hardware failure or communication interruption occurs, thereby ensuring the continuous and stable operation of the system. Through this mechanism, the system can quickly take countermeasures when problems arise, ensuring that data transmission is not interrupted and task execution is not affected, thereby significantly improving the fault tolerance and reliability of the system. BRIEF DESCRIPTION OF THE DRAWINGS

[0062] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings in the following description are only for the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0063] Figure 1 A schematic diagram of a method for interaction between an application programming interface and computing hardware according to an embodiment of the present invention;

[0064] Figure 2The figure is a flow chart of triggering an exception handling mechanism according to an embodiment of the present invention. DETAILED DESCRIPTION

[0065] The present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. At the same time, it is explained here that in order to make the embodiments more detailed, the following embodiments are the best and preferred embodiments, and those skilled in the art may also adopt other alternatives to implement some known technologies; and the accompanying drawings are only for more specific description of the embodiments, and are not intended to specifically limit the present invention.

[0066] It should be noted that the references to "one embodiment", "embodiment", "exemplary embodiments", "some embodiments" and the like in the specification indicate that the embodiments described may include specific features, structures or characteristics, but not every embodiment may include the specific features, structures or characteristics. In addition, when a specific feature, structure or characteristic is described in conjunction with an embodiment, it should be within the knowledge of a person skilled in the art to implement such feature, structure or characteristic in conjunction with other embodiments (whether or not explicitly described).

[0067] In general, a term can be understood, at least in part, from its use in context. For example, depending, at least in part, on the context, the term "one or more" as used herein can be used to describe any feature, structure, or characteristic in the singular sense, or can be used to describe a combination of features, structures, or characteristics in the plural sense. Additionally, the term "based on" can be understood as not necessarily intended to convey an exclusive set of factors, but can instead, depending, at least in part, on the context, allow for the presence of other factors that are not necessarily explicitly described.

[0068] like Figure 1-Figure 2 As shown, a method for interacting with computing hardware through an application programming interface comprises the following steps:

[0069] S1: Establish a connection with computing hardware through the API (application programming interface), initialize the communication protocol, set the format, rate and encryption method of data transmission, and ensure stable operation of the interface;

[0070] S2: Send device identification requests through the API to obtain hardware information and generate a resource list based on the hardware resource status (such as processing power, memory, and storage) to provide a basis for subsequent task allocation;

[0071] S3: Based on the hardware resource list, the application tasks are allocated according to priority and remaining hardware resources through the API to ensure effective task scheduling;

[0072] S4: Establish a two-way data channel through the API to support real-time data transmission between applications and computing hardware, ensuring the integrity of data transmission;

[0073] S5: During data transmission or task execution, if hardware failure, communication interruption or task execution exception occurs, the exception handling mechanism is immediately triggered through the API to ensure continuous operation of the system;

[0074] S6: After the task is completed, the communication with the hardware is securely disconnected through the API to release occupied resources, and the interaction log is recorded to provide data support for subsequent optimization.

[0075] S1 specifically includes:

[0076] S11: first physically connect the application programming interface (API) to the network port of the computing hardware and use TCP / IP as the transport layer protocol to establish a communication connection;

[0077] S12: After the connection is established, the API and the computing hardware initialize the handshake protocol and select a communication protocol that is compatible with both parties. The communication protocol includes HTTP, HTTPS, WebSocket or MQTT protocol to ensure the stability and security of data transmission;

[0078] S13: Set the data transmission format through API, including JSON, XML or Protocol Buffers, to facilitate data parsing, transmission and exchange, and ensure data efficiency and compatibility;

[0079] S14: Dynamically adjust the data transmission rate according to the network bandwidth of the computing hardware and the task requirements, and use the TCP flow control method, including adjusting the window size and controlling the size of the receiving buffer, to ensure that data loss or delay will not occur during data transmission due to insufficient bandwidth;

[0080] S15: Negotiate with computing hardware through API and select encryption method, which includes SSL / TLS protocol, symmetric encryption algorithm or asymmetric encryption algorithm. Among them, SSL / TLS protocol is used to ensure the security and data integrity of the transport layer. Symmetric encryption algorithm (such as AES) is suitable for scenarios that require fast encryption and decryption. Asymmetric encryption algorithm (such as RSA) is suitable for encrypting sensitive data or key exchange. Through the above steps, it can be ensured that the connection between API and computing hardware has efficient and secure data transmission capabilities.

[0081] The TCP flow control method in S14 specifically includes:

[0082] S141: Monitor the remaining bandwidth of the current network through the API to obtain the network throughput between the computing hardware and the application. The throughput is expressed as the amount of data that can be transmitted per unit time. The bandwidth is calculated using the following formula: ,in, is the amount of data transferred, is the time taken for transmission, B is the current bandwidth, that is, the actual throughput rate of network transmission;

[0083] S142: According to the requirements of network bandwidth and transmission rate, the TCP flow control method is used to calculate the congestion window size and adjust the data transmission rate; the congestion window size is proportional to the network bandwidth, and the calculation formula of the congestion window size is: ,in, is the current congestion window size, Indicates the expected data transfer volume within a period of time. The maximum congestion window size ensures that the bandwidth is not over-occupied or network congestion is not caused;

[0084] S143: Calculate and adjust the size of the receive buffer based on the real-time bandwidth and congestion window adjustment , to maintain efficient data transmission; the size of the receive buffer can be dynamically adjusted using the following formula ,in, is a constant that is adjusted according to the specific hardware capabilities and data transmission requirements;

[0085] S144: Congestion window calculated according to the above and receive buffer , dynamically adjust the data transmission rate; the transmission rate The relationship between the congestion window and the network bandwidth is calculated by the following formula: Among them, the transmission rate (rate) is the key to dynamic adjustment. This formula can ensure that the transmission rate matches the current network status and hardware capabilities, thereby avoiding the impact of too high or too low rates on system performance; the above method can realize dynamic adjustment of the data transmission rate; the TCP flow control method can monitor the network bandwidth in real time, and make appropriate adjustments based on the calculated bandwidth, congestion window, and receive buffer size parameters to ensure maximum flow control and bandwidth utilization during data transmission; this dynamic adjustment method avoids transmission bottlenecks or overloads caused by network bandwidth changes or hardware limitations, and improves data transmission efficiency.

[0086] S2 specifically includes:

[0087] S21: Send a device identification request to the computing hardware through the API. The request contains the device's unique identifier (such as MAC address, device ID, or serial number) and uses a standardized network protocol (such as HTTP, HTTPS, or WebSocket) for communication to ensure that the identification request can accurately reach the hardware and obtain a response;

[0088] S22: After receiving the device identification request, the computing hardware returns a hardware information response, which contains basic attribute data of the hardware, including processor model, memory size, storage capacity, and network interface status. This response is returned to the application through the API, and the data format adopts standard formats such as JSON or XML to ensure that the data can be efficiently parsed and processed.

[0089] S23: After receiving the hardware response, the API parses the returned hardware information and extracts relevant information, including processor type, memory capacity, hard disk storage space, network bandwidth, and number of remaining computing cores; the parsing process is implemented through a JSON or XML parsing library to ensure accurate extraction of information;

[0090] S24: Based on the hardware information obtained through the analysis, the current status of the hardware resources is evaluated, including indicators of processor usage, memory occupancy, storage space remaining amount, and network bandwidth utilization, so as to determine the actual remaining situation of the resources;

[0091] S25: Based on the hardware resource status assessment results, the API generates a hardware resource list; the list contains detailed resource information of each hardware unit, including CPU usage, remaining memory space, remaining storage space, and network bandwidth, to ensure that subsequent tasks can reasonably allocate hardware resources based on the list.

[0092] S3 specifically includes:

[0093] S31: receiving a task list sent by the application through an API, where each task in the task list includes a priority identifier and resource requirement parameters, including the number of processor cores, memory capacity, and storage space requirements;

[0094] S32: sorting the task list based on the priority identifiers in the task list to ensure that high-priority tasks are allocated resources before low-priority tasks;

[0095] S33: According to the sorted task list, the resources in the hardware resource list are matched through the API to determine the processor, memory and storage resources required for each task, and calculate the feasibility of resource allocation; and the tasks are allocated to the computing hardware with corresponding remaining resources to ensure the maximum resource utilization and the efficiency of task execution;

[0096] S34: Send task allocation instructions to the selected computing hardware through the API, including task identification, allocated resource parameters and execution instructions, to ensure that the task is correctly executed on the specified hardware according to the allocation results; through the above steps, the application tasks can be efficiently allocated according to priority and available hardware resources, thereby improving the overall operating efficiency and response speed of the system, and is suitable for multi-tasking and complex resource computing environments.

[0097] S33 specifically includes:

[0098] S331: Extract resource requirement parameters for each task from the sorted task list, including the number of processor cores required , Memory capacity and storage space ,in, Respectively represent tasks The number of processor cores, memory capacity, and storage space required;

[0099] S332: Extract the remaining resource information of each hardware node from the hardware resource list, including the number of remaining processor cores. , Remaining memory capacity and remaining storage space ,in, Respectively represent hardware The remaining number of processor cores, remaining memory capacity, and remaining storage space;

[0100] S333: Calculate resource matching degree based on the resource requirements of the task and the remaining hardware resources; for each task and hardware nodes , the matching degree is calculated according to the following formula: ,in, Representation task With Hardware Node The resource matching degree is calculated as the minimum value of the ratio of the resources required by the task to the available hardware resources, ensuring that the hardware node resources allocated to each task do not exceed its requirements;

[0101] S334: For each task and hardware nodes , determine whether the feasibility of resource allocation is met; if , it means that the hardware node can meet the resource requirements of the task and can Assign to Hardware Node ; Otherwise, the allocation fails; Through the above steps, the feasibility of resource allocation for each task on different hardware nodes can be accurately calculated based on the matching relationship between task requirements and hardware resources, and it can be ensured that resources are not over-allocated or allocated unsuccessfully; This technical solution improves the efficiency of resource allocation and optimizes the use of computing resources through accurate resource matching calculation.

[0102] S4 specifically includes:

[0103] S41: Select a communication protocol suitable for bidirectional data transmission through the API. The communication protocol for bidirectional data transmission includes the WebSocket protocol, HTTP / 2 protocol, or MQTT protocol to ensure the real-time and stability of data transmission.

[0104] S42: initiating an initial connection request with the computing hardware through the API, and performing a handshake process using the selected communication protocol to ensure that both parties can successfully establish a communication session;

[0105] S43: After the initial connection is established, the authentication and authorization process is performed through the API, using a token-based authentication mechanism (such as OAuth 2.0) or a certificate verification method to ensure the security and legitimacy of the data channel;

[0106] S44: Configure data transmission parameters including packet size, transmission buffer size, and data compression options through the API to optimize data transmission efficiency and bandwidth utilization;

[0107] S45: Open a channel for sending and receiving data between the application and the computing hardware through the API at the same time, ensuring that data can be transmitted and received in real time in both directions; through the above steps, a two-way data channel can be established efficiently and stably through the API, and appropriate communication protocols can be selected and authentication and authorization mechanisms can be implemented to ensure the real-time and security of data transmission.

[0108] S5 specifically includes:

[0109] S51: Monitor the status of data transmission and task execution in real time through the API, and use monitoring parameters and thresholds (such as CPU temperature, memory usage, network latency, etc.) to detect hardware failures, communication interruptions, or abnormal task execution, ensuring that system abnormalities can be identified in a timely manner;

[0110] S53: Once an abnormal event is detected, the abnormal handling mechanism is immediately activated through the API;

[0111] S54: Send an exception notification to the user or system administrator through the API to inform the current system status and processing results and provide exception information.

[0112] The exception handling mechanism in S53 includes:

[0113] S531: Roll back the computing hardware and application status to the last stable state through the API to prevent data loss or task interruption;

[0114] S532: triggering a task restart procedure through an API, automatically reallocating resources and continuing to execute the task from the node where the exception occurred;

[0115] S5323: Record detailed log information of abnormal events through API, including occurrence time, exception type, hardware components involved and exception code, for subsequent analysis and optimization; through the above steps, hardware failures, communication interruptions or task execution exceptions can be detected and handled in a timely manner during data transmission or task execution to ensure continuous and stable operation of the system; when an exception occurs, the exception handling mechanism triggered by the API will quickly roll back the system status, restart the task and record the error log to provide protection for system recovery.

[0116] S6 specifically includes:

[0117] S61: Send a disconnection instruction through the API to notify the computing hardware to terminate the current communication session and prepare to close the two-way data channel;

[0118] S62: receiving a communication termination confirmation signal from the computing hardware through the API, confirming that the bidirectional data channel has been successfully closed, and ensuring that there is no more data transmission activity;

[0119] S63: Send a resource release request through the API to instruct the computing hardware to release the processor, memory, and storage resources occupied during the task execution process to ensure that these resources can be reused by other tasks;

[0120] S64: Use API commands to clean up the cache and temporary data related to the current task in the computing hardware to prevent data leakage or resource waste and maintain the efficiency of hardware operation;

[0121] S65: Automatically generate and store interaction logs through the API. The interaction logs include disconnection timestamps, released resource information, events that occurred during the interaction, and status information for subsequent auditing and system optimization. Through the above steps, it is possible to ensure that after the task is completed, the communication with the computing hardware is safely disconnected through the API, the occupied resources are completely released, and the interaction logs are recorded in detail. It is possible to ensure that the system can stably return to the idle state after the task is completed, ready to receive new tasks.

[0122] The present invention covers any substitution, modification, equivalent method and scheme made on the essence and scope of the present invention. In order to make the public have a thorough understanding of the present invention, specific details are described in detail in the following preferred embodiments of the present invention, but those skilled in the art can fully understand the present invention without the description of these details. In addition, in order to avoid unnecessary confusion about the essence of the present invention, well-known methods, processes, procedures, components and circuits are not described in detail.

[0123] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A method for interacting with computing hardware through an application programming interface, characterized in that The following steps are involved: S1: Establish a connection with the computing hardware through the API, initialize the communication protocol, and set the format, rate, and encryption method of data transmission, including: S11: first physically connect the application programming interface to the network port of the computing hardware, and use TCP / IP as a transport layer protocol to establish a communication connection; S12: After the connection is established, the API and the computing hardware initialize a handshake protocol and select a communication protocol that is compatible with both parties, wherein the communication protocol includes HTTP, HTTPS, WebSocket or MQTT protocol; S13: Set the data transmission format through the API, including JSON, XML or Protocol Buffers; S14: Dynamically adjust the data transmission rate according to the network bandwidth of the computing hardware and the task requirements, and use the TCP flow control method, including adjusting the window size and controlling the size of the receiving buffer, to ensure that data loss or delay will not occur during data transmission due to insufficient bandwidth; S15: Negotiate with computing hardware through an API and select an encryption method, where the encryption method includes an SSL / TLS protocol, a symmetric encryption algorithm, or an asymmetric encryption algorithm; S2: Send device identification request through API to obtain hardware information, and generate resource list according to hardware resource status to provide basis for subsequent task allocation; S3: Based on the hardware resource list, the application tasks are allocated according to priority and remaining hardware resources through the API, including: S31: receiving a task list sent by an application program through an API, wherein each task in the task list includes a priority identifier and resource requirement parameters, including the number of processor cores, memory capacity, and storage space requirements; S32: sorting the task list based on the priority identifiers in the task list; S33: According to the sorted task list, the resources in the hardware resource list are matched through the API to determine the processor, memory and storage resources required for each task, and the feasibility of resource allocation is calculated; and the tasks are allocated to the computing hardware with corresponding remaining resources; S34: Sending a task allocation instruction to the selected computing hardware through the API, including a task identifier, allocated resource parameters, and an execution instruction, to ensure that the task is correctly executed on the specified hardware according to the allocation result; S4: Establishes a two-way data channel through API, supporting real-time data transmission between applications and computing hardware; S5: During data transmission or task execution, if a hardware failure, communication interruption, or task execution exception occurs, the exception handling mechanism is immediately triggered through the API to ensure continuous operation of the system. The exception handling mechanism includes: Roll back computing hardware and application status to the last stable state through API to prevent data loss or task interruption; Trigger the task restart program through the API to automatically reallocate resources and continue the task from the node where the exception occurred; Detailed log information of abnormal events is recorded through the API, including the time of occurrence, abnormality type, hardware components involved, and abnormality code; S6: After the task is completed, the communication with the hardware is securely disconnected through the API, the occupied resources are released, and the interaction log is recorded.

2. A method for interacting with computing hardware through an application programming interface according to claim 1, characterized in that: The S14 specifically includes: S141: monitoring the remaining bandwidth of the current network through the API, and obtaining the network throughput between the computing hardware and the application program, where the throughput is expressed as the amount of data that can be transmitted per unit time; S142: According to the requirements of network bandwidth and transmission rate, the TCP flow control method is used to calculate the congestion window size and adjust the data transmission rate; the congestion window size is proportional to the network bandwidth, and the calculation formula of the congestion window size is: ,in, is the current congestion window size, Indicates the expected data transfer volume within a period of time. is the maximum congestion window size, B is the current bandwidth; S143: Calculate and adjust the size of the receive buffer based on the real-time bandwidth and congestion window adjustment , to maintain efficient data transmission; S144: Congestion window calculated according to the above and receive buffer , dynamically adjust the data transmission rate; the transmission rate The relationship between the congestion window and the network bandwidth is calculated by the following formula: .

3. A method for interacting with computing hardware through an application programming interface according to claim 1, characterized in that: The S2 specifically includes: S21: Sending a device identification request to the computing hardware through the API, wherein the request includes a unique device identifier and communicates using a standardized network protocol; S22: After receiving the device identification request, the computing hardware returns a hardware information response, which includes basic attribute data of the hardware, including processor model, memory size, storage capacity, and network interface status; S23: After receiving the hardware response, the API parses the returned hardware information and extracts relevant information, including processor type, memory capacity, hard disk storage space, network bandwidth, and number of remaining computing cores; S24: Based on the hardware information obtained through the analysis, the current status of the hardware resources is evaluated, including indicators of processor usage, memory occupancy, storage space remaining amount, and network bandwidth utilization, so as to determine the actual remaining situation of the resources; S25: Based on the hardware resource status evaluation result, the API generates a hardware resource list; the list contains detailed resource information of each hardware unit, including CPU usage, memory remaining space, storage remaining space and network bandwidth.

4. A method for interacting with computing hardware through an application programming interface according to claim 1, characterized in that: The S33 specifically includes: S331: Extract resource requirement parameters for each task from the sorted task list, including the number of processor cores required , Memory capacity and storage space ,in, They represent the number of processor cores, memory capacity, and storage space requirements of task t respectively; S332: Extract the remaining resource information of each hardware node from the hardware resource list, including the number of remaining processor cores. , Remaining memory capacity and remaining storage space ,in, They represent the remaining number of processor cores, remaining memory capacity, and remaining storage space of hardware h respectively; S333: Calculate the resource matching degree according to the resource requirements of the task and the remaining hardware resources; for each task t and hardware node h, calculate the matching degree according to the following formula: ,in, Indicates the resource matching degree between task t and hardware node h; S334: For each task t and hardware node h, determine whether the feasibility of resource allocation is met; if , it means that the hardware node can meet the resource requirements of the task and can allocate task t to hardware node h; otherwise, the allocation fails.

5. A method for interacting with computing hardware through an application programming interface according to claim 1, characterized in that: The S4 specifically includes: S41: selecting a communication protocol suitable for bidirectional data transmission through an API, where the communication protocol for bidirectional data transmission includes a WebSocket protocol, an HTTP / 2 protocol, or an MQTT protocol; S42: initiating an initial connection request with the computing hardware through the API, and performing a handshake process using the selected communication protocol to ensure that both parties can successfully establish a communication session; S43: After establishing the initial connection, perform authentication and authorization process through the API; S44: Configure data transmission parameters through API, including packet size, transmission buffer size and data compression options; S45: Opens a channel for sending and receiving data between the application and the computing hardware through the API, ensuring that data can be transmitted and received in real time in both directions.

6. A method for interacting with computing hardware through an application programming interface according to claim 1, characterized in that: The S5 specifically includes: S51: Monitor the status of data transmission and task execution in real time through the API, and use monitoring parameters and thresholds to detect hardware failures, communication interruptions, or abnormal task execution; S53: Once an abnormal event is detected, the abnormal handling mechanism is immediately activated through the API; S54: Send an exception notification to the user or system administrator through the API to inform the current system status and processing results and provide exception information.

7. A method for interacting with computing hardware through an application programming interface according to claim 1, characterized in that: The S6 specifically includes: S61: Send a disconnection instruction through the API to notify the computing hardware to terminate the current communication session and prepare to close the two-way data channel; S62: receiving a communication termination confirmation signal from the computing hardware through the API, confirming that the bidirectional data channel has been successfully closed; S63: Sending a resource release request through an API to instruct the computing hardware to release the processor, memory, and storage resources occupied during the task execution process; S64: Use the API to instruct the computing hardware to clean up the cache and temporary data related to the current task; S65: Automatically generate and store an interaction log through the API, where the interaction log includes a disconnection timestamp, released resource information, events that occurred during the interaction, and status information.

Citation Information

Patent Citations

  • Real-time communications using RESTLIKE API

    CN105900391A

  • Intelligent equipment-oriented lightweight API (Application Program Interface) of time sequence database

    CN119180054A