Software-Defined Interaction-Based Heterogeneous Bus Data Processing for Low-Cost Embedded Devices

The rapid growth of the Internet of Things (IoT) market has made serial buses a universal transmission method for connecting various devices and carrying large amounts of heterogeneous data. Existing methods of processing heterogeneous serial bus data rely on programmable devices such as FPGAs and MCUs to solve the data heterogeneity problem by updating the system firmware functions. However, these methods are constrained by professional development knowledge, hardware platform compatibility, system reliability, and security, leading to the inflexibility and inefficiency of programmable devices to process serial bus heterogeneous data. In this paper, we propose a novel Software-defined Interaction (SDI) approach that enables the dynamic configuration of heterogeneous bus data and can process different data types by introducing a scripting language into a low-cost embedded device. Specifically, a Lightweight Data Distribution (L2D) mechanism is presented to address the strong dependency between data and protocols, which achieves efficient decoupling between data and processing methods. Additionally, a Multi-instance Hot-switching (MIHS) method is proposed to achieve dynamic switching among multiple instances. Finally, the effectiveness and real-time performance of the proposed method are verified through simulation and low-cost hardware deployment.


I. INTRODUCTION
In the Internet of Things (IoT) field, embedded microcontroller devices typically use data buses to communicate with peripheral devices to enable connectivity to various sensors, actuators, and other external devices [1].With the rapid growth of the IoT market, data bus-based embedded devices are widely used in many areas, such as medical devices [2], [3], [4], industrial equipment [5], [6], critical infrastructure [7], [8], [9], and smart homes [10].However, these multidomain applications further present several challenges.
At present, IoT devices that rely on data bus technology are highly specialized in specific domains [11], [12].This is mainly due to the existence of various bus standards [13], The associate editor coordinating the review of this manuscript and approving it for publication was Santosh Kumar .fragmented data protocols [14], and diverse application requirements [15], [16], [17], which need to be customized.To adapt to various application scenarios, IoT devices introduce diverse types of data, defined as heterogeneous data, when scenarios are changed and upgraded.
Existing IoT devices typically used recompilation and firmware updates to process the newly introduced heterogeneous data [18], [19], [20] to meet the demand for functional updates in embedded systems [21].For instance, [22] introduced a microcontroller bus architecture incorporating an on-demand remote code execution layer.This layer enables the seamless execution of instructions, which are dynamically loaded from the cloud during runtime.While this approach offers a unique solution for real-time hardware functional updates, it necessitates a high network reliability level and is unsuitable for the varied scenarios in IoT applications.Some researchers have tackled this issue by proposing functional updates based on In-application Programming (IAP) [23], [24], [25].This approach involves the separation of boot code and application code, thereby offering a potential solution to the challenge of ensuring dependable hardware functional updates in Microcontroller Unit (MCU) platforms.Recent researches on IAP updates mainly involved the following modes, namely serial port [26], USB bus [27], Ethernet [28], Bluetooth [29], 1553B [30], WiFi wireless LAN [31], etc.These methods have been extensively utilized across diverse domains.For example, [32] employed IAP technology to facilitate hardware firmware updates in the missile's entire bomb state, leveraging the 1188A interface.While IAP-based firmware updates ensure a certain level of reliability, they are susceptible to unpredictable periods of downtime and cannot provide uninterrupted update (i.e., hotswitching) services, which is unacceptable for time-sensitive devices (e.g., medical devices [33]).
Recently, some researchers have studied hot-switching methods based on Field-programmable Gate Arrays (FPGAs) platforms.Bucknall et al. [34] proposed a framework that allows developers to reconfigure edge applications through local reconfiguration.In the local reconfiguration mode, developers must have extensive knowledge of Linux and FPGA development and understand the bus protocols, communication protocols, and communication rates [35], [36].This framework solves the issue of hot-switching device functionality on the FPGA platform by considering both dynamic updates of data processing and uninterrupted firmware updates.However, it has high requirements for developers and needs more development expertise.
Python has become a popular choice in a variety of fields, including low-cost embedded systems, due to its large number of third-party packages, wide range of uses, ease of programming, and easy-to-develop object-oriented architecture.MicroPython is a scripting language designed for embedded devices [37], which relies on the Python execution container and interacts with hardware data through an interface.It allows for the dynamic update of embedded system functionality without modifying the system firmware, while weakening the requirement for the developer's expertise.The utilization of hybrid C and Python programming for deploying dynamic functional components of the system into Python containers has the potential to enhance the dynamism of embedded systems [38].This approach presents an opportunity to address the diversity of bus data within these systems.
In recent years, several researchers have conducted feasibility studies on utilizing MicroPython for rapid application development.In a study conducted by [37], a comparison was made between the execution efficiency of C and MicroPython on an embedded platform.The findings revealed that although MicroPython execution was less efficient than C code, it demonstrated superior code portability compared to C. Additionally, the study demonstrated the feasibility of utilizing MicroPython on low-cost embedded hardware.
[39] examined the potential for modifications and expansions to the conventional MicroPython implementation on the STM32 platform.They also evaluated the user-friendliness of the development process, implementation, and programming of IoT peripherals.Furthermore, they explored the capability of creating customized libraries and modules at the hardware level.Ultimately, the researchers concluded by highlighting the suitability of MicroPython for facilitating rapid application development.Nevertheless, MicroPython operates as a single-instance system, allowing only one Python script to be loaded at a given moment, which leads to service interruptions when scripts are switched, and thus hot-switching is not possible.In order to satisfy both hot-switching and weak expertise requirements under development, this paper designs a Python container-based architecture that can support hot-switching among multiple instances.
In IoT devices, bus data and processing methods usually have strong coupling relationships [40], which limits the flexibility and reusability of device development, leading to the need for embedded device development in the form of customization, increasing development costs, and reducing development efficiency.Recently, the subscription publishing model has been widely used by researchers to decouple data and processing methods [41], [42].The subscriptionpublishing (sub/pub) model is characterized by establishing a loosely coupled relationship between devices through one-tomany data transfer methods.Specifically, a device (publisher) publishes data to one or more subscribers, who can choose to subscribe to the data they are interested in.This model provides a flexible way of interacting with data, reduces dependencies between devices, and accommodates changes between devices and applications [43].
The sub/pub model has been introduced into embedded systems and implemented in platforms such as Robot Operating System 2 (ROS2) [44], [45] for decoupling sensor data and applications.ROS2 is an open-source robot operating system framework widely used in embedded systems and provides a flexible communication mechanism that enables embedded devices to interact with data in a sub/pub model.However, most existing researches were oriented towards cloud platforms or environments based on operating systems such as Linux, and less researches were conducted towards low-cost embedded systems.Low-cost embedded systems are usually characterized by limited resources and high power requirements [46], and the requirements for decoupling methods may differ from those of traditional high-performance systems.Therefore, to better meet the needs of low-cost embedded systems, this paper proposes a lightweight decoupling method to improve the flexibility and scalability of the system.
Overall, this paper proposes a novel Software-defined Interaction (SDI) approach, the first processing architecture for heterogeneous bus data, that rapidly develops heterogeneous data processing methods for all bus devices.The core innovation of SDI is to integrate Python execution containers and sub/pub mechanisms to provide a common heterogeneous bus data processing framework for low-cost MCU architectures, which enables the reuse of processing methods on embedded devices, improves development efficiency, and reduces development costs.The main contributions of this paper are summarized as follows: 1.A heterogeneous bus data processing architecture based on the SDI method is proposed for the first time.
By introducing a scripting language to dynamically reconfigure the mapping between data and processing methods, SDI can flexibly and efficiently process various data from the bus without modifying the system firmware.2. A Lightweight Data Distribution (L2D) mechanism is introduced to achieve efficient decoupling between data and processing methods.The mechanism uses a flexible data sub/pub model, which can effectively shield the hardware characteristics of embedded systems and reduce the requirement for professional knowledge for system development.3. A Multi-instance Hot-switching (MIHS) method is presented to realize the dynamic update of multiple instances in an uninterrupted state.This method introduces the hot-switching control instance as the coordination object to facilitate uninterrupted switching between the original instance and the switching instance in the controlled state.4. We validate the adaptability, generality, and performance of the proposed SDI approach through system simulations and practical IoT applications.

