Source code for plot_sample_from_burst

UUT is running in Burst/RTM, eg at 50Hz.
Stream the data to host, then 
- pick out all the Start Of Burst ES, then store the next sample
- program plots time series for channel 1

Capture data example:

nc acq1001_343 4210 | pv > burst32-50Hz-512-3.bin

[pgm@harlosh RGM]$ hexdump -e '32/4 "%08x," "\n"' burst32-50Hz-512-3.bin | cut -d, -f1-8 | grep -n aa55f154 | head

import numpy as np
import matplotlib.pyplot as plt
import argparse

[docs]def raw2volts(xx): return float(xx/256 * 10.0 / 0x1000000)
[docs]def plot_data(args): fname =[0] # int32's are easier for math, uint's easier for ES detect. # wasting memory keeping a copy, but, memory is cheap.. rawi = np.fromfile(fname, dtype=np.int32) rawu = np.fromfile(fname, dtype=np.uint32) ll = len(rawi)/args.nchan lltrunc = ll * args.nchan chxi = np.reshape(rawi[0:lltrunc], (ll, args.nchan)) chxu = np.reshape(rawu[0:lltrunc], (ll, args.nchan)) # extract the first sample in each burst. Approx ll/rtm_translen, ll is safe .. chx = np.zeros((args.nchan, ll)) ss = 0 for ii in range(0, ll): if chxu[ii][0] == 0xaa55f154 and chxu[ii][1] == 0xaa55f154: for cc in range(0, args.nchan): chx[cc][ss] = raw2volts(chxi[ii+1][cc]) ss += 1 if ss < 10: print("{}, {}".format(ii, raw2volts(chxi[ii+1][0]))) print("number of samples: {}".format(ss)) plt.plot(chx[0][0:ss])
[docs]def run_main(): parser = argparse.ArgumentParser(description='rgm plot demo') parser.add_argument('--nchan', type=int, default=32) parser.add_argument('data', nargs=1, help="data ") plot_data(parser.parse_args())
# execution starts here if __name__ == '__main__': run_main()