A Linux and Qt-based automatic adaptation measurement and control method for USB oscilloscope and a high-reliability waveform acquisition method

CN122592013APending Publication Date: 2026-08-18GUILIN UNIV OF ELECTRONIC TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610746765.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-05-28
Publication Date
2026-08-18

AI Technical Summary

Technical Problem

[0006]本发明的目的在于提供一种基于Linux与Qt的USB示波器自动适配测控及高可靠波形采集方法,以解决现有技术中设备识别滞后、人工配置繁琐、数据传输不稳定、多设备兼容性差的问题,实现Linux平台下USB示波器全自动、高可靠、通用化的自动化测控

Benefits of technology

[0021] 1. This invention uses a kernel event-driven approach to identify hot-plugging devices, providing millisecond-level responses to device online/offline status. Compared to the traditional polling method, this significantly reduces system resource consumption and improves identification accuracy and real-time performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122592013A_ABST
    Figure CN122592013A_ABST
Patent Text Reader

Abstract

The application discloses a Linux and Qt-based automatic adaptation measurement and control and high-reliability waveform acquisition method of a USB oscilloscope, and belongs to the technical field of automatic test measurement and control.The application realizes millisecond-level real-time discovery of hot plug of the USB oscilloscope through Linux udev kernel event driving; the automatic adaptation of USB device permissions is completed through software dynamic generation and loading of udev rules; SCPI instruction interaction and waveform data receiving are decoupled based on a Qt multithreading architecture, ring buffer, CRC check and packet loss retransmission mechanism are adopted to guarantee stable transmission of high-speed waveforms; the device instruction set and data format are automatically matched through a multi-brand protocol adaptive analysis layer to complete big-endian and little-endian normalization conversion.The application realizes plug-and-play of the USB oscilloscope, automatic management and control in the whole life cycle, high-reliability waveform acquisition and multi-brand universal compatibility, solves problems such as identification lag, complicated permissions, packet loss in transmission and poor compatibility, and is suitable for unattended test scenes such as industrial automation, embedded debugging and batch detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of automated testing, Linux embedded systems, USB instrument communication, and Qt cross-platform software technology, specifically to a method for automatic adaptation measurement and control and high-reliability waveform acquisition of a USB oscilloscope based on Linux and Qt. Background Technology

[0002] USB digital oscilloscopes are core testing instruments for industrial automation testing, embedded hardware debugging, and batch inspection of electronic products. However, existing oscilloscope measurement and control technologies have many inherent shortcomings in applications such as Linux industrial control systems and embedded test terminals.

[0003] Current technologies generally use a timed polling method to scan device nodes to identify USB devices. This polling method is resource-intensive, has high recognition latency, cannot achieve real-time hot-plug response, and is difficult to adapt to unattended automated testing scenarios. Furthermore, Linux systems impose strict permission restrictions on USBTMC protocol instruments, preventing ordinary users from directly reading and writing devices. Traditional solutions rely on manually writing udev rules, modifying user groups, and restarting system services, which is cumbersome, cannot be deployed in batches, and has a high rate of human error, severely limiting the practical application of automated testing.

[0004] Furthermore, traditional measurement and control software often employs a single-threaded transmission and reception mechanism, where control commands and waveform data share the same communication channel, making it prone to command blocking and data lag. Large-capacity waveform data acquired at high speeds by oscilloscopes is highly susceptible to packet corruption, data loss, and buffer overflows during USB transmission, resulting in poor measurement stability. Additionally, different brands of oscilloscopes have inconsistent SCPI instruction sets, waveform data end order, and byte alignment rules. Existing software is mostly custom-developed for single devices, lacking versatility and scalability, and unable to achieve compatibility with multiple brands of equipment.

[0005] In summary, existing technologies suffer from technical problems such as low device identification efficiency, complex permission configuration, poor data transmission reliability, weak device compatibility, and insufficient automation, and cannot meet the industrial-grade testing requirements for long-term stability, unattended operation, and batch adaptation. Summary of the Invention