II. SDI OVERVIEW A. SDI ARCHITECTURE
This paper designs a system architecture based on the proposed SDI approach, which aims to achieve the unified management, sharing, and reuse of data and computational instances on low-cost IoT devices.SDI is characterized by its reconfigurability, scalability, and support for cross-domain data interaction.Fig. 1 illustrates the system architecture with SDI, consisting of the following key modules: (1) Resource description module, responsible for describing and managing various system resources and providing information guidance for data processing.(2) L2D, a sub/pub-based (subscription and publishing) lightweight data distribution module that employs a sub/pub model to distribute bus data to specific subscription instances (Python instances), facilitating efficient decoupling between data and processing methods.(3) MIHS, a multi-instance hot switching module, enables dynamic switching of execution instances at runtime to achieve uninterrupted updates.(4) EDF-MIS, the earliest deadline first (EDF) based multi-instance scheduling module, enables the implementation of complex processing methods while considering inter-instance dependencies and data processing time constraints.

B. DATA DISTRIBUTION MECHANISM
This paper presents L2D as the fundamental mechanism for data distribution within embedded devices, encompassing two primary functionalities.Firstly, the L2D offers a streamlined mechanism for transferring and sharing data, facilitating the indexing of data by topic for utilization across multiple instances.This capability enables the efficient exchange of data between various instances.Furthermore, the issue of heterogeneity among embedded devices is addressed by L2D through the provision of a Board Support Package (BSP).This package offers a standardized abstraction and interface, enabling various embedded devices to utilize a consistent API for data interaction.Consequently, this simplifies the development process and enhances the potential for reusing instances.The integration of L2D and BSP shields the bus driver against heterogeneity, enabling efficient data and processing methods.This integration presents a versatile and user-friendly approach to solution development.
It is commonly acknowledged that buses typically exhibit two distinct modes of operation: half-duplex and full-duplex.Each mode possesses unique characteristics related to data transmission across the bus.In the context of industrial buses, the half-duplex mode is usually employed.In this mode, the device operates in a master-slave configuration, following the principle that the master device transmits data and the slave device responds accordingly.Hence, it is possible to identify a specified data publishing topic for every bus data and allocate a processing instance to handle it.In fullduplex mode, since the bus data type cannot be determined, we use a unified subscription approach.That is, all processing instances associated with it subscribe to the bus data topic.After a processing instance handles data and sends it to the appropriate data push topic, the multi-instance scheduling algorithm sets all driver instances to wait for new data.

