' ' CAN Datenlogger für Vector CANalyer "mc7-10.txt" Rev 8.0 (c) Avisaro AG, 17.12.2013 ' ' ------------------------------------------------ ' New file after 'new_file_s' Seconds (choose larger 3600 = 1h) let new_file_s = 14400 ' ------------------------------------------------ ' 2te CAN auxopen -8, 125000, 0, 536870911, 0, 0 ' ------------------------------------------------ ' Ports let red = -202 ' -207 for WAGO Boards, -203 for D-Sub Boards let green = -207 ' -208 for WAGO Boards, -204 for D-Sub Boards let inkey = -208 ' ------------------------------------------------ inmode -3 outmode -2 dim A(28) let t = time let id = 0 let in = 0 let temp$ = "mc 7-10" put -101, temp$ getcan A BEGIN: put green, #1 let n$ = date$ let f$ = "logs/" let f$ = f$ + mid$(date$, 6 , 2) + mid$(date$, 9 , 2) let f$ = f$ + mid$(time$, 1, 2) let f1$ = f$ + "_1.asc" let f2$ = f$ + "_2.asc" get -7, A get -8, A get inkey, in if in = 0 then sleep 1000 put green, #0 sleep 100 goto BEGIN end if close 1 close 2 exec "mkdir logs" sleep 1 open "AB", 1, f1$ if LASTERR <> 0 then open "WB", 1, f1$ if LASTERR <> 0 then close 1 goto BEGIN end if let out$ = "base hex timestamps absolute" put 1, out$ put 1, #13 put 1, #10 let out$ = "no internal events logged" put 1, out$ put 1, #13 put 1, #10 let out$ = "Begin Triggerblock " put 1, out$ put 1, date$ put 1, #32 put 1, time$ put 1, #13 put 1, #10 close 1 sleep 1 open "AB", 1, f1$ end if open "AB", 2, f2$ if LASTERR <> 0 then open "WB", 2, f2$ if LASTERR <> 0 then close 2 goto BEGIN end if let out$ = "base hex timestamps absolute" put 2, out$ put 2, #13 put 2, #10 let out$ = "no internal events logged" put 2, out$ put 2, #13 put 2, #10 let out$ = "Begin Triggerblock " put 2, out$ put 2, date$ put 2, #32 put 2, time$ put 2, #13 put 2, #10 close 2 sleep 1 open "AB", 2, f2$ end if put green, #1 put red, #1 let t = time + 1 let t_new_file = time + new_file_s do if t_new_file < time then close 1 close 2 goto BEGIN end if get -7, A if BYTESREAD = 28 then let bus$ = "1" gosub STORE_CAN end if get -8, A if BYTESREAD = 28 then let bus$ = "2" gosub STORE_CAN end if if t <= time then put red, #1 put green, #1 if lof(0) = 0 then close 1 close 2 put red, #0 goto BEGIN end if let t = time + 1 end if get inkey, in if in = 0 then 'Dies einkommentieren für Taste = Stop close 1 goto FIN_KEY 'Dies einkommentieren für Taste = Marker let bus$ = "XX" gosub STORE_MARKER end if loop FIN_KEY: put red, #0 get inkey, in if in = 0 then close 1 close 2 goto FIN_KEY end if FINISH: put red, #0 let x = lof(0) get inkey, in if (x < 10) or (in = 0) then goto BEGIN else goto FINISH end if goto BEGIN STORE_CAN: put red, #0 let t = time + 1 let out$ = str$(caninfo(6)) let l = len(out$) if l > 3 then let filestring$ = mid$(out$, 1 , l-3) + "." + right$(out$, 3) else let filestring$ = "0." + out$ end if let filestring$ = filestring$ + chr$(32) + bus$ + chr$(32) let i = caninfo(1) if i > 4095 then let filestring$ = filestring$ + hex$(caninfo(1), 8) + "x " else let filestring$ = filestring$ + hex$(caninfo(1), 3) + " " end if let filestring$ = filestring$ + chr$(32) + "Rx d " let can_dlc = caninfo(4) let filestring$ = filestring$ + str$(caninfo(4)) + chr$(32) for i=1 to can_dlc let filestring$ = filestring$ + hex$(a(11+i), 2) + chr$(32) next let filestring$ = filestring$ + chr$(13) + chr$(10) let errcnt = 0 WrToFl: if bus$ = "1" then put 1, filestring$ else put 2, filestring$ end if if LASTERR <> 0 and errcnt < 5 then let errcnt = errcnt + 1 sleep 1 goto WrToFl end if return STORE_MARKER: put red, #0 put 1, bus$ put 1, #44 put 1, date$ put 1, #44 put 1, time$ put 1, #44 REM put 1, #13 put 1, #10 put red, #0 return ' +++