Method and system for double buffering transmission of polysomnography data in a ring queue

CN122593690APending Publication Date: 2026-08-18ANYANG XIANGYU MEDICAL EQUIP
View PDF 0 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

下游阻塞会反向影响上游采集,导致丢包;

Benefits of technology

[0015]本发明的有益效果:设置一级环形队列与二级环形队列,一级环形队列用于信号或数据的采集,并可抗中断抖动,吸收抖动,二级环形队列能够抗I/O长尾延迟,持续积压;实现采集与I/O彻底解耦。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122593690A_ABST
    Figure CN122593690A_ABST
Patent Text Reader

Abstract

This invention discloses a method and system for double-buffered transmission of multichannel sleep monitoring data using a circular queue. It establishes a primary circular queue and a secondary circular queue. The primary circular queue is used for signal or data acquisition and is resistant to interruption jitter, absorbing jitter. The secondary circular queue is resistant to long-tail I / O latency and continuous backlog, achieving complete decoupling between acquisition and I / O. Furthermore, the primary circular queue incorporates mechanisms such as fixed memory and constant time to meet the deterministic requirements of interrupt / task environments. Moreover, framing, sequence numbering, and CRC value verification, along with storage and transmission sharing the same reliable data source, ensure zero packet loss.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of medical data processing technology, and in particular to a method and system for double-buffered transmission of polysomnography data in a circular queue. Background Technology

[0002] Polysomnography (PSG) systems require continuous acquisition, real-time processing, synchronous encapsulation, parallel transmission, and storage of multi-source, multi-channel physiological signals (PSG multi-source signals) on a single main control MCU. In practical engineering, the data link is affected by the following uncertainties: Storage-side unpredictable congestion: SD card writes suffer from long-tail latency caused by page erasure, wear leveling, file system mutual exclusion, etc. Uncertainty blocking at the sending end: Congestion, retransmission, and momentary disconnection in the wireless link (WiFi / Bluetooth, etc.) can cause the sending thread to be occupied or blocked for a long time. RTOS multitasking preemption and interrupt storms: scheduling jitter caused by DMA interrupts, multiple concurrent acquisition sources, log output, etc. Waveform data is highly sensitive to continuity: loss of EEG / EMG / ECG / respiratory waveforms can directly cause errors in event identification, discontinuity in the timeline, and distortion of clinical indicators.

[0003] PSG multi-source signals require continuous data sampling. Data processing at each stage necessitates buffering due to blocking, interruptions, and concurrency. Current methods, such as DMA buffering, single-level queue buffering, RTOS queues, or dynamic memory mechanisms, suffer from the following shortcomings: Downstream blockage can negatively impact upstream data collection, leading to packet loss. The single-level buffer has insufficient anti-jitter capability. Long tail latency in SD writing or wireless congestion can easily cause "sudden backlog", resulting in the queue being full and packets being lost. In a general queue / dynamic memory mechanism, frequent copying / dynamic allocation / scheduling switching operations increase CPU jitter, causing real-time tasks to miss their time windows and resulting in packet loss.

[0004] Therefore, existing systems are unable to meet the requirements of low overhead, low jitter, and stable operation over long periods of time. Summary of the Invention

[0005] The purpose of this invention is to provide a method and system for double-buffered transmission of multichannel sleep monitoring data in a circular queue, so as to solve one or more of the above-mentioned technical problems.

[0006] To achieve this objective, the present invention adopts the following technical solution: A double-buffered transmission method for multichannel sleep monitoring data using a circular queue includes: S1: Data Acquisition: Raw data segments of physiological signals or data are collected through multiple acquisition links. Each raw data segment is processed to form a standardized acquisition segment, and the standardized acquisition segment is written into a first-level circular queue without blocking. S2: Data Processing Read the standardized acquisition segments from the first-level circular queue, and perform multi-channel data alignment and encapsulation processing on each standardized acquisition segment, wherein the encapsulation is into a complete data frame; S3: Outbound Processing: The complete data frame is written to a secondary circular queue, which includes independent transmit circular buffer queue channels and store circular buffer queue channels. The transmit circular buffer queue channel is used to perform transmit tasks, and the store circular buffer queue channel is used to perform write or store tasks.