C. DATA PROCESSING STREAM PRODUCTION METHODOLOGY
The SDI-based heterogeneous data processing workflow is shown in Fig. 2, with the following main steps: 1. Configuration loading.This process is a prerequisite for performing data processing and mainly includes resource description file download and processing.The resource description file is delivered by the administration terminal and contains task configuration, L2D configuration, and constraint configuration, of which the task configuration contains the instance file and task file.File processing decodes the information from the resource description file through a parser, and the processed data is subsequently used for system construction.2. System construction.In this stage, the system application construction is mainly completed.Based on the various configuration information input from the file parser, the data provided by L2D, and the instance information from the instance resource pool, the instance execution sequence is generated under the EDF-MIS algorithm, which provides the application data for the instance execution in the next stage.3. Instance execution.This stage aims to analyze existing instance execution sequences.The execution sequence of instances is optimized according to relationships between instances, instance types, and the inputs and outputs of instances.For the change of instances during execution, instance hot-switching is utilized to replace the running instances, taking into account both real-time and redundancy.

III. METHOD
This section provides an overview of the fundamental techniques of the proposed SDI approach, including the resource description model, the L2D mechanism, the MIHS method, and the EDF-MIS algorithm.By integrating these techniques, we establish an efficient, flexible, and real-time data processing architecture that realizes dynamic configuration and scheduling of heterogeneous data processing.

A. RESOURCE DESCRIPTION MODEL
In SDI, the resource description model is used to describe and manage the diverse resources in the SDI-based system architecture and consists of four primary parts: data description, processing resource pool, data mapping, and time constraints.
The data description part represents data sources, types, and protocols, clearly defines and abstracts the data in the system, and provides accurate data information for subsequent processing.In this paper, depending on the data source, the data is abstracted into two categories:(1) bus data objects and (2) inter-instance data objects.
The processing resource pool is a centralized repository of processing instances, containing various processing instances available in the system, each of which has specific functionality and capabilities.The processing resource pool provides the flexibility to select and configure appropriate processing instances to meet various data processing requirements.
The data mapping part is used to construct the mapping between data and processing methods to ensure that each piece of data can be processed correctly.The configuration of the data mapping appears before device startup or when the device is executing to accommodate changes in the requirements of the system as it executes.
The time constraint part is used to describe the time requirements of the data processing, including the constraints on the execution time and execution period of the processing method.Through the setting of time constraints, the soft realtime capability of data processing is improved, and the system can complete the data processing tasks within the specified time.
Through the combination and collaborative working of these four parts, SDI can clearly describe and manage the various resources in the system, providing accurate guidance and support for data processing.