[0006] The purpose of this invention is to provide an automatic adaptation measurement and control and high-reliability waveform acquisition method for USB oscilloscopes based on Linux and Qt, so as to solve the problems of device identification lag, cumbersome manual configuration, unstable data transmission and poor compatibility of multiple devices in the prior art, and realize fully automatic, highly reliable and universal automated measurement and control of USB oscilloscopes under the Linux platform. Technical solution of the present invention

[0007] To achieve the above objectives, the present invention adopts the following technical solution:

[0008] This invention achieves real-time device discovery through udev kernel event-driven mechanisms, abandoning the traditional polling mechanism; it achieves fully automatic permission adaptation through dynamic software configuration of udev rules; it decouples instruction control and data acquisition processes based on Qt multi-threaded architecture, and improves transmission stability by combining ring caching and data verification mechanisms; and it achieves unified parsing of data formats from multiple brands of devices through an adaptive protocol layer, realizing fully automated measurement and control.

[0009] S1. Automatic Device Discovery: Under the Linux system, by listening to udev kernel hot-plug events, USB device insertion, removal and abnormal disconnection events are captured in real time, and the unique identifiers of device VID and PID are extracted to complete the automatic event-level identification and online / offline status update of USB oscilloscopes.

[0010] S2. Automatic permission adaptation: After the USB oscilloscope is detected, the read and write permissions of the current system users to the corresponding USBTMC device node are automatically detected. If the permissions are insufficient, the udev rule file adapted to the device is dynamically generated, the udev service is reloaded and the device permissions are refreshed, and user group authorization is automatically completed.

[0011] S3. Automated Device Management: Based on the Qt signal slot mechanism, device management instances are created to automatically turn on, initialize, and reset parameters of the oscilloscope, monitor the device communication status in real time, automatically retry and reconnect after disconnection, and automatically release USB device resources upon exit.

[0012] S4. Asynchronous command interaction: Construct an SCPI command priority scheduling queue, and use an independent control thread to asynchronously issue configuration commands, trigger commands, and start / stop acquisition commands, and receive device response information to achieve non-blocking device control;

[0013] S5. High-reliability waveform acquisition: An independent data receiving thread is opened to continuously read the raw waveform data stream from the USB. High-speed data is buffered through a ring buffer. Combined with frame header and frame tail verification, CRC integrity verification and abnormal data packet retransmission mechanism, data packet loss and byte out-of-order problems are corrected.

[0014] S6 Adaptive Data Parsing: Automatically identifies differences in waveform data endianness, byte alignment rules, and SCPI instructions from different brands of oscilloscopes, completes data normalization conversion, and outputs standard waveform data for rendering, storage, and analysis.

[0015] Furthermore, kernel event-driven operation is adopted instead of timed polling scan, eliminating invalid device traversal operations, achieving millisecond-level device identification, and reducing system CPU resource consumption.

[0016] Furthermore, the dynamically generated udev rules are based on precise matching of device VID and PID, authorizing only the target oscilloscope device without modifying the system's global configuration, thus ensuring system security and unique compatibility.

[0017] Furthermore, it supports the simultaneous connection of multiple USB oscilloscopes, and independently allocates communication handles and data buffer areas for each device, enabling parallel management and control of multiple devices, channel isolation, and no interference between them.

[0018] Furthermore, SCPI commands are deduplicated, time-sequenced, and prioritized to avoid device jamming and communication anomalies caused by command congestion and repeated issuance.

[0019] Furthermore, the circular buffer employs a cyclic overwrite write mechanism, dynamically adjusting the buffer threshold based on the waveform data rate to avoid data overflow and data loss in high-speed acquisition scenarios.

[0020] Furthermore, it incorporates a multi-brand oscilloscope protocol feature library, automatically matching device models and calling corresponding parsing strategies to achieve universal compatibility with multiple brands of USB oscilloscopes such as Rigol, Tektronix, and Agilent. Beneficial effects of the present invention