[0007] In some implementations, the physiological signals or data collected in step S1 include at least: electroencephalogram (EEG) signals, electromyogram (EMG) signals, mandibular electrical signals, electrocardiogram (ECG) signals, blood oxygen data, oral and nasal airflow data, nasal pressure data, chest and abdominal belt data, and snoring data. In some implementations, in step S1, the original data fragments are framed to form standardized acquisition fragments; the standardized acquisition fragments include at least: source identifier, fragment number, timestamp, effective length and payload data.

[0008] In some implementations, the write operation is performed in constant time during step S1; In some implementations, in step S1, the write operation is performed in a direct memory access DMA interrupt context or a fast processing segment immediately following the interrupt, and no downstream write or send operation is performed. In some implementations, in step S1, the standardized acquisition segments acquired do not directly call the write or send interface, and do not wait for file system mutual exclusion, erase / write delay, or wireless retransmission. In some implementations, in step S1, when the system experiences short-term latency fluctuations or jitter, a primary circular queue acts as a near-source buffer to temporarily store data fragments. In some implementations, in step S1, when the queue of the primary circular queue is full, the existing unprocessed data segments are not overwritten, but the queue status signal is output and the scheduling enhancement strategy is triggered.

[0009] In some implementations, after the data fragment is processed in step S2, it is not directly written or directly transmitted back, but the result is written to a secondary circular queue to achieve decoupling of acquisition and I / O.

[0010] In some implementations, in step S3, when there is an occasional long-term blockage during data writing or data transmission, the secondary circular queue continuously accumulates complete frame data during the blockage period, so that the data acquisition and data processing links remain continuous; when the blockage is cleared, batch dequeueing, writing and transmission are performed.

[0011] In some implementations, in step S3, the complete frame data includes at least: a frame header, a frame payload, a frame checksum, and a frame trailer; wherein the frame checksum is a Cyclic Redundancy Check (CRC) value. In some implementations, in step S3, at least the EEG, ECG, and EMG data are subject to an overwrite queuing policy.

[0012] In some implementations, both the primary circular queue and the secondary circular queue are provided with a fixed-length cyclic first-in-first-out (FIFO) buffer. Each circular queue has a physical storage space of a contiguous memory array of length L, and the writing and reading of data are controlled by the enqueue pointer In and the dequeue pointer Out. Wherein, the length L is an integer power of 2, and the movement of the pointer is achieved by address wrapping through bitmask operations.

[0013] In some implementations, both the primary circular queue and the secondary circular queue are provided with fixed memory.

[0014] A circular queue-based double-buffered transmission system for multi-channel sleep monitoring data includes: Acquisition module: Used to acquire raw data fragments of physiological signals or data from multiple links, form standardized acquisition fragments, and write them into a primary circular queue; Processing module: Aligns the standardized acquisition segments in the primary circular queue and encapsulates them into complete data frames; Outbound module: Writes complete data frames to a secondary circular queue, sends a circular buffer queue channel for sending tasks, and stores a circular buffer queue channel for writing or storing tasks.

[0015] The beneficial effects of this invention are as follows: a primary circular queue and a secondary circular queue are set up. The primary circular queue is used for signal or data acquisition and can resist interruption jitter and absorb jitter. The secondary circular queue can resist long tail delay of I / O and continuous backlog; thus, the acquisition and I / O are completely decoupled.

[0016] Furthermore, the primary circular queue is equipped with mechanisms such as fixed memory and constant time to meet the deterministic requirements of the interrupt / task environment; Furthermore, the use of framing, sequence number, and CRC value verification, along with the sharing of the same reliable data source for storage and transmission, ensures zero packet loss. Attached Figure Description

[0017] Figure 1This is a flowchart illustrating the steps of the circular queue method for double-buffered transmission of multichannel sleep monitoring data according to the present invention. Figure 2 This is a flowchart illustrating the double-buffered transmission method for multichannel sleep monitoring data using a circular queue, as described in this invention. Figure 3 This is a structural diagram of the circular queue multichannel sleep monitoring data double-buffered transmission system of the present invention.

[0018] Terminology Explanation: MCU (Microcontroller Unit) An embedded control chip integrating a processor, memory, and input / output interfaces is used to perform acquisition, processing, and communication tasks. In this paper, the main control MCU (such as STM32H743IIT) is responsible for the acquisition, packaging, scheduling, and storage control of multi-channel signals.

