chenlh
2026-01-20 fe4d335b54ede7a47fd4bcf5c228fb427cbcc8c9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
 * dsp_report.cpp
 *
 *  Created on: 2025Äê7ÔÂ22ÈÕ
 *      Author: 86189
 */
 
#ifndef DSP_REPORT_CPP_
#define DSP_REPORT_CPP_
#include <cstring>
#include "dsp_report.h"
 
void ReportStatus::device_status_push(short ID , short* value, int numOfValue)
{
    int i;
    int found =0;
 
    if(numOfValue > 16) numOfValue =16 ;
 
    for(i = 0; i< device_status_count; i++){
        if(dev_status[i].ID == ID){
            found = 1;
            break;
        }
    }
 
    if(found){
        memcpy(dev_status[i].value , value,  numOfValue*sizeof(short));
    }
    else{
        dev_status[device_status_count].ID = ID;
        memcpy(dev_status[device_status_count].value, value,  numOfValue*sizeof(short));
        device_status_count++;
        device_status_count &= 15;
    }
}
 
int ReportStatus::get_device_status_ptr(char* data, int data_len)
{
    int size = device_status_count*sizeof(struct dsp_status_t);
    if(data_len < size) {
        return 0;
    }
 
    memcpy(data, dev_status, size);
    device_status_count =0; //reset
    return size;
}
 
#endif /* DSP_REPORT_CPP_ */