B. L2D: A LIGHTWEIGHT DATA DISTRIBUTION MECHANISM
In this section, L2D is designed as a data distribution mechanism to achieve the dynamic mapping between data and processing methods, and the structure is illustrated in Fig. 3.The module is based on a sub/pub model, enabling effective decoupling between data and processing methods.The L2D mechanism has three critical functions in SDI.Firstly, it provides a standard interface and uniform usage for the upper layer (the instance layer), which blocks the differences among various buses and increases the reusability of instances.Thirdly, the cross-domain (i.e., different script environments) communication capability of L2D enables data transfer between the BSP bus driver in the C domain and the processing method in the Python domain.For the L2D mechanism, the data topic is an index of the entire data distribution system.The processing method must subscribe to a specific topic to receive the corresponding data.In this process, the processing method only needs to be concerned with the content of the data carried by the topic, not the publisher of the topic, thus making it possible to decouple the data and processing methods.By introducing the data distribution mechanism, the coupling between the data and processing methods can be minimized, allowing for flexible transmission of data and independent development of processing methods.Note that topics are unique,and a processing method in L2D can subscribe to multiple topics.

C. MIHS: MULTIPLE INSTANCE HOT-SWITCHING
Based on the L2D mechanism, SDI solves the bus data heterogeneity problem by loading specific instances for specific data.For those instances that require uninterrupted updates, the existing functionality can be replaced by instance switching.In this paper, we propose a MIHS method that dynamically switches various instances at run-time.
Instance switching works by a temporary loading control instance to facilitate the replacement of instances.In this paper, we task the example of a hot-switching of an instance, and the switching process is shown in Fig. 4.
In this case, the original and switching instances are two independent objects.The subscription data is distributed through the L2D coordinator, and the instance switching process is controlled by the temporary coordinator instance.The instance switching process is as follows: Firstly, the original and switching instances subscribe to the same data topic, and both execute the respective computation processes upon receiving the data publication.
Secondly, after completing the computations, they transition into different states.The original instance publishes the data to the result topic and immediately enters a sleep state, waiting for the following invocation.The switching instance publishes the computation result to the temporary topic and enters the congestion waiting state.The temporary coordinator instance subscribes to the result and temporary topic data and executes the discriminator procedure when the data arrives.
Thirdly, when the calculation result satisfies the discriminant criteria, the instance replacement operation is executed immediately.At first, the original instance is deleted, then the original instance is removed from the L2D service list, and finally, the official result topic is published to the switching instance.Because it is in congestion mode, the switching instance will immediately receive the data published by the temporary subscription coordinator and then complete the calculation result publication, topic update, and work mode modification.
The complexity of the multi-instance switching process may result in SDI exceptions at run-time.For this reason, we analyze different exceptions to the switching process.The exceptions that may occur during the hot-switching process can be categorized into two parts: instance exceptions and switching process exceptions.
For instance, as an exception, there are three cases included: (1) Original instance exception.The original instance is replaced by a normal instance through the hotswitching operation.(2) Switching instance exception.If the hot-switching operation has been completed, repeat the hot-switching operation once for the switching instance.If the hot-switching has not completed, reload the switching instance.(3) Both the original instance and the switching instance are exceptions.In this case, delete the abnormal instance and reload the original instance and the switching instance.
For the switching process exception.The exception monitoring and fixing is realized by adding a subscription data source to the switching control instance.
In general, for the exceptions in the hot-switching process, all can be fixed through the reloading of instances and instance hot-switching operations, and since each instance in the SDI architecture has an independent run-time, the resource consumption of the fix process that causes a certain amount of time loss is temporary.
Consequently, the hot-switching of the instance is completed without disrupting the work of other instances during this process.The proposed MIHS method enables dynamic loading and replacement of instances to cope with changing data processing requirements and improve the flexibility and maintainability of the system.

D. EDF-MIS: EDF-BASED MULTI-INSTANCE SCHEDULING ALGORITHM
To effectively manage the execution of tasks and comply with processing deadlines, a variety of single-core scheduling algorithms have been proposed to meet the multitask scheduling requirements, and the related algorithms can be categorized into non-priority scheduling and priority scheduling.The non-priority scheduling algorithms represented by Round Robin (RR) [47] and First Come First Served (FCFS) [48] can divide the time slot on average and arrange the execution sequence according to the arrival time of the tasks respectively.Although they meet the scheduling requirements to a certain extent, some tasks fail to be scheduled because they do not consider the deadlines of the tasks.Priority-based scheduling algorithms represented by EDF [49], [50] and Least Laxity First (LLF) [51], which order tasks based on their deadlines and slackness respectively, achieve optimal performance under single-core scheduling under the constraint of schedulable conditions.However, compared with the EDF scheduling algorithm, LLF needs to calculate task relaxation degree in real time, which is not suitable for embedded devices with limited computing resources.The EDF algorithm determines the priority of the task according to the deadline of the task, ensures the timely completion of the task, while optimizing the utilization of MCU computing resources.Therefore, we utilize the EDF algorithm as a task scheduling algorithm to improve the task scheduling efficiency of SDI.