[0019] DMA (Direct Memory Access) A technology that allows peripherals to exchange data directly with memory without occupying the CPU is used to improve data transmission efficiency and is often used in high-speed data acquisition scenarios such as ADC, SPI, and UART.

[0020] RTOS (Real-Time Operating System) An operating system specifically designed for embedded systems, supporting multitasking, interrupt response, and real-time requirements. In this paper, it is used to manage acquisition, processing, and transmission tasks.

[0021] Circular FIFO (Ring Buffer) A fixed-size buffer, using head and tail pointers to cyclically utilize storage space, is suitable for embedded systems with high memory and real-time requirements. This paper uses it to implement lock-free, constant-time data enqueueing and dequeueing.

[0022] Framed The process of encapsulating raw data into a complete data frame with a header (such as source ID, timestamp, sequence number), payload, and tail (such as CRC checksum) facilitates storage, transmission, and verification.

[0023] CRC (Cyclic Redundancy Check) A commonly used error detection code is used to verify whether data has been corrupted during transmission or storage.

[0024] Long-tail latency This refers to a phenomenon where, while the vast majority of operations complete quickly, a few operations experience significant delays due to anomalies or resource contention. In this article, it refers to delays caused by occasional congestion during SD card writing or wireless transmission.

[0025] Back pressure A flow control mechanism is proposed that limits the upstream data injection rate through a feedback mechanism to prevent system overload when downstream processing capacity is insufficient. This paper utilizes queue fullness to trigger scheduling enhancements or sampling adjustments.

[0026] FAT file system (File Allocation Table) A file system commonly used in embedded storage devices (such as SD cards) that supports file creation, reading, writing, and management.

[0027] PSG (Polysomnography) A diagnostic technique that simultaneously records multiple physiological signals, including electroencephalography (EEG), electrooculography (EOG), electromyography (EMG), electrocardiography (ECG), respiration, and blood oxygenation, for the analysis of sleep disorders.

[0028] SPI / UART (Serial Peripheral Interface / Universal Asynchronous Receiver / Transmitter) Two common embedded communication protocols are used to connect sensors, analog-to-digital converter chips, or wireless modules.

[0029] DMA double buffer (Ping-Pong Buffer) A technique that uses two buffers to alternately receive data allows one buffer to be processed by the CPU while the other continues to receive data, thereby improving data throughput. Detailed Implementation

[0030] The present invention will now be described in further detail with reference to the accompanying drawings.

[0031] refer to Figure 1 and Figure 2 A method for double-buffered transmission of polysomnography data using a circular queue includes the following steps: S1: Data Acquisition: Raw data segments of physiological signals or data are collected through multiple acquisition links. Each raw data segment is processed to form a standardized acquisition segment, and the standardized acquisition segment is written into a first-level circular queue without blocking. S2: Data Processing Read the standardized acquisition segments from the first-level circular queue, and perform multi-channel data alignment and encapsulation processing on each standardized acquisition segment, wherein the encapsulation is into a complete data frame; S3: Outbound Processing: The complete data frames are written to at least one secondary circular queue, which includes independent transmit circular buffer queue channels and store circular buffer queue channels. The transmit circular buffer queue channel is used to perform transmit tasks, and the store circular buffer queue channel is used to perform write or store tasks.

[0032] refer to Figure 2 In step S1, the collected physiological signals or data include at least: electroencephalogram (EEG) signals, electromyogram (EMG) signals, electrocardiogram (ECG) signals, mandibular electrical signals, blood oxygen data, oral and nasal airflow data, nasal pressure data, chest and abdominal belt data, and snoring data.

[0033] Specifically: Physiological signals or data can be acquired through at least four links, with each link set up in parallel to independently complete actions such as acquisition, framing processing, and writing to a first-level circular queue; The first link is used for the acquisition of electroencephalogram (EEG) signals. EEG signals are acquired through the SPI serial interface, direct memory access (DMA) and the ADS1299 chip (ADS1299 chip). After frame processing to form standardized segments, the segments are written into the first-level circular queue.

[0034] The second link is used for the acquisition of signals such as mandibular electroencephalography (EEG), electromyography (EMG), and electrocardiography (ECG). The signals are acquired through the SPI serial interface, direct memory access (DMA), and ADS1299 chip. After frame processing to form standardized segments, they are written into the first-level circular queue.