[0021] 1. This invention uses a kernel event-driven approach to identify hot-plugging devices, providing millisecond-level responses to device online / offline status. Compared to the traditional polling method, this significantly reduces system resource consumption and improves identification accuracy and real-time performance.

[0022] 2. This invention enables fully automatic configuration of USB device permissions without manual intervention or system restart. It is compatible with all Linux distributions, supports batch automated deployment, and solves the industry pain point of cumbersome Linux instrument permission configuration.

[0023] 3. This invention adopts a multi-threaded approach to separate instruction interaction and data acquisition, and combines it with a circular buffer, CRC check and packet loss retransmission mechanism to completely solve the problems of packet loss, out-of-order delivery and lag in high-speed waveform transmission, and greatly improve the reliability and accuracy of waveform acquisition.

[0024] 4. This invention sets up a multi-device adaptive protocol parsing layer, which automatically adapts to the protocol differences and data format differences of different brands of oscilloscopes, so as to realize that one system is compatible with multiple types of devices, with extremely strong versatility and scalability.

[0025] 5. This invention enables full lifecycle management of equipment, including automatic online deployment, automatic initialization, abnormal reconnection, and automatic resource recycling. It is suitable for unattended industrial automation testing scenarios and effectively reduces manual maintenance costs. Attached Figure Description

[0026] Figure 1 is a block diagram of the USB oscilloscope measurement and control and waveform acquisition system architecture of the present invention;

[0027] Figure 2 is a flowchart of the automatic USB device discovery and permission adaptation process of the present invention;

[0028] Figure 3 is a flowchart of the multi-threaded instruction scheduling and high-reliability waveform acquisition process of the present invention. Detailed Implementation

[0029] The present invention will be further described in detail below with reference to specific embodiments.

[0030] This invention discloses an automatic adaptation measurement and control and high-reliability waveform acquisition method for USB oscilloscopes based on Linux and Qt. The specific implementation process is as follows:

[0031] The first step involves starting a resident listening service in the background to subscribe to Linux udev kernel hot-plug events. When a USB oscilloscope is plugged into the system, the kernel actively reports the device VID, PID, and device node path information. The system extracts the unique device identifier and matches it with the built-in device library to quickly complete device identification and online registration. When the device is unplugged or abnormally disconnected, the removal event is captured in real time, and communication resources are automatically reclaimed to prevent handle leakage.

[0032] The second step involves the system automatically detecting the current user's read and write permissions to the / dev / usbtmc device node after device identification. If permissions are insufficient, the software automatically generates a udev rule file that precisely matches the device, writes the device authorization parameters, calls the system interface to reload the udev rules, dynamically refreshes device permissions, and automatically adds the currently running user to the corresponding device user group. The entire process requires no manual operation and no system restart.

[0033] The third step involves creating a device management object using the Qt framework to automatically power on the oscilloscope, initialize channels, and reset acquisition parameters. The system monitors communication heartbeats and data timeout status in real time, and automatically executes reconnection logic for abnormal situations such as loose USB connections, device crashes, and momentary disconnections to ensure continuous device online operation. When the software exits, it uniformly closes device handles and releases USB bus resources.

[0034] The fourth step is to construct an SCPI instruction scheduling queue, start an independent control thread, sort, deduplicate, and prioritize user-issued instructions such as channel configuration, trigger mode, acquisition frequency, and amplitude calibration, asynchronously send them to the oscilloscope and receive device response feedback, ensuring that control instructions are executed in real time and in an orderly manner, and avoiding interface lag and device instruction congestion.

[0035] The fifth step involves establishing a separate data receiving thread to continuously read the raw waveform data stream from the USB port. A circular buffer is used to cache the high-speed data stream, and the buffer threshold is dynamically adjusted according to the acquisition rate. Valid data packets are located by identifying the frame header and frame tail, and data integrity is verified by combining CRC checks. Lost or corrupted data packets are retransmitted to correct them, ensuring continuous and complete output of large-capacity waveform data.