1) THE EDF-MIS SCHEDULABLE CONDITION
In EDF-MIS, a task i related to bus data processing is defined as a series of periodic processing instances that are executed in a sequential manner (τ i1 , τ i2 , . . ., τ in ).Fig. 5 shows an example of a task sequence with 5 tasks.A resource description model describes the relationships between processing instances and data objects, and each processing instance executes a Python script.The processing task i is released at period T i and has a deadline of D i satifiying (Eq.( 1)).The j-th subtask within the task i is represented as τ ij , with its maximum execution time denoted as C ij .It is posited that the deadline D i for the task i is determined by the completion time of the final subtask within the task.Therefore, for task i to be schedulable, it is necessary for the deadline to exceed the combined execution time of the individual subtasks and for the computation FIGURE The hot-switching process of the instance.The L2D coordinator is used to distribute the subscribed data and the temporary coordinator instance is used to control the instance switching process.utilization U i (Eq.( 2)) of the MCU to be less than 1.

2) EDF-MIS TASK MERGE POLICY
In bus data processing, it is common to find situations where identical operations need to be performed on data of the same type.This characteristic implies a potential for significant redundancy among repetitive tasks of the same type.Based on this particular characteristic, the EDF-MIS presents a strategy for optimizing execution.Specifically, we introduce the concepts of ready subtasks and identical subtasks: 1.The ready subtask: a subtask that is ready and waiting to be executed.2. The identical subtask: subtasks that perform the same script and use the same input data, i.e., ready subtasks with the same script and subscribing to the same data source.Simultaneously, if there are multiple subtasks that are identical, including a subtask with a short deadline and a subtask with a later deadline, the subtask with the shorter deadline is executed and subsequently marked as completed, while the subtask with a later deadline is also designated as completed.This is because the computational subtasks are prioritized based on their respective deadlines.The subtask with the shorter deadline is assigned a higher computational priority, while the subtask with a later deadline can reuse the output of the identical subtask with the shorter deadline, thus avoiding redundant computational processes.

3) TASK MODEL
The EDF-MIS algorithm can effectively mitigate the redundancy of computations associated with similar tasks, thereby enhancing the overall efficiency of task execution.The approach leverages the shared characteristics among tasks and the similarity of data processing procedures to minimize extra computational burden, thus enhancing the efficiency and punctuality of the embedded system.In the following, the execution process of EDF-MIS is demonstrated through the integration and optimization of three processing tasks.Table 1 presents the tasks denoted as 1 , 2 , and 3 .It is worth noting that the initial three subtasks of tasks 1 and 3 are the same subtasks, and the task deadline is equivalent to the task period.Fig. 6 displays the scheduling diagram, which does not consider the integration of the same subtasks.The computational utilization of the tasks 1 , 2 , and 3 is 0.32, 0.40, and 0.30 (calculated by Eq. ( 2)), respectively.Additionally, the total computational utilization U total is 1.02, indicating that it exceeds the value of 1.The task sequences 1 , 2 , and 3 exhibit non-schedulability.

4) EDF-MIS ALGORITHM DESCRIPTION
For EDF-HIS, the initial three identical subtasks from tasks 1 and 3 will be integrated, which means that tasks 1 and 3 share the first three computational tasks.The integration Get the task sequence with the shortest deadline in the collection of task sequences (i.e., the highest priority task): Integrate the identical subtasks of the output sequence and the highest priority task: Press task sequences into a collection of task execution sequences: Seq .push( ′ ) 7: end for operation can be realized by Algorithm 1 in the following steps.First, the task sequence Orq is sorted according to the deadline of each task, and the principle of sorting is to place the task closest to the current deadlines at the front of the queue.If multiple tasks have the same deadline, they are sorted according to their arrival times.Secondly, traverse the sorted task sequence to obtain the task sequence with the shortest deadline in the task sequences, namely the highest priority task.Then, determine whether the highest priority task and the output sequence Seq have the identical subtask, and integrate in the case of the identical subtask.Finally, the integrated subtasks are pushed to the output sequence.With this algorithm, subtasks with the same script and data input can be integrated effectively to optimize the execution sequence of tasks in embedded systems.
As shown in Fig. 7, integrating the identical subtasks during the scheduling process and considering their priorities, the computational utilization of sequences 1 , 2 , and 3 , denoted as U ′ 1 , U ′ 2 , and U ′ 3 , is calculated to be 0.32, 0.4, and 0.02 respectively.The total computational utilization U total = 0.74 < 1, satisfying the EDF scheduling condition.Overall, the EDF-MIS algorithm can effectively organize the sequence of instance executions based on the different processing time constraints of each instance, which enables the timely processing of heterogeneous data and meets the multi-service requirements of the system.