[0035] The third link is used to collect data such as airflow from the mouth and nose, nasal pressure, chest and abdominal band, and snoring. It collects data such as airflow from the mouth and nose, nasal pressure, chest and abdominal band, and snoring through the ADC chip and direct memory access DMA and related sensors. After frame processing to form standardized segments, the data is written into the first-level circular queue.

[0036] The fourth link is used for blood oxygen data acquisition. Blood oxygen data, such as blood oxygen saturation (SpO2) and pulse rate (PR), is acquired through a blood oxygen probe and a universal asynchronous transceiver (UART). After being framed into standardized segments, the data is written into a primary circular queue.

[0037] In step S1, the original data segments are framed to form standardized acquisition segments; the standardized acquisition segments include at least: source identifier, segment number, timestamp, effective length and payload data; Source Identifier ID: Used to identify whether a segment belongs to blood oxygen (SpO2 / pulse rate), nasal and oral airflow / nasal pressure / chest and abdominal band / snoring, ADS1299 bioelectricity (EEG / EMG / jaw electrical activity / ECG), etc., to distinguish the type of physiological signal; Segment number: Used to check segment continuity, making it easy to find out if there are missing segments on the acquisition side; Timestamp: Used to record the acquisition time or the start time of a segment, supporting multi-source alignment and playback; Effective length: Used to indicate the length of the segment load; Payload data: raw sampled values ​​or sampled byte stream organized by channel.

[0038] In step S1, the write operation is performed in constant time; In step S1, the write operation is performed in a direct memory access (DMA) interrupt context or in a fast processing segment immediately following the interrupt, without performing any downstream write or send operations; thus, the enqueue operation is a constant-time setting, thereby avoiding blocking and preventing the introduction of unpredictable delays that could cause the DMA buffer to be overwritten the next time.

[0039] In step S1, the standardized acquisition segments acquired do not directly call the write or send interfaces, such as the write SD card interface or the send network interface, and do not wait for file system mutual exclusion, erase / write delay or wireless retransmission; thus structurally blocking the reverse transmission of I / O blocking to the acquisition side.

[0040] In step S1, when the system experiences short-term latency fluctuations, the primary queue acts as a near-source buffer to temporarily store data fragments. For example, latency fluctuations may include: frequent interruptions, task switching, and critical section occupancy. This allows processing tasks to be dequeued and processed at a more stable pace later.

[0041] In step S1, when the primary circular queue is full, existing unprocessed data segments are not overwritten. Instead, a queue status signal such as "queue full" is output, and a scheduling enhancement strategy is triggered. This could include increasing the priority of related processing tasks and outbound tasks, restricting non-critical sources, adjusting batch writes, or reducing a certain sampling strategy. Since the primary circular queue handles "near-source real-time segments," overwriting them would directly disrupt waveform continuity; therefore, priority protection is implemented by not overwriting them.

[0042] In step S2, after the data fragment is processed, it is not directly written (e.g., written to an SD card) or directly transmitted back. Instead, the result is written to a secondary circular queue. This achieves decoupling of acquisition and I / O, that is, decoupling of data acquisition from data input.

[0043] In step S2, the data segment can be processed using an MCU microprocessor or a CPU. The MCU microprocessor can be an STM32H743IIT model.

[0044] In step S3, the sending ring buffer queue channel and the storage ring buffer queue channel form two channels, which can be set serially or in parallel.

[0045] Sending circular buffer queue channel: used for sending tasks, such as sending data to the host computer via BW16. Storage ring buffer queue channel: used for storing tasks, such as writing or storing via SDMMC + FAT file system.

[0046] These two queue channels can be understood as different outbound direction buffers of the same "complete frame stream", or the same frame being distributed and entering two outbound buffers. The specific implementation method can be selected according to resource and consistency requirements, but all fall within the scope of the two-level buffer concept of this application.

[0047] In step S3, when there is an occasional long-term blockage (e.g., long-tail delay) during data writing or data transmission, the secondary circular queue continuously accumulates complete frame data during the blockage period, keeping the data acquisition and data processing links continuous; when the blockage is cleared, the outbound task performs batch dequeueing, writing and sending; thereby absorbing the long-tail delay of I / O.

