Hallo,
hier habe ich noch einmal meine Sende und Empfangsfunktionen zusammen gestellt:
Sender
Code:
$regfile = "m8def.dat"
$crystal = 7372800
$baud = 4800
Config Pinc.0 = Input
Config Pinb.2 = Input
Dim I As Byte
Dim Key As Byte
Const Keys = 2
Do
For I = 1 To Keys
Key = I
Select Case Key
Case 1 : Debounce Pinc.0 , 0 , Key_o1 , Sub
Case 2 : Debounce Pinb.2 , 0 , Key_o2 , Sub
End Select
Next
Loop
' Tasterfunktionen
Key_o1:
Gosub Abfrage
Return
' Abfrage der angeschlossenen Module
Abfrage:
Portd.2 = 1
Waitms 5
Print "test"
Portd.2 = 0
Return
Key_o2:
Return
Empfänger:
Code:
$regfile = "m8def.dat"
$crystal = 7372800
$baud = 4800
Dim S As String * 10
Dim A As String * 10
Dim Z As String * 10
Dim V As Word
On Urxc Onrxd
Enable Urxc
Enable Interrupts
Do
Loop
' **** RS485 Aktivieren und Bus prüfen
Onrxd:
V = V + 1
S = S + Chr(udr)
If Len(s) > 3 Then
A = S
Goto Pruefung
Else
End If
Return
'****************************************************
Pruefung:
Z = Mid(a , 1 , 2 )
Gosub Zustand
A = ""
S = ""
Return
'****************************************************
Zustand:
Disable Urxc
Disable Interrupts
Config Portd.2 = Output
Waitms 5
Portd.2 = 1
Print "Angekommen" ; S
Print "Zustand"
Waitms 5
Portd.2 = 0
Config Portd.2 = Input
Enable Urxc
Enable Interrupts
A = ""
Return
Wie gesagt, wenn ich am angeschlossenen Terminalprogramm unter Win XP das Wort "test" eingebe, meldet sich der empfänger und bestätigt mir mit der Rückmeldung "Angekommen test".
Sende ich dies über den Sender so erhalte ich nur wirre Zeichen.
Tobias
Lesezeichen