| 
					
				 | 
			
			
				@@ -177,6 +177,7 @@ type 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     stopit: boolean;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     activeFile: string;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     dirty: boolean;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    function readString(var line: string): boolean;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     procedure saveSection(filename: string; key: string);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     procedure loadSection(filename: string; key: string);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -749,63 +750,10 @@ end; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 function TForm1.serialUpload: string;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 var
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  hexFileSource: TStringList;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  hexFile, tmp, line: string;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  pos, x: integer;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  hexFile: string;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 begin
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  pos := 0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  line := '';
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   hexFile := MCSIO.CreateUniqueFile(MCSIO.GetTempDir, 'TPS', '.hex');
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   makeHexFile(hexFile);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-{  hexFileSource := TStringList.Create;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  for x := 1 to StringGrid1.RowCount - 1 do
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  begin
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    if (pos = 0) then
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    begin
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      line := line + ':';
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    end;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    tmp := StringGrid1.Cells[1, x];
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    line := line + tmp;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    tmp := StringGrid1.Cells[2, x];
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    line := line + tmp;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    Inc(pos);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    if (pos = 8) then
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    begin
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      hexFileSource.Add(line);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      line := '';
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      pos := 0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    end
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    else
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    begin
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      line := line + ',';
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    end;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  end;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  if (pos = 0) then
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  begin
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    line := hexFileSource.Strings[hexFileSource.Count - 1];
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    hexFileSource.Delete(hexFileSource.Count - 1);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    pos := 8;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  end;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  if (pos <= 7) then
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  begin
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    for x := pos to 7 do
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    begin
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      line := line + '00';
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      if (x < 7) then
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        line := line + ',';
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    end;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  end;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  line := line + '*';
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  hexFileSource.Add(line);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  MCSIO.StrToFile(hexFile, hexFileSource.Text);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  hexFileSource.Free;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   Result := hexFile;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 end;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -827,8 +775,11 @@ var 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   KeyName, StringValue: string;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   Res: WideString;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   Lines: TStringList;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  TimeOut: integer;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  error: boolean;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 begin
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  error := False;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   line := GetSerialPortNames;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   //  if (line <> '') then
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   begin
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -853,24 +804,62 @@ begin 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       SdpoSerial1.Device := comService;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       SdpoSerial1.Active := True;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      Lines := TStringList.Create;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      Lines.LoadFromFile(hexFile);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      for x := 0 to Lines.Count - 1 do
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      if (not readString(line)) then
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      begin
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        error := True;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      end;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      if (not error) then
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      begin
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SdpoSerial1.WriteData('w');
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (readString(line)) then
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        begin
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          if (pos('ready', line) > 0) then
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          begin
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Lines := TStringList.Create;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Lines.LoadFromFile(hexFile);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for x := 0 to Lines.Count - 1 do
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            begin
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              SdpoSerial1.WriteData(Lines.Strings[x]);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              SdpoSerial1.WriteData(CRLF);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              Sleep(250);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            end;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            SdpoSerial1.WriteData('e');
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          end
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          else
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          begin
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            error := True;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          end;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        end;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      end;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      if (error) then
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       begin
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        SdpoSerial1.WriteData(Lines.Strings[x]);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        SdpoSerial1.WriteData(CRLF);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Application.MessageBox('Arduino antwortet nicht. Evtl. Arduino nicht angeschlossen oder falsche Firmware?',
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          'Keine Antwort',
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          MB_OK + MB_ICONEXCLAMATION);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       end;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       SdpoSerial1.Active := False;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       DeleteFile(hexFile);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     end;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   end;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-{  else
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+end;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+function TForm1.readString(var line: string): boolean;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+var
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  TimeOut: integer;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+begin
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  Result := False;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  TimeOut := 10;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  while ((not SdpoSerial1.DataAvailable) and (TimeOut > 0)) do
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  begin
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    Dec(TimeOut);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    Sleep(1000);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  end;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  if (Timeout > 0) then
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   begin
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    Application.MessageBox('Kein Comport vorhanden. EVt. Arduino nicht angeschlossen?',
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      'Kein Comport',
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      MB_OK + MB_ICONEXCLAMATION);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    line := SdpoSerial1.ReadData;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    Result := True;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   end;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 end;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 procedure TForm1.setDirty(Value: boolean);
 
			 |