[0036] The sixth step involves the system matching the device model based on the device's VID / PID, calling the corresponding parsing strategy, automatically identifying the endianness and byte alignment of the waveform data, and completing the transcoding, calibration, and normalization of the raw data to convert it into standard waveform data for real-time interface rendering, local storage, and subsequent data analysis.

Claims

1. A method for automatic adaptation of a USB oscilloscope to measurement and control and high-reliability waveform acquisition based on Linux and Qt, comprising the following steps: S1. Automatic Device Discovery: Under the Linux system, by listening to the udev kernel hot-plug events, the system captures USB device insertion, removal, and abnormal disconnection events in real time, extracts the unique identifiers of the device VID and PID, and completes the automatic event-level identification and online / offline status update of the USB oscilloscope. S2. Automatic permission adaptation: After the USB oscilloscope is detected, the read and write permissions of the current system users to the corresponding USBTMC device node are automatically detected. If the permissions are insufficient, the udev rule file adapted to the device is dynamically generated, the udev service is reloaded and the device permissions are refreshed, and user group authorization is automatically completed. S3. Automated Device Management: Based on the Qt signal slot mechanism, device management instances are created to automatically turn on, initialize, and reset parameters of the oscilloscope, monitor the device communication status in real time, automatically retry and reconnect after disconnection, and automatically release USB device resources upon exit. S4. Asynchronous command interaction: Construct an SCPI command priority scheduling queue, and use an independent control thread to asynchronously issue configuration commands, trigger commands, and start / stop acquisition commands, and receive device response information to achieve non-blocking device control; S5. High-reliability waveform acquisition: An independent data receiving thread is opened to continuously read the raw waveform data stream from the USB. High-speed data is buffered through a ring buffer. Combined with frame header and frame tail verification, CRC integrity verification and abnormal data packet retransmission mechanism, data packet loss and byte out-of-order problems are corrected. S6 Adaptive Data Parsing: Automatically identifies differences in waveform data endianness, byte alignment rules, and SCPI instructions from different brands of oscilloscopes, completes data normalization conversion, and outputs standard waveform data for rendering, storage, and analysis.

2. The method according to claim 1, characterized in that: In step S1, kernel event-driven operation is used instead of timed polling scan, eliminating invalid device traversal operations, achieving millisecond-level device identification, and reducing system CPU resource consumption.

3. The method according to claim 1, characterized in that: In step S2, the dynamically generated udev rules are based on precise matching of device VID and PID, and are only authorized to the target oscilloscope device without modifying the system's global configuration.

4. The method according to claim 1, characterized in that: In step S3, multiple USB oscilloscopes can be connected simultaneously. Each device is independently allocated a communication handle and a data buffer area to achieve parallel management and control of multiple devices and channel isolation.

5. The method according to claim 1, characterized in that: In step S4, SCPI commands are deduplicated, time-sequenced, and priority-sorted to avoid device jamming and communication abnormalities caused by command congestion and repeated issuance.

6. The method according to claim 1, characterized in that: In step S5, the circular buffer adopts a cyclic overwrite write mechanism to dynamically adjust the buffer threshold according to the waveform data rate, thereby avoiding data overflow and data loss in high-speed acquisition scenarios.

7. The method according to claim 1, characterized in that: In step S6, a multi-brand oscilloscope protocol feature library is built-in, which automatically matches the device model and calls the corresponding parsing strategy to achieve universal adaptation of multi-brand USB oscilloscopes such as Rigol, Tektronix, and Agilent.

8. A USB oscilloscope automatic adaptation measurement and control system based on Linux and Qt, characterized in that, The method for implementing any one of claims 1-7 includes: a device event monitoring module, a system permission adaptive module, a device lifecycle management module, an asynchronous instruction scheduling module, a high-reliability data transmission module, and a multi-device protocol parsing and adaptation module.