IV. RESULTS AND DISCUSSION
In this section, we conduct performance analysis and example verification experiments on SDI, including analysis of execution time for data distribution, analysis of instance switching process, and verification of SDI.Specifically, in the SDI architecture, the decoupling of data and processing methods is realized by the L2D module, which quantitatively analyzes the performance of L2D under different package sizes and topic sizes, that is, the execution time of the insertion and lookup operation, to demonstrate the efficiency and stability of L2D-based data distribution.Then, by introducing MIHS method into the switching process of water level control algorithm, we demonstrate that MIHS provides a feasible method of uninterrupted switching between multiple instances.Subsequently, we verify the effectiveness of SDI architecture in dealing with heterogeneous bus data access in complex environment through an example of high-elevation railway tunnel maintenance monitoring system.Finally, the superiority of the proposed method is verified by comparing it with existing methods.

A. ANALYSIS OF EXECUTION TIME FOR DATA DISTRIBUTION
To validate the efficiency and stability of the data distribution method (L2D) in SDI, we evaluated the insertion and lookup performance of the L2D method on different topic sizes, package sizes, and execution platforms, respectively.
104512 VOLUME 11, 2023 Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.
In particular, the maximum topic size tested on the PC platform is 500,000.The maximum topic size on the embedded platform is 30,000.We used single thread to process the insertion and lookup operations in both PC and embedded device.

1) EFFECT OF PACKAGE SIZE
When testing the effect of package size on transmission performance, the topic size is set and fixed to a maximum value.On the PC platform, the maximum size of topics is set at 500,000 due to the impact of RAM.We consider that in the bus the maximum package size is 64 bytes for CAN-FD, 256 bytes for Modbus in the fieldbus, the test packet size interval is {10, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000}.Table1 2 shows the insertion and lookup test results of L2D on PC, including the average, maximum, and minimum values of the execution time at different packet sizes.Due to the non-real-time nature of the PC operating system, the data insertion and lookup operations are affected by system scheduling, resulting in a large offset in the maximum execution time.Therefore, we will focus on the average value of L2D execution time for insertion and lookup on PC, and the trend of execution time under different packet sizes is shown in Fig. 8.In the embedded platform, limited by hardware resources, especially RAM (32M-Byte) resources, the topic size is set at a maximum of 30,000.The range of the packet size is consistent with the PC platform parameters, and the system scheduling period is 1/100,000 s.Fig. 9 shows the average, maximum, and minimum execution time of data insertion and lookup for L2D on the embedded platform for different packet sizes.Since the embedded platform uses real-time operating system scheduling and L2D has a higher priority compared to instance threads and is less affected by system scheduling, we will discuss average, maximum, and minimum levels for the embedded platform.Fig. 8 and Fig. 9 show that within the interval of [10,1000] bytes, L2D-based data insertion and lookup performance can remain in a relatively stable range with small fluctuation.On the PC platform, the minimum average value of data insertion is 4.38 µs and the maximum average value is 4.57 µs; the minimum average value of data lookup is 3.48 µs and the maximum average value is 3.77 µs.The minimum average value of insertion on embedded platform is 49.59 µs and the maximum average value is 50.76 µs; the minimum average value of data lookup is 3.87 µs and the maximum average value is 4.32 µs.The experimental results show that the proposed L2D mechanism can guarantee that the data distribution performance is not affected by the packet size, i.e., the execution time of data insertion and lookup fluctuates within a small range while increasing the packet size.L2D is a lightweight data distribution mechanism that efficiently reduces insertion and lookup complexity by adding hierarchical indexes without increasing computing resource consumption.Overall, L2D can maintain stable performance across packet sizes and is suitable for both PC and embedded platforms.

