
' =============================================================
'  This example receive all the file with a single buffer
'  It could not work if file-length is more then buffer-length
' =============================================================

FileName = "FileReceived.csv"
COM Open 13 115200
Gosub ReceiveFileFromCOM
Stop

Label ReceiveFileFromCOM
	Variable String FileName
	Variable String Str1
	'
	COM DiscardInBuffer
	'
	For v1 = 1 To 9e99
		s1 = COM_Received
		If s1 <> ""
			If s1 = "{{{FileStartMarker}}}"
				Wait Seconds 1
				Str1 = COM_Received
				Str1 = Replace(Str1, "{{{CRLF}}}", CRLF)
				Save DeleteFile FileName
				Save StringToFile Str1 FileName
				Exit
			EndIf
		EndIf
		Wait Seconds 0.01
	Next
Return


'WATCH s1