[0048] In step S3, the preferred elements of the secondary circular queue are: complete frame data, which includes at least: frame header, frame payload, frame checksum, and frame trailer; wherein the frame checksum is a cyclic redundancy check (CRC) value. Frame header: Frame synchronization identifier, source ID, frame sequence number, timestamp, length information; Frame payload: Aligned multichannel data (such as EEG / EMG / ECG, etc.) or event data (such as snoring events, leg movement events, etc.). Frame check: CRC cyclic redundancy check, used to detect storage media errors, transmission errors or memory corruption; End of frame: Frame end marker.

[0049] Therefore, a unified data source is provided: storage and transmission start from the same set of "complete frames", ensuring that the data returned by the host computer and the data stored locally are consistent in terms of timestamp, sequence number and content, which facilitates comparison and verification.

[0050] In step S3, at least EEG, ECG, and EMG data are enqueued without overwriting. That is, it is preferable to continue using strict non-overwriting enqueuing to ensure that the "complete frame" is not overwritten and to avoid the formation of uncontrollable waveform gaps.

[0051] Furthermore, both the primary circular queue and the secondary circular queue are fixed-length cyclic first-in-first-out (FIFO) buffers. Each circular queue has a physical storage space of a contiguous memory array of length L, and the writing and reading of data are controlled by the enqueue pointer In and the dequeue pointer Out. Wherein, the length L is an integer power of 2, and the movement of the pointer is achieved by address wrapping through bit mask operation ((L-1)&(pointer value+1)).

[0052] Furthermore, both the primary and secondary circular queues are allocated fixed memory. For example, in the primary circular queue: interrupt context operations: writes to this queue occur during DMA interrupts or high-priority acquisition tasks. If dynamic memory is used, malloc may cause blocking or non-reentrancy issues.

[0053] Constant-time enqueueing: Fixed memory ensures that the enqueue operation takes a fixed amount of time. Regardless of how fragmented the system memory is, the CPU can complete the data transfer within a fixed time, thus responding promptly to the next DMA interrupt.

[0054] Absorbing short-term jitter: When multiple interrupts occur simultaneously, the head and tail pointers of the queue move extremely fast to ensure that no data is lost.

[0055] This protects the real-time nature of data acquisition and prevents it from being blocked by downstream processes.

[0056] For example, in a two-level circular queue: absorb long-tail I / O latency and decouple processing from storage / transmission; Absorbing bursts of congestion: When there is a second-level blockage during SD card writing or WiFi transmission, complete frames will accumulate in the secondary queue. If dynamic memory is used, frequent allocation / release can lead to memory fragmentation, which may exhaust memory over long periods of operation.

[0057] Supports batch operations: Storage / send tasks can retrieve data in batches from a fixed memory block, merge and write them, further improving throughput.

[0058] Avoid memory leaks: Fixed memory completely eliminates the risk of dynamic memory leaks caused by abnormal power outages or task restarts, ensuring the stability of the system running continuously overnight (>8 hours).

[0059] Both the primary and secondary circular queues employ a FIFO circular queue structure. The FIFO circular queue structure is explained below.

[0060] I. Core structural components; A FIFO circular queue uses a fixed-length contiguous memory array plus two pointers (in / out), forming a closed loop in overall logic. The following is a detailed breakdown or explanation: 1. Physical storage layer; Data buffer: A contiguous array of memory of length L, which is the physical space for storing actual data.

[0061] Key constraint: The array length L must be an integer power of 2 (e.g., 2 / 4 / 8 / 16 / 32). This is to enable the modulo operation to be performed quickly using (L-1) & the value (bitwise operations replace the modulo operation, improving efficiency).

[0062] 2. Control pointer layer; Two integer pointers modified by volatile (in / out) ensure atomicity in multi-threaded / interrupt-driven environments:

[0063] II. Working principle (taking length L=8 as an example) 1. Initialization state; When in = 0 and out = 0, all positions in the array are empty, resulting in an empty queue (in == out).

[0064] Verification: During initialization, it will forcibly check whether L is a power of 2 (FFASSERT(!(L&(L-1)))), and if not, it will freeze (while(1)).

[0065] 2. Enqueue operation; Logic: First, check if the queue is full, then write the data and move the in pointer.