2) EFFECT OF TOPIC SIZE
In this part, we study the data insertion and lookup capabilities of L2D at different topic sizes.The packet size is set to 100 bytes, and the experiments are verified on the PC platform and embedded platform, respectively.On the PC platform, we tested the data insertion and lookup capability under four topic scales, including 500 topics, 5000 topics, 50,000 topics, and 500,000 topics, and the test results are shown in Fig. 10.In the embedded platform, limited by the embedded hardware device, we tested the data insertion and lookup capability under 100 topics, 1,000 topics, 10,000 topics, and 100,000 topics, respectively, and the test results are shown in Fig. 11.
Fig. 10 and Fig. 11 show that on both PC and embedded platforms, the data insertion and lookup execution times increase slightly with topic size, but the fluctuations are not significant.However, on the embedded platform, the execution time for data insertion and lookup is much smaller than that on the PC platform.The minimum data insertion time is 20.00 µs, the maximum insertion time is 80.00 µs, the minimum lookup time is less than one scheduling clock, and the maximum lookup time is 20.00 µs.In general,

B. ANALYSIS OF INSTANCE SWITCHING PROCESS
In this section, we show that MIHS can realize uninterrupted switching between multiple instances through the switching process of water level control algorithms.The experiment contains two control algorithms are proportional control algorithm (i.e., P instance) and proportional-integral control algorithm (i.e., PI instance).The P instance is initially loaded, and after it fails to reach the preset water level due to the    From the execution output of the P instance in Fig. 13, it can be seen that the control target value T cannot be reached due to the steady state error of the P instance.Therefore, introducing the switching instance (PI instance) and accumulating the errors of previous instances by adding the integral term can well eliminate the accumulated error.The formalized description is shown in Eq. ( 4), and the system data flow is shown in Fig. 14.In this instance, the integral control coefficient ki=0.2 is pushed from the Python domain to the L2D by the switching instance.The execution output of the single PI instance is shown in Fig. 15.
To achieve the switching of instances, we introduce a hotswitching control instance for judging and controlling the switching timing of the P instance and the PI instance.The specific implementation is to achieve hot-switching between P instance and PI instance by dynamically modifying the instance output topic, so we add a topic for each P instance and PI instance to manage the data publication topic.The judgment logic of the hot-switching control instance is that when the output value of the P instance is 0.75 and stable for a period of time, the output topic of the P instance is modified from the target topic to the temporary topic, and the output topic of the PI instance is modified from the temporary topic to the target topic.The application instance hot-switching flow is shown in Fig. 16, and the P/PI instance hot-switching execution output is shown in Fig. 17.We can see that the execution output of the system is switching from the P instance to the PI instance under the control of the hot-switching control instance, verifying the effectiveness of the proposed MIHS method.The data sub/pub between C and multiple Python domains, demonstrating that the L2D mechanism has the ability to interact with data across C and Python domains, providing reliable data transmission support for complex and heterogeneous bus data processing tasks.

C. VERIFICATION OF SDI
In this section, we verify that the SDI approach can effectively handle heterogeneous bus data access in complex environments through a high-elevation railway-tunnel-maintenance monitoring system.The high-elevation railway-tunnelmaintenance process is significantly affected by the external high-elevation environment, and the maintenance quality is difficult to guarantee, so it is necessary to monitor the maintenance process of high-elevation railway tunnels in real time to ensure the quality of tunnel construction.To address this need, we have developed a High-Elevation Railway-Tunnel-Maintenance Remote Terminal Unit (HRRTU), depicted in Fig. 18, which can dynamically configure data processing instances to process and upload heterogeneous bus data obtained from maintenance equipment in real time.Fig. 19 shows the actual deployment of the HRRTU.terminal, one end of the HRRTU connects to the maintenance trolley's PLC via RS485, employing Modbus-based protocols to retrieve sensor data (refer to 3 for specific details).The other end of the HRRTU establishes an internet connection through WiFi.Considering the impact of the high-elevation environment on the human body, we have deployed the SDI on the HRRTU of the maintenance trolley in the highelevation tunnel to meet the needs of multi-protocol data access and remote online commissioning.
The HRRTU and the maintenance trolley establish communication in a master-slave mode, where the HRRTU assumes the role of the master device, and the maintenance trolley operates as the slave device.The HRRTU builds the real-time monitoring function of the maintenance trolley by loading command injection processing instances and WIFI communication instances, as shown in Fig. 21.The task instance of the HRRTU encompasses two instances: the command injection/processing instance and the WIFI communication instance.The command injection processing instance implements the injection of 485 commands and the processing of PLC response data, and publishes the processed data to the corresponding topic in L2D.Then, the WIFI communication instance subscribes to the maintenance trolley data topic, publishes the data to the WIFI send topic (WH) after data processing and packaging.Finally, the bus driver subscribes to the data of the WH topic to send it via USART, thus enabling the cloud upload of maintenance data.

