Files
MiPi_TEST/__pycache__/analyze_captures.cpython-312.pyc

97 lines
11 KiB
Plaintext
Raw Normal View History

2026-04-08 14:19:31 +01:00
<EFBFBD>
R<EFBFBD>iu#<00><00>@<00>dZddlZddlZddlmZddlmZddlZddlZddlm Z m
Z
m Z m Z m Z ee<0E>jdz Zee<0E>jdz ZdZd Zd
Z dd ed ed eeefdedeeee ff
d<10>Zdeedefd<12>Zddeddfd<14>Zdd<15>Zedk(re<1E>yy)a<>
analyze_captures.py
Groups MIPI oscilloscope CSV files by capture, runs csv_preprocessor on each,
then sends the compact summaries to the Claude API for trend analysis.
Usage:
python analyze_captures.py # all captures in ./data
python analyze_captures.py --last N # most recent N captures only
python analyze_captures.py --capture 0001 # single capture by number
<EFBFBD>N)<01>datetime)<01>Path)<05> analyze_file<6C>analyze_lp_file<6C>group_captures<65>ChannelMetrics<63> LPMetrics<63>datazanalysis_log.txtz http://192.168.45.8:5000/displayzclaude-opus-4-6a<36>You are an expert in MIPI D-PHY signal integrity analysis. You will be given compact pre-processed summaries of oscilloscope captures from a MIPI CLK and DAT0 differential pair. Each capture has three passes: sig (high-res HS quality), proto (long-window HS stats), and lp (single-ended, shows LP-11/LP-00/HS burst structure including the SoT sequence). Analyse the data for trends, degradation, anomalies, or consistent spec concerns across captures. Be concise and actionable.<2E>ts<74>num<75>files<65>verbose<73>returnc<00><><00>d|d<02>d|<00>d<04>g}g}dD]<5D>}||vr|jd|<06>d<07><03><00> |jd<08>rt||<00>}nt||<00>}|j|j <00><00>|j|<07>|rt |j <00><00><00><>d j|<04>|fS#t $r!}|jd|<06>d |<08><00><04>Yd
}~<08><>d
}~wwxYw) z<>
Run the pre-processor on all CSV files for one capture.
Returns (text_summary, list_of_metrics).
Missing files produce a one-line note instead of crashing.
z === Capture <20>04d<34> z ===)<06> proto_clk<6C> proto_dat<61>sig_clk<6C>sig_dat<61>lp_clk<6C>lp_datz [z ] MISSING<4E>lp_z ] ERROR: N<>
)<08>append<6E>
startswithrr<00>summary<72>print<6E> Exception<6F>join) r r r r<00>lines<65> metrics_list<73>key<65>m<>excs <20>5/home/david-rice/Python/MiPi_Test/analyze_captures.py<70>process_capturer'+s<><00><00><1C>C<EFBFBD><03>9<EFBFBD>B<EFBFBD>r<EFBFBD>d<EFBFBD>$<24> /<2F> 0<>E<EFBFBD>57<35>L<EFBFBD>S<>4<><03> <0E>e<EFBFBD> <1B> <11>L<EFBFBD>L<EFBFBD>3<EFBFBD>s<EFBFBD>e<EFBFBD>9<EFBFBD>-<2D> .<2E> <14>
4<><12>~<7E>~<7E>e<EFBFBD>$<24>#<23>E<EFBFBD>#<23>J<EFBFBD>/<2F><01> <20><15>s<EFBFBD><1A>,<2C><01> <11>L<EFBFBD>L<EFBFBD><11><19><19><1B> %<25> <18> <1F> <1F><01> "<22><16><15>a<EFBFBD>i<EFBFBD>i<EFBFBD>k<EFBFBD>"<22><>4<> <10>9<EFBFBD>9<EFBFBD>U<EFBFBD> <1B>\<5C> )<29>)<29><><19> 4<> <11>L<EFBFBD>L<EFBFBD>3<EFBFBD>s<EFBFBD>e<EFBFBD>9<EFBFBD>S<EFBFBD>E<EFBFBD>2<> 3<> 3<><33> 4<>s<00>A9B<<02>< C&<05>C!<05>!C&<05> all_summariesc<00>0<00>dj|<00>}d|<01>d<03>S)Nz
uDBelow are pre-processed summaries of MIPI D-PHY captures. Each capture has three passes per lane (CLK and DAT0):
sig — high-res HS differential (rise/fall times)
proto — long-window HS differential (jitter, clock freq, amplitude)
lp — single-ended LP state capture (LP-11 voltage, SoT sequence, HS bursts)
u@
Please:
1. Identify any consistent spec concerns (HS voltage, LP-11 voltage, LP-low timing).
2. Highlight any trends over captures (amplitude drift, jitter, LP-11 voltage, etc.).
3. Flag anomalies — missing LP transitions, short LP-low, unexpected burst counts.
4. Summarise overall signal health in 23 sentences.)r )r(<00>bodys r&<00> build_promptr+Ls.<00><00> <11>;<3B>;<3B>}<7D> %<25>D<EFBFBD> a<01>
<10>&<26>A<01>
A<01> <06><00>lastc<00><00>tt<00>}|s td<01>yt|j <00><00>| d}tdt |<02><00>d<04><03>g}|D]+\}}t |||||f<00>\}}|j|<06><00>-t|<03>}tdt |<08>d<06>dt<00>d<08><05>tj<00>} | jjtd td
|d <0B>g<01> <0C>}
|
jd j } d|
j"j$<00>d|
j"j&<00>d<10>} d} td| <0A><00><02>td<13>t| <0A>t| <0B>td| <0C>d<15><03>t| dz<00>t)j*<00>j-d<16>}t/t0dd<18><19>5}|j3dd<11>d|<04>d|d dd<1C>d|ddd<1C>dd<11>d<12> <0B>|j3| <0B>|j3d| <0C>d <20><03>ddd<02>td!t0<00><00><02> t5j6t8d"| id#<23>$<24>td%<25>y#1swY<00>FxYw#t:$r}td&|<0F><00><02>Yd}~yd}~wwxYw)'z<>
Called by mgmt_worker after each file transfer.
Analyses the most recent `last` captures and prints the Claude report.
z[ANALYSIS] No captures found.Nz
[ANALYSIS] Processing z most-recent capture(s)...z[ANALYSIS] Sending <20>,z
chars to z...<2E><00>user<65><02>role<6C>content<6E><04>model<65>
max_tokens<EFBFBD>system<65>messagesr<00>Tokens: <20> in / <20> out<75><============================================================rzCLAUDE ANALYSIS<49>(<28>)<29>%Y-%m-%d %H:%M:%S<>a<>utf-8<><01>encodingu — captures <20>ru<><E28093><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
(<28>)
z[ANALYSIS] Report appended to <20>text<78><00><02>json<6F>timeoutz"[ANALYSIS] Report sent to display.z [ANALYSIS] Display send failed: )r<00>DATA_DIRr<00>sorted<65>keys<79>lenr'rr+<00> CLAUDE_MODEL<45> anthropic<69> Anthropicr9<00>create<74> SYSTEM_PROMPTr4rI<00>usage<67> input_tokens<6E> output_tokensr<00>now<6F>strftime<6D>open<65> ANALYSIS_LOG<4F>write<74>requests<74>post<73> DISPLAY_URLr)r-<00>groupsrPr(r r <00> summary_text<78>_<>prompt<70>client<6E>message<67>analysis<69>
token_line<EFBFBD> separator<6F>f<>es r&<00> run_analysisrmas<00><00>
<1C>H<EFBFBD> %<25>F<EFBFBD> <11> <0A>-<2D>.<2E><0E> <11>&<26>+<2B>+<2B>-<2D> <20>$<24><15><16> (<28>D<EFBFBD> <09> $<24>S<EFBFBD><14>Y<EFBFBD>K<EFBFBD>/I<>
J<EFBFBD>K<>!<21>M<EFBFBD><17>+<2B><07><02>C<EFBFBD>)<29>"<22>c<EFBFBD>6<EFBFBD>2<EFBFBD>s<EFBFBD>)<29>3D<33>E<><0F> <0C>a<EFBFBD><15><1C><1C>\<5C>*<2A>+<2B><1A>-<2D> (<28>F<EFBFBD> <09> <1F><03>F<EFBFBD> <0B>A<EFBFBD><EFBFBD>j<EFBFBD><1C><0E>c<EFBFBD>
J<EFBFBD>K<><17>!<21>!<21>#<23>F<EFBFBD><14>o<EFBFBD>o<EFBFBD>$<24>$<24>!<21><19>"<22>%<25>&<26>9<>:<3A> %<25><06>G<EFBFBD> <17><EFBFBD><EFBFBD>q<EFBFBD>!<21>&<26>&<26>H<EFBFBD><1B>G<EFBFBD>M<EFBFBD>M<EFBFBD>6<>6<>7<>v<EFBFBD>g<EFBFBD>m<EFBFBD>m<EFBFBD>>Y<>>Y<>=Z<>Z^<5E>_<>J<EFBFBD><19>I<EFBFBD> <09>B<EFBFBD>y<EFBFBD>k<EFBFBD>
<1A><1B> <09>
<1B><1C> <09>)<29><14> <09>(<28>O<EFBFBD> <09>A<EFBFBD>j<EFBFBD>\<5C><11>
<1B><1C> <09>)<29>d<EFBFBD>
<1A><1B>
<12><1C><1C><1E> <20> <20>!4<> 5<>B<EFBFBD> <0A>l<EFBFBD>C<EFBFBD>'<27> 2<>'<27>a<EFBFBD> <09><07><07>"<22>V<EFBFBD>H<EFBFBD>B<EFBFBD>r<EFBFBD>d<EFBFBD>"2<>4<EFBFBD><01>7<EFBFBD>1<EFBFBD>:<3A>c<EFBFBD>2B<32>#<23>d<EFBFBD>2<EFBFBD>h<EFBFBD>q<EFBFBD>k<EFBFBD>RU<52>EV<45>VX<56>Y_<59>X`<60>`b<>c<>d<> <09><07><07><08><19> <09><07><07>#<23>j<EFBFBD>\<5C><13>%<25>&<26>'<27>
<EFBFBD> *<2A><<3C>.<2E>
9<EFBFBD>:<3A>6<><10> <0A> <0A>k<EFBFBD><16><18>(:<3A>A<EFBFBD>F<> <0A>2<>3<>'<27>'<27><> <15>6<> <0A>0<><11><03>4<>5<>5<><35>6<>s%<00><AI<03>-)I#<00>I <07># J<03>,I?<03>?Jc
<00><><00>tjd<01><02>}|jdtddd<05><06>|jdtddd <09><06>|jd
d d <0C> <0A>|jdd d<0F> <0A>|j <00>}t t<00>}|s7tdt<00><00>tj<00><11>tjd<12>t|j<00><00>}|j<00>mt|j<00>}|D<00>cgc] }|d|k(s<01> |<05><02>}}|s>td|j<00>d<14>tj<00><11>tjd<12>|j<00>||j d}tdt!|<03><00>dt<00>d<17><05>g}|D]V\}}t#|||||f|j$<00><18>\} }
|j'| <09>|j$r<01>Etd|d<1A>d|<07><00><04><00>Xt)|<06>} |j*rtd<1C>t| <0B>ytdt!| <0B>d<1E>dt,<00>d <20><05>t/j0<00>} | j2j5t,d!t6d"| d#<23>g<01>$<24>} | j8d%j:}d&| j<j><00>d'| j<j@<00>d(<28>}d)}tCjD<00>jGd*<2A>}td|<10>d+|<10><00><04>t|<0E>td,|<0F>d-<2D><03>t|<10>tItJd.d/<2F>0<EFBFBD>5}|jMd|<10>d|<07>d|<10>d<17><07>|jM|<0E>|jMd1|<0F>d2<64><03>ddd<00>td3tJ<00><00><02> tOjPtRd4|id5<64>6<EFBFBD>td7<64>ycc}w#1swY<00>KxYw#tT$r}td8|<12><00><02>Yd}~yd}~wwxYw)9Nz%Analyse MIPI CSV captures with Claude)<01> descriptionz--last<73>Nz'Process only the N most recent captures)<04>type<70>default<6C>metavar<61>helpz --capture<72>NUMz+Process a single capture number (e.g. 0001)z --verbose<73>
store_truez"Print per-file summaries to stdout)<02>actionrtz --dry-runz5Print summaries and prompt but do not call Claude APIzNo CSV files found in )<01>filerEzCapture z not found.z Processing z capture(s) from r)rz Processed capture rrz,
--- Prompt that would be sent to Claude ---z
Sending r/z characters to z...
r0r1r2r5rr:r;r<r=r@z
CLAUDE ANALYSIS
r>r?rArBrCrGrHz
Report appended to rIrJrKzReport sent to display.zDisplay send failed: )+<2B>argparse<73>ArgumentParser<65> add_argument<6E>int<6E>str<74>
parse_argsrrNr<00>sys<79>stderr<72>exitrOrP<00>capturer-rQr'rrr+<00>dry_runrRrSrTr9rUrVr4rIrWrXrYrrZr[r\r]r^r_r`rar)<13>parser<65>argsrbrP<00>
target_num<EFBFBD>kr(r r rcrdrerfrgrhrirjrkrls r&<00>mainr<6E><00>s<><00><00> <15> $<24> $<24>1X<31> Y<>F<EFBFBD>
<EFBFBD><17><17><08>#<23><04>c<EFBFBD>F<><18>H<01>
<EFBFBD><17><17> <0B>#<23><04>e<EFBFBD>J<><18>L<01>
<EFBFBD><17><17> <0B>L<EFBFBD>A<><18>C<01>
<EFBFBD><17><17> <0B>L<EFBFBD>T<><18>V<01> <11> <1C> <1C> <1E>D<EFBFBD><1C>H<EFBFBD> %<25>F<EFBFBD> <11> <0A>&<26>x<EFBFBD>j<EFBFBD>1<><03>
<EFBFBD>
<EFBFBD>C<> <0B><08><08><11> <0B> <11>&<26>+<2B>+<2B>-<2D> <20>D<EFBFBD> <0B>|<7C>|<7C><1F><18><14><1C><1C>&<26>
<EFBFBD><1F>6<>a<EFBFBD>1<EFBFBD>Q<EFBFBD>4<EFBFBD>:<3A>#5<><01>6<><04>6<><13> <11>H<EFBFBD>T<EFBFBD>\<5C>\<5C>N<EFBFBD>+<2B>6<>S<EFBFBD>Z<EFBFBD>Z<EFBFBD> H<> <0F>H<EFBFBD>H<EFBFBD>Q<EFBFBD>K<EFBFBD> <0B>y<EFBFBD>y<EFBFBD><1C><13>T<EFBFBD>Y<EFBFBD>Y<EFBFBD>J<EFBFBD>K<EFBFBD> <20><04> <09>K<EFBFBD><03>D<EFBFBD> <09>{<7B>"3<>H<EFBFBD>:<3A>R<EFBFBD>
@<40>A<> "<22>M<EFBFBD><17>:<3A><07><02>C<EFBFBD>)<29>"<22>c<EFBFBD>6<EFBFBD>2<EFBFBD>s<EFBFBD>)<29>3D<33>d<EFBFBD>l<EFBFBD>l<EFBFBD>[<5B><0F> <0C>a<EFBFBD><15><1C><1C>\<5C>*<2A><13>|<7C>|<7C> <11>(<28><13>S<EFBFBD> <09><12>B<EFBFBD>4<EFBFBD>8<> 9<> :<3A><1A>-<2D> (<28>F<EFBFBD> <0B>|<7C>|<7C> <0A>=<3D>><3E> <0A>f<EFBFBD> <0A><0E>
<EFBFBD>J<EFBFBD>s<EFBFBD>6<EFBFBD>{<7B>1<EFBFBD>o<EFBFBD>_<EFBFBD>\<5C>N<EFBFBD>%<25>
H<EFBFBD>I<><18>"<22>"<22>$<24>F<EFBFBD><15><EFBFBD><EFBFBD>%<25>%<25>!<21><19>"<22>%<25>&<26>9<>:<3A> &<26><06>G<EFBFBD> <19><1F><1F><11>#<23>(<28>(<28>H<EFBFBD><1B>G<EFBFBD>M<EFBFBD>M<EFBFBD>6<>6<>7<>v<EFBFBD>g<EFBFBD>m<EFBFBD>m<EFBFBD>>Y<>>Y<>=Z<>Z^<5E>_<>J<EFBFBD><19>I<EFBFBD><19><1C><1C><1E>(<28>(<28>)<<3C>=<3D>B<EFBFBD>
<EFBFBD>B<EFBFBD>y<EFBFBD>k<EFBFBD>,<2C>Y<EFBFBD>K<EFBFBD>
8<EFBFBD>9<> <09>(<28>O<EFBFBD> <09>A<EFBFBD>j<EFBFBD>\<5C><11>
<1B><1C> <09>)<29><14>
<0E>l<EFBFBD>C<EFBFBD>'<27> 2<>'<27>a<EFBFBD> <09><07><07>"<22>Y<EFBFBD>K<EFBFBD>r<EFBFBD>"<22><14>R<EFBFBD> <09>{<7B>"<22>5<>6<> <09><07><07><08><19> <09><07><07>#<23>j<EFBFBD>\<5C><13>%<25>&<26>'<27>
<EFBFBD> !<21>,<2C><1E>
0<EFBFBD>1<>+<2B><10> <0A> <0A>k<EFBFBD><16><18>(:<3A>A<EFBFBD>F<> <0A>'<27>(<28><>q7<>^'<27>'<27><> <15>+<2B> <0A>%<25>a<EFBFBD>S<EFBFBD>)<29>*<2A>*<2A><>+<2B>s1<00> O<04>O<04>9AO<03>)O<00>O<07> O2<03>O-<03>-O2<03>__main__)F)<01>
)rN) <20>__doc__ryrr<00>pathlibrrSr_<00>csv_preprocessorrrrrr <00>__file__<5F>parentrNr]rarRrVr}r|<00>dict<63>bool<6F>tuple<6C>listr'r+rmr<><00>__name__<5F>r,r&<00><module>r<>s<><00><01>
<04><10>
<EFBFBD><1D><18><10><0F>e<>e<><13>H<EFBFBD>~<7E>$<24>$<24>v<EFBFBD>-<2D><08><13>H<EFBFBD>~<7E>$<24>$<24>'9<>9<> <0C>1<> <0B>"<22> <0C>2<><0E>&<1A> *<2A> <0B>*<2A> <0C>*<2A> <10><03>T<EFBFBD> <09>?<3F>*<2A><12> *<2A>
 <0B>3<EFBFBD><04>^<5E>$<24> $<24>%<25> *<2A>B<06><04>S<EFBFBD> <09><06>c<EFBFBD><06>*56<>s<EFBFBD>56<>D<EFBFBD>56<>pP+<2B>f <0C>z<EFBFBD><19><08>F<EFBFBD>r,