implemented -- it runs C program and passes log filename to the plotter

This commit is contained in:
2025-10-02 13:36:35 +03:00
parent 26841ba30e
commit 60a5c90c88
4 changed files with 48 additions and 3 deletions

Binary file not shown.

2
do Executable file
View File

@ -0,0 +1,2 @@
#!/usr/bin/bash
./plotter.py "$(./BF_companion 2>&1 1>/dev/tty)"

3
main.c
View File

@ -154,7 +154,7 @@ static uint32_t f_channels[ADC_LCH_CNT] = {0, 0, 1, 0};
// режимы измерения для каналов // // режимы измерения для каналов //
static uint32_t f_ch_modes[ADC_LCH_CNT] = {X502_LCH_MODE_COMM, X502_LCH_MODE_COMM,X502_LCH_MODE_COMM,X502_LCH_MODE_COMM}; static uint32_t f_ch_modes[ADC_LCH_CNT] = {X502_LCH_MODE_COMM, X502_LCH_MODE_COMM,X502_LCH_MODE_COMM,X502_LCH_MODE_COMM};
// диапазоны измерения для каналов // // диапазоны измерения для каналов //
static uint32_t f_ch_ranges[ADC_LCH_CNT] = {X502_ADC_RANGE_1, X502_ADC_RANGE_1,X502_ADC_RANGE_1,X502_ADC_RANGE_1}; static uint32_t f_ch_ranges[ADC_LCH_CNT] = {X502_ADC_RANGE_5, X502_ADC_RANGE_5,X502_ADC_RANGE_5,X502_ADC_RANGE_5};
@ -1303,6 +1303,7 @@ int main(int argc, char** argv) {
printf("\n\nreceive done. Exiting...\n\n\n"); printf("\n\nreceive done. Exiting...\n\n\n");
//logfile_ptr = fopen(logfilename, "w"); //logfile_ptr = fopen(logfilename, "w");
printf("dumped to file: %s\n", logfilename); printf("dumped to file: %s\n", logfilename);
fprintf(stderr, "%s\n", logfilename);
X502_Close(hnd); X502_Close(hnd);
// освобождаем описатель // освобождаем описатель

View File

@ -4,6 +4,15 @@ from decimal import *
from sys import argv from sys import argv
t_x502_sync_mode = ["INTERNAL", "EXTERNAL_MASTER", "SYN1_RISE", "SYN1_FALL", "SYN2_RISE", "SYN2_FALL", "???"]
t_x502_lch_mode = ["COMM", "DIFF", "ZERO", "???"]
t_x502_adc_range = ["+-10V", "+-5V", "+-2V", "+-1V", "+-0.5V", "+-0.2V", "???"]
ADC_settings = {"sync_frec_source":"???", "sync_start_source": "???", "chans":{}}
def main(): def main():
chart = go.Figure() chart = go.Figure()
chart.add_trace(go.Scatter(x=[1,2,3], y=[1,2,3])) chart.add_trace(go.Scatter(x=[1,2,3], y=[1,2,3]))
@ -11,6 +20,8 @@ def main():
if __name__ == "__main__": if __name__ == "__main__":
print("parsing")
print("=======================")
if len(argv) == 1: if len(argv) == 1:
main() main()
else: else:
@ -33,9 +44,33 @@ if __name__ == "__main__":
data[header] = [] data[header] = []
data[header + "_N"] = [] data[header + "_N"] = []
data[header + "_hex"] = [] data[header + "_hex"] = []
data[header].append(int(value,16)) value_unsigned = int(value, 16)
if (value_unsigned > 0x7FFFFF):
value_signed = (value_unsigned) - 0xFFFFFF
else:
value_signed = value_unsigned
data[header].append(value_signed)
data[header + "_hex"].append(value) data[header + "_hex"].append(value)
data[header + "_N"].append(values_N) data[header + "_N"].append(values_N)
else:
line_splt = line.split()
print(line_splt)
if line_splt[0] == "sync_frec_source:":
val = int(line_splt[1])
ADC_settings["sync_frec_source"] = t_x502_sync_mode[val]
elif line_splt[0] == "sync_start_source:":
val = int(line_splt[1])
ADC_settings["sync_start_source"] = t_x502_sync_mode[val]
elif line_splt[0] == "chan:":
chan_N = int(line_splt[1][:-1])
chan_mode = int(line_splt[3][:-1])
chan_range = int(line_splt[5])
ADC_settings["chans"][chan_N] = {"mode":t_x502_lch_mode[chan_mode], "range":t_x502_adc_range[chan_range]}
else:
print("strange line:")
print(line)
except ValueError: except ValueError:
pass pass
except IndexError: except IndexError:
@ -45,12 +80,19 @@ if __name__ == "__main__":
pass pass
f.close() f.close()
print("data samples:", values_N) print("data samples:", values_N)
print(ADC_settings)
ADC_settings_str = ""
ADC_settings_str += "sync_frec_source: " + ADC_settings["sync_frec_source"] + "<br>"
ADC_settings_str += "sync_start_source: " + ADC_settings["sync_start_source"] + "<br>"
for key, val in ADC_settings["chans"].items():
ADC_settings_str += " chan" + str(key) + ": " + str(val)+ "<br>"
print(ADC_settings_str)
chart = go.Figure() chart = go.Figure()
chart.update_layout(title=argv[1] + "<br>" + ADC_settings_str)
for key, val in data.items(): for key, val in data.items():
if (key.count("_N") + key.count("_hex")) == 0: if (key.count("_N") + key.count("_hex")) == 0:
#print(key+"_hex :", data[key+"_hex"]) #print(key+"_hex :", data[key+"_hex"])
chart.add_trace(go.Scattergl(x=data[key+"_N"], y=data[key], name=key, mode="lines", text=data[key+"_hex"])) chart.add_trace(go.Scattergl(x=data[key+"_N"], y=data[key], name=key, mode="lines", text=data[key+"_hex"]))
# chart.add_trace(go.Scattergl(x=data[key+"_N"], y=data[key], name=key, mode="lines+markers", text=data[key+"_hex"])) # chart.add_trace(go.Scattergl(x=data[key+"_N"], y=data[key], name=key, mode="lines+markers", text=data[key+"_hex"]))
chart.update_layout(title=argv[1])
chart.show() chart.show()