[0066] Full queue check: ((L-1)&(in+1)) == out (i.e., the next write position is equal to the current read position).

[0067] Write process (taking L=8 as an example): If the queue is not full: write the data to data[in]; Incrementing the in pointer and taking the modulo: in = (L-1)&(in+1) (e.g., when in=7, (7)&8=0, returning to the starting point); If the queue is full: return FIFO_FULL, do not write.

[0068] 3. Dequeue (Out) operation; Logic: First check if the queue is empty, then read the data and move the out pointer.

[0069] Empty queue check: in == out; Reading process: If the queue is not empty and the read pointer is valid (data != NULL): read data[out] to the target address; The `out` pointer is incremented and moduloed: `out = (L-1)&(out+1)`; If the queue is empty: return FIFO_EMPTY, do not read; If the data pointer is null: Return FIFO_ERROR.

[0070] III. Visualizing State Transitions (L=8)

[0071] From the above, we can see that: 1. FIFO circular queue and its index wraparound mechanism: Use a fixed-length array to store the data; the length is a power of 2. Wrapping is accomplished using a bitmask; Full / empty determination rules are adopted; Provide a strict non-overlapping queuing policy.

[0072] 2. Construct a two-level buffer queue architecture for multi-source physiological signals or data: The primary circular queue receives the acquired segments, while the secondary circular queue receives the complete frames; Decouple data acquisition from I / O so that I / O blocking does not affect data acquisition; We use queue / backpressure strategies to ensure that critical data is not lost.

[0073] 3. Framed encapsulation mechanism and consistency verification mechanism The frame header contains the source ID, timestamp, sequence number, and length; The frame end includes a CRC checksum; Storage and transmission share the same "complete frame stream," ensuring consistency and auditability.

[0074] Thus, the primary circular queue and the secondary circular queue form a two-level buffer structure, which is conducive to achieving "no packet loss" data processing and transmission.

[0075] 1) Minimize the acquisition end: DMA interrupts only perform enqueueing and do not perform operations such as writing to SD or sending to the network to ensure real-time acquisition; 2) The primary circular queue is responsible for "interruption jitter resistance": When multiple sampling sources arrive in a short period of time, the primary queue absorbs fluctuations and jitter; that is, fixed memory and bit mask wrapping avoid uncertain overhead such as dynamic allocation and division modulo, reducing system jitter and improving long-term operational stability. 3) The secondary circular queue is responsible for "resisting long tail delays in I / O": During SD card or wireless congestion, the secondary circular queue continues to accumulate, and the data is released in batches after the congestion is cleared; that is, when long tail congestion occurs during SD card writing or wireless transmission, the congestion will only cause the secondary circular queue to accumulate, and will not slow down DMA interruption and acquisition tasks in the reverse, thereby significantly reducing the probability of packet loss and achieving continuous acquisition. 4) Key data non-coverage strategy: Strict non-coverage queuing is adopted for key data such as EEG / ECG / EMG. It is better to trigger back pressure (reduce the sampling rate of a certain part) or increase consumption priority than to cover historical data. 5) Framed data verification with sequence number and CRC value: This allows for objective verification of "no packet loss"; even if anomalies occur, the missing frame interval and error source can be located. This provides objective evidence for clinical data quality control and problem localization.

[0076] A circular queue-based double-buffered transmission system for multi-channel sleep monitoring data, used to perform the steps of the above method, includes: Acquisition module: Used to acquire raw data fragments of physiological signals or data from multiple links, form standardized acquisition fragments, and write them into a primary circular queue; Processing module: Aligns the standardized acquisition segments in the primary circular queue and encapsulates them into complete data frames; Outbound module: Writes complete data frames into at least one secondary circular queue. The send circular buffer queue channel is used to perform send tasks, and the storage circular buffer queue channel is used to perform write or storage tasks.

[0077] The above description only discloses some embodiments of the present invention. For those skilled in the art, various modifications and improvements can be made without departing from the inventive concept of the present invention, and these all fall within the scope of protection of the invention.

Claims

