FreeCalypso > hg > fc-sim-sniff
comparison sw/sniff-rx/byteproc.c @ 46:43f678895a3a
simtrace3-sniff-rx: add some annotations to output
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 31 Aug 2023 10:01:40 +0000 |
parents | b112c2df6c43 |
children |
comparison
equal
deleted
inserted
replaced
45:b0524d1dc6ef | 46:43f678895a3a |
---|---|
13 extern struct timeval curtime; | 13 extern struct timeval curtime; |
14 extern struct tm *cur_tm; | 14 extern struct tm *cur_tm; |
15 | 15 |
16 static int byte_pending_flag, byte_pending_val; | 16 static int byte_pending_flag, byte_pending_val; |
17 | 17 |
18 static void | |
19 annotate(new_byte) | |
20 { | |
21 if (new_byte & 0x80) { | |
22 fprintf(main_outf, " RST %s", new_byte & 0x40 ? "high" : "low"); | |
23 return; | |
24 } | |
25 switch (new_byte & 0x18) { | |
26 case 0x08: | |
27 fputs(" PPS1", main_outf); | |
28 return; | |
29 case 0x10: | |
30 fputs(" PPS spenh trigger", main_outf); | |
31 return; | |
32 case 0x18: | |
33 fputs(" Bad PPS catcher bits!", main_outf); | |
34 return; | |
35 } | |
36 } | |
37 | |
18 void | 38 void |
19 rx_byte_in(new_byte) | 39 rx_byte_in(new_byte) |
20 { | 40 { |
21 if (!byte_pending_flag) { | 41 if (!byte_pending_flag) { |
22 byte_pending_flag = 1; | 42 byte_pending_flag = 1; |
23 byte_pending_val = new_byte; | 43 byte_pending_val = new_byte; |
24 return; | 44 return; |
25 } | 45 } |
26 /* received complete 2-byte message from the FPGA */ | 46 /* received complete 2-byte message from the FPGA */ |
27 fprintf(main_outf, "[%02d:%02d:%02d.%06u] %02X%02X\n", cur_tm->tm_hour, | 47 fprintf(main_outf, "[%02d:%02d:%02d.%06u] %02X%02X", cur_tm->tm_hour, |
28 cur_tm->tm_min, cur_tm->tm_sec, (unsigned) curtime.tv_usec, | 48 cur_tm->tm_min, cur_tm->tm_sec, (unsigned) curtime.tv_usec, |
29 new_byte, byte_pending_val); | 49 new_byte, byte_pending_val); |
50 annotate(new_byte); | |
51 putc('\n', main_outf); | |
30 byte_pending_flag = 0; | 52 byte_pending_flag = 0; |
31 if (logfile_flag && (new_byte & 0x80)) | 53 if (logfile_flag && (new_byte & 0x80)) |
32 printf("SIM RST is %s\n", new_byte & 0x40 ? "high" : "low"); | 54 printf("SIM RST is %s\n", new_byte & 0x40 ? "high" : "low"); |
33 } | 55 } |
34 | 56 |