;
;
;
common pr_sci5k_heads_blk, u
if (n_elements(u) ne 0) then begin  ; close up from last time through
    close, u
    free_lun, u
end
;
task_pn = string(format='((A),"/mdi_sci")',getenv("MDI_TASK_DIR"))
;spawn,[task_pn,'-p', '-m 200'],unit=u,/noshell
spawn,[task_pn,'-p', '-s 1'],unit=u,/noshell
b = intarr(199)         ; 398 bytes 
b0 = bytarr(398*4)         ; 398 bytes 
;
none_cnt = 0
i=0L
while 1 do begin
  readu,u,b0
  b = fix(b0(indgen(398)*4+3), 0, 199)
  b = unsign(b, 16)
  if (keyword_set(qstop)) then stop
  ;;dec2sun, b
  ;pmm, b
  ;print, b(0:15)
  ss  = where(b eq 'aa55'x, nss)
  ss3 = where(b eq '55aa'x, nss3)
  ss2 = where(b eq 'bfff'x, nss2)
  ;;print, i, min(b), max(b), nss, nss2, nss3, format='(i6, 3x, 2(1x, z4.4), 3i6)'
  ;;help, where(b0 eq 'aa'x)
  ;;print, b(0:15) and 'ffff'x, format='(16(1x,z4.4))'
  ;
  ;;print, b(0:15), format='(16(1x,z4.4))'
  for ii=0,nss-1 do begin
    ist = ss(ii)
    ien = (ist + 20) < 198
    print, i, b(ist:ien), format = '(i6,3x, 36(1x,z4.4))'
    none_cnt = 0
  end
  none_cnt = none_cnt + 1
  if ((none_cnt mod 30) eq 29) then print, 'Still receiving data - no data segments for last ', none_cnt, ' packets'
  i = i + 1
end
;
close, u
end
