logo elektroda
logo elektroda
X
logo elektroda
Adblock/uBlockOrigin/AdGuard mogą powodować znikanie niektórych postów z powodu nowej reguły.

[Mega32] [BASCOM]Reakcja na polecenia z zewnątrz - USART

Gibol 21 Gru 2008 02:24 1265 1
  • #1 5883998
    Gibol
    Poziom 17  
    Chcę zaprogramować sterowanie Komendami AT.
    Coś typu połączenie > rób program
    Połączenie > przerwij program.

    Próbowałem dostosować kawałek programu dla Atmega 8 z "Powiadamianie GSM" (było kiedyś w DIY)

    Kompilator zwraca mi błąd:

    
    Error: 7 Line: 0 IF THEN expected [96], in file:
    Error:123 Line: 0 END IF expected, in file:
    


    program:
    
    $regfile = "m32def.dat"
    $crystal = 20000000
    
    $baud = 19200
    
    Config Serialin = Buffered , Size = 100
    
    Config Porta.0 = Output
    
    
    
    Enable Interrupts
    Declare Sub Oproznij_bufor
    Declare Sub Transmisja
    Declare Sub Glowny
    Declare Sub Standby
    
    
    
    Dim Dzwtxt As String * 20
    Dim Ringtxt As Byte
    Dim Bufor As Byte
    Dim Ring As Byte
    Dim Uart_txt As String * 100
    Dim Dzw As Byte
    Dim Dzwoniacy As String * 40
    Dim Kod As String * 100
    Dim Dane As String * 200
    Dim Status As Bit
    
    Reset Porta.0
    
    Uart_txt = ""
    Dzwtxt = ": +48"
    Ringtxt = "RING"
    Status = 0
    
    
      Waitms 100
      Print "ATX0" ; Chr(13)                                    'Odpowiadaj
      Waitms 100
      Print "ATZ" ; Chr(13)                                     'Ustaw domyślnie
      Waitms 100
      Print "ATE0" ; Chr(13)                                    'WYLACZ ECHO
      Waitms 100
      Print "AT+CLIP=1" ; Chr(13)                               'Wlaczanie prezentacji numeru
      Waitms 100
      Gosub Oproznij_bufor
      Call Glowny
    
    Glowny:
    Do
    Call Transmisja
    If Status = 0 Then Call Standby
    If Status = 1 Then Set Porta.0
    Loop
    Return
    
    Transmisja:
    Do
     Kod = Inkey()
      Dane = Dane + Chr(kod)
      Bufor = Ischarwaiting()
    
      Dzw = Instr(dane , Dzwtxt)
        Dzw = Dzw + 5
      Dzwoniacy = Mid(dane , Dzw , 9)
    
     If Dzwoniacy = "numer" And Status = 0 Then
     Status = 1
    
     If Dzwoniacy = "numer" And Status = 1 Then
     Status = 0
                                               '
     Wait 1
      Print "ATH" ; Chr(13)
     Waitms 100
      Gosub Oproznij_bufor
     End If
    
    Loop Until Bufor = 0 Or Kod = "13"
    
    Oproznij_bufor:
    Do
       Kod = Inkey()
       Bufor = Ischarwaiting()
       Dane = "0"
    Loop Until Bufor = 0
    Return
    
    
    'standby
    Standby:
    Do
    Waitms 10
    Loop Until Status = 1
    


    Poprawiłem tytuł - regulamin p.11
    [zumek]
  • Pomocny post
    #2 5884036
    Remus
    Poziom 13  
    Zmień linie:
    
     If Dzwoniacy = "numer" And Status = 0 Then 
     Status = 1 
    
     If Dzwoniacy = "numer" And Status = 1 Then 
     Status = 0
    

    na:
    
     If Dzwoniacy = "numer" And Status = 0 Then Status = 1
    
    
     If Dzwoniacy = "numer" And Status = 1 Then Status = 0
    


    i usuń end if:
    
     If Dzwoniacy = "numer" And Status = 0 Then 
     Status = 1 
    
     If Dzwoniacy = "numer" And Status = 1 Then 
     Status = 0 
                                               ' 
     Wait 1 
      Print "ATH" ; Chr(13) 
     Waitms 100 
      Gosub Oproznij_bufor 
    ' End If
    


    Program się skompiluje (ale już nie analizuję, czy zadziała ;)

    Pozdrawiam
REKLAMA