Author |
Topic |
|
moeknows164
USA
4 Posts |
Posted - 06/22/2020 : 02:44:03
|
Is it possible to get a copy of the code how the data is sent to Excel |
RAStaszak |
|
Reply #1
EmfDev
2250 Posts |
Posted - 06/22/2020 : 09:53:00
|
Hi moeknows164, is it for the history data? or for the graph data? |
|
|
Reply #2
moeknows164
USA
4 Posts |
Posted - 06/22/2020 : 19:45:43
|
It is for the history data |
RAStaszak |
|
|
Reply #3
EmfDev
2250 Posts |
Posted - 06/23/2020 : 09:47:23
|
First you have to use the SPIR command to fetch the raw data from the unit. The end of the data can be regcognized by 0xFF 0xFF means no data in there.
after fetching the data you have to decode.
code is something like this
typedef union floatUnionT { float f; unsigned char uc[4]; }floatUnionT; floatUnionT emf, ef, rf; for(unsigned long i = 0; i < END_OF_DATA; ) { unsigned char byte1 = DATA[i++]; unsigned char byte2 = DATA[i++]; if((byte1 == 0x55) && (byte2 == 0xAA)) // time { unsigned char time[6]; for(int j = 0; j < 6; j++) time[j] = DATA[i++]; } else if((byte1 == 0xAA) && (byte2 == 0x55)) // data { unsigned char byte3 = DATA[i++]; unsigned char byte4 = DATA[i++]; unsigned int temp = ((unsigned int) byte3 << 8) | byte4; unsigned int emf_int = (temp >> 4) & 0x0FFF; unsigned char emf_dec = temp & 0x0F; emf.f = (emf_int + emf_dec/10); // emf.f is emf float ef.uc[0] = DATA[i++]; ef.uc[1] = DATA[i++]; ef.uc[2] = DATA[i++]; ef.uc[3] = DATA[i++];
rf.uc[0] = DATA[i++]; rf.uc[1] = DATA[i++]; rf.uc[2] = DATA[i++]; rf.uc[3] = DATA[i++]; float mwm2 = rf.f/100000; float mwcm2 = rf.f/1000000000;
// Possible Source char sbuf[16]; memset(sbuf,0,16); if(DATA[i] == 0x5A) { unsigned char s = DATA[i+1]; i+=2; if(s == 0) sprintf(sbuf, "---"); else if(s == 1) sprintf(sbuf, "Smart Meter"); else if(s == 2) sprintf(sbuf, "Cell Tower"); else if(s == 3) sprintf(sbuf, "Microwave"); else if(s == 4) sprintf(sbuf, "WiFi/Phone"); else if(s == 5) sprintf(sbuf, "Static"); else if(s == 6) sprintf(sbuf, "AC EF"); else if(s == 7) sprintf(sbuf, "Power Line"); else sprintf(sbuf, "Mixed"); }
|
|
|
Reply #4
mserdag
Argentina
8 Posts |
Posted - 01/18/2024 : 05:40:35
|
Hi, i copy this code and translate to python, the only thing is that the code
ef.uc[0] = DATA[i++]; ef.uc[1] = DATA[i++]; ef.uc[2] = DATA[i++]; ef.uc[3] = DATA[i++];
rf.uc[0] = DATA[i++]; rf.uc[1] = DATA[i++]; rf.uc[2] = DATA[i++]; rf.uc[3] = DATA[i++];
is not the same result that when i use your software, the rest of all, i read the same data, what i do wrong? |
|
|
|
Topic |
|
|
|