1. A double-buffered transmission method for multichannel sleep monitoring data using a circular queue, comprising: S1: Data Acquisition: Raw data segments of physiological signals or data are collected through multiple acquisition links. Each raw data segment is processed to form a standardized acquisition segment, and the standardized acquisition segment is written into a first-level circular queue without blocking. S2: Data Processing Read the standardized acquisition segments from the first-level circular queue, and perform multi-channel data alignment and encapsulation processing on each standardized acquisition segment, wherein the encapsulation is into a complete data frame; S3: Outbound Processing: The complete data frame is written to a secondary circular queue, which includes independent transmit circular buffer queue channels and store circular buffer queue channels. The transmit circular buffer queue channel is used to perform transmit tasks, and the store circular buffer queue channel is used to perform write or store tasks.

2. The method for double-buffered transmission of multichannel sleep monitoring data using a circular queue according to claim 1, characterized in that, In step S1, the collected physiological signals or data include at least: electroencephalogram (EEG) signals, electromyogram (EMG) signals, mandibular electrical signals, electrocardiogram (ECG) signals, blood oxygen data, oral and nasal airflow data, nasal pressure data, chest and abdominal belt data, and snoring data. In step S1, the original data fragments are framed to form standardized acquisition fragments; the standardized acquisition fragments include at least: source identifier, fragment number, timestamp, effective length and payload data.

3. The method for double-buffered transmission of multichannel sleep monitoring data using a circular queue according to claim 1, characterized in that, In step S1, the write operation is performed in constant time; In step S1, the write operation is performed in the Direct Memory Access (DMA) interrupt context or in the fast processing segment immediately following the interrupt, and no downstream write or send operation is performed. In step S1, the standardized acquisition segments are not directly called to write or send interfaces, and do not wait for file system mutual exclusion, erase / write delay or wireless retransmission.

4. The method for double-buffered transmission of multichannel sleep monitoring data using a circular queue according to claim 1, characterized in that, In step S1, when the system experiences short-term latency fluctuations or jitter, the primary circular queue acts as a near-source buffer to temporarily store data fragments. In step S1, when the queue of the first-level circular queue is full, the existing unprocessed data segments are not overwritten, but the queue status signal is output and the scheduling enhancement strategy is triggered.

5. The method for double-buffered transmission of multichannel sleep monitoring data using a circular queue according to claim 1, characterized in that, In step S2, after the data fragment is processed, it is not directly written or directly transmitted back. Instead, the result is written to a secondary circular queue to achieve decoupling of acquisition and I / O.

6. The method for double-buffered transmission of multichannel sleep monitoring data using a circular queue according to claim 1, characterized in that, In step S3, when there is an occasional long-term blockage during data writing or data transmission, the secondary circular queue continuously accumulates complete frame data during the blockage period, so that the data acquisition and data processing links remain continuous; when the blockage is cleared, batch dequeueing, writing and transmission are performed.

7. The method for double-buffered transmission of multichannel sleep monitoring data using a circular queue according to claim 1, characterized in that, In step S3, the complete frame data includes at least: frame header, frame payload, frame checksum, and frame trailer; wherein, the frame checksum is a cyclic redundancy check (CRC) value. In step S3, at least EEG, ECG, and EMG data are subject to an overwrite queuing policy.

8. The method for double-buffered transmission of multichannel sleep monitoring data using a circular queue according to claim 1, characterized in that, Both the primary circular queue and the secondary circular queue are equipped with a fixed-length cyclic first-in-first-out (FIFO) buffer. Each circular queue has a physical storage space of a contiguous memory array of length L, and the writing and reading of data are controlled by the enqueue pointer In and the dequeue pointer Out. Wherein, the length L is an integer power of 2, and the movement of the pointer is achieved by address wrapping through bitmask operations.

9. The method for double-buffered transmission of multichannel sleep monitoring data using a circular queue according to claim 1, characterized in that, Both the primary and secondary circular queues have fixed memory allocations.

10. A circular queue-based multi-channel sleep monitoring data double-buffered transmission system, characterized in that, include: Acquisition module: Used to acquire raw data fragments of physiological signals or data from multiple links, form standardized acquisition fragments, and write them into a primary circular queue; Processing module: Aligns the standardized acquisition segments in the primary circular queue and encapsulates them into complete data frames; Outbound module: Writes complete data frames to a secondary circular queue, sends a circular buffer queue channel for sending tasks, and stores a circular buffer queue channel for writing or storing tasks.