#SingleInstance Force SetTitleMatchMode, 2 SetBatchLines, -1 ;######################################################################## ;###### User Variables ################################################## ;######################################################################## RS232_Port = COM2 RS232_Baud = 19200 RS232_Parity = N RS232_Data = 8 RS232_Stop = 1 Console_Path = ;Ask User for Serial port InputBox, RS232_Port, TDS544A Capture, Set Serial Port, , , , , , , ,% RS232_PORT ;######################################################################## ;###### Script Variables ################################################ ;######################################################################## RS232_Settings = %RS232_Port%:baud=%RS232_Baud% parity=%RS232_Parity% data=%RS232_Data% stop=%RS232_Stop% dtr=Off ;######################################################################## ;###### Serial Port Receive ############################################# ;######################################################################## ;Quit_var is used to exit the RS232 COM port receive loop ; 0=Don't Exit; 1=Exit; CTRL-F1 to set to 1 and exit script. Quit_var = 0 RS232_FileHandle:=RS232_Initialize(RS232_Settings) ;get the file prefix := "TDS544A" FormatTime, timestamp, %A_Now%, yyyy-MM-dd HHmmss FileSelectFile, bitmapfile, S16, %prefix% %timestamp%.bmp, Save As, Bitmap File (*.bmp) if (bitmapfile = "") ExitApp ;open the file file := FileOpen(bitmapfile, "w") ;RS232 COM port receive loop binary = binaryBytes := 0x4B436 ;(640*480)+1078 for header, all White VarSetCapacity(binary, binaryBytes, 0xFF) binaryPtr := &binary binaryPtrStart := binaryPtr ASCII = ToolTip, Press HARDCOPY on the scope Progress, R0-40000, Ready to Capture, TDS544A Capture SetTimer, AutoStop, 500 ;no data for 500ms? stop. Loop { ;0xFF in the line below sets the size of the read buffer. Read_Data := RS232_Read(RS232_FileHandle,"0x4B436",RS232_Bytes_Received) ;MsgBox,RS232_FileHandle=%RS232_FileHandle% `n RS232_Bytes_Received=%RS232_Bytes_Received% `n Read_Data=%Read_Data% ; Variable that is set by RS232_Read() ;Process the data, if there is any. If (RS232_Bytes_Received > 0) { ;Prevent interruption during execution of this loop. Critical, On ;Begin Data to binary conversion Read_Data_Num_Bytes := StrLen(Read_Data) / 2 ;RS232_Read() returns 2 characters for each byte ;ASCII .= Read_Data Loop %Read_Data_Num_Bytes% { StringLeft, Byte, Read_Data, 2 StringTrimLeft, Read_Data, Read_Data, 2 Byte = 0x%Byte% Byte := Byte + 0 ;Convert to Decimal binaryPtr := NumPut(Byte, binaryPtr+0, "UChar") } Critical, Off Tooltip, } filesize := binaryPtr - binaryPtrStart Progress, % filesize ;CTRL-F1 sets Quit_var=1 if Quit_var = 1 Break } ;append data to file file.RawWrite(binary, filesize) file.Close ;FileAppend, %ASCII%, %bitmapfile%.txt RS232_Close(RS232_FileHandle) Sleep, 200 SplashImage, % bitmapfile, , % bitmapfile, Captured Image, TDS544A Capture Sleep, 5000 ExitApp ;Exit Script Return ;######################################################################## ;###### Exit Console Receive Loop ####################################### ;######################################################################## AutoStop: if (filesize = 0) return if (lastfilesize = filesize) Quit_var = 1 lastfilesize := filesize return ^F1:: Quit_var = 1 return