Ja, ich war mir schon fast bewusst, dass das Thema nicht in diesem Thread richtig ist... Hatte aber sonst auf einen Moderator gehofft, der das Teil an die passende Stelle verschiebt.
Laufen tut mein C# Code jetzt. Allerdings habe ich ein eigenartiges Problem. Die Kommunikation mit dem Mikrocontroller funktioniert nur, wenn ich auch einen Portmonitor auf dem System anhabe, auf dem auch mein C# Programm läuft.
Hier einmal beide Codeausschnitte:
C# Programm:
Mikrocontroller (BASCOM):Code:public SerialPort comPort = new SerialPort("COM1", 2400, Parity.None, 8, StopBits.One); public void ser_sendYes() { if (comPort.IsOpen == false) { comPort.Open(); } comPort.Write("J\r"); comPort.Close(); } public void ser_sendReset() { if (comPort.IsOpen == false) { comPort.Open(); } comPort.Write("R\r"); comPort.Close(); } this.ser_sendReset(); this.ser_sendYes();
Code:Rem This file contains an error in the include statement Rem the file a.bas does not exist Rem It shows that the editor will load this file Rem and displays the error marker on this line Rem when you compile the main file : include.bas $regfile = "m32def.dat" $crystal = 4000000 $baud = 2400 Config Porta.0 = Output Config Porta.1 = Output Config Porta.2 = Output Config Porta.3 = Output Config Porta.4 = Output Dim X As Byte Dim Y As Byte Dim Empfangen As String * 255 Declare Sub Led1() Declare Sub Led2() Declare Sub Led3() Declare Sub Led4() Declare Sub Blinken() Do X = 0 Do Empfangen = "" Input Empfangen Select Case Empfangen Case "J" Led1 X = X + 1 Case "R" Porta.0 = 0 Porta.1 = 0 Porta.2 = 0 Porta.3 = 0 X = 4 End Select Loop Until X = 4 Wait 2 Porta.0 = 0 Porta.1 = 0 Porta.2 = 0 Porta.3 = 0 Porta.4 = 0 Loop End Sub Led1() If Porta.0 = 0 Then Porta.0 = 1 Print "Led 1 ist an" Else Led2 End If End Sub Sub Led2() If Porta.1 = 0 Then Porta.1 = 1 Print "Led 2 ist an" Else Led3 End If End Sub Sub Led3() If Porta.2 = 0 Then Porta.2 = 1 Print "Led 3 ist an" Else Led4 End If End Sub Sub Led4() If Porta.3 = 0 Then Porta.3 = 1 Print "Led 4 ist an: Gewonnen" Wait 1 Blinken End If End Sub Sub Blinken() Y = 0 Do Porta.4 = 1 Waitms 500 Porta.4 = 0 Waitms 500 Y = Y + 1 Loop Until Y=15 End Sub







 
			
			 
					
					
					
						 Zitieren
Zitieren 
			

Lesezeichen