D. COMPARISON WITH EXISTING METHODS
The above experimental results have fully verified the effectiveness of the SDI method.In this part, we will make a detailed comparison between the advantages of the proposed SDI method and similar models in recent years.The specific comparison results are as follows: Overall, on the basis of the proposed SDI, we achieve comprehensive integration of access device data and processing resources, encompassing uniform management, scheduling, reuse, reorganization, and switching functionalities.This holistic approach significantly improves the efficiency of device development, effectively addresses heterogeneous data challenges across diverse buses, and eliminates unnecessary downtime resulting from functional updates.Furthermore, the migration of existing devices to the SDI-based system architecture not only enhances equipment utilization but also minimizes investment duplication.Finally, we also validate the practical efficacy of the proposed SDI technology through an illustrative scenario.With the introduction of SDI, we expect to the development of IoT devices and enable more efficient, flexible and scalable interaction solutions.
Xue et al. [52] introduced an IoT definition function framework that enables secure remote upgrades and reprogramming of IoT devices.However, the framework can only select the features to be updated from the preset feature library and the lack of hot update capability results in the need to update the firmware during the update process.
Hu et al. [53] proposed a concept based on softwaredefined devices, which maps physical devices to the digital space by adding a software-defined device layer to the IoT paradigm.The virtual devices are segmented and reorganised through a virtual software-defined device controller to achieve software-defined devices on the virtual space.Although the architecture is able to solve the data heterogeneity problem, it increases the data processing time.This is because it focuses on the heterogeneous data processing problem in the SDD layer from the virtual space, thus sacrificing the efficiency of data processing.In contrast, the architecture proposed in this paper starts from the device itself and realizes the advantage of data processing on the device side by reshaping the function of the device.This approach can not only reduce the cloud load, but also improve the real-time data processing.
In addition, Hu et al. [54] described an intelligent controller with software-defined edge function, which builds multiple virtual machines through software-defined and virtualization technology to meet various application requests of the edge layer.However, compared with the architecture proposed in this paper, the architecture proposed in Literature 3 cannot run on low-cost platforms such as MCUS and does not discuss the application heat switching.
In summary, the SDI approach in this paper has the following advantages compared with other methods: 1. SDI can be deployed on low-cost embedded device platforms such as the STM32F1 series, STM32F4 series and STM32H7 series.2. SDI can provide direct calculation of zero jump at the device level, so as to achieve strong real-time performance.3. SDI has a hot-switching mechanism to ensure the stability of the service.Combined with the above advantages, these comparative results reinforce the unique advantages of the proposed architecture, especially in terms of reducing processing time, improving real-time performance, and ensuring service continuity.

V. CONCLUSION
In this study, we propose a software-defined interaction approach for achieving dynamic and efficient processing of heterogeneous bus data on low-cost devices.Specifically, an efficient data distribution mechanism (L2D) is introduced to achieve efficient decoupling between data and processing methods through a sub/pub mechanism, and experimental results show that insertion and lookup operations are characterized by high efficiency and stability.In addition, a multiinstance hot-switching method (MIHS) is proposed, which introduces a scripting language to achieve uninterrupted switching between instances with high reliability and flexibility.Finally, the effectiveness and superiority of the proposed SDI approach are verified through an example.Overall, SDI can achieve rapid iterative optimization of functions on low-cost hardware, reduce unnecessary resource investment, and greatly accelerate the development of intelligent access devices.

FIGURE 2 .
FIGURE 2. The workflow of SDI, mainly including three components: configuration loading, system construction, and instance execution.

FIGURE 3 .
FIGURE 3. The structure of L2D.Broker acts as a coordinator to push to subscribers based on the topic published by the publisher.

FIGURE 7 .
FIGURE 7. EDF-MIS task scheduling consider the integration of the identical subtasks.

FIGURE 8 .
FIGURE 8. Insertion and lookup performance of L2D on PC platform with different package sizes.

FIGURE 9 .
FIGURE 9. Insertion and lookup performance of L2D on embedded platform with different package sizes.

FIGURE 10 .
FIGURE 10.Insertion and lookup performance of L2D on PC platform with different topic sizes.

FIGURE 11 .
FIGURE 11.Insertion and lookup performance of L2D on embedded platform with different topic sizes.

FIGURE 20 .
FIGURE 20. device connection architecture of the HRRTU.

FIGURE 21 .
FIGURE 21.The task instance structure of the HRRTU.

TABLE 1 .
The parameters of three sequence tasks.

TABLE 2 .
L2D execution time for insertion and lookup on PC platform.

TABLE 3 .
Modbus register address table.