Serial OnCom

Discussion in 'Questions (Windows Mobile)' started by Cor, Jan 16, 2008.

  1. Cor

    Cor Active Member Licensed User

    I want to detect some incoming Characters and act on it. (send other data)

    No use of flowcontrol

    Iám using the serialterminal program.

    Now it seems a problem when I want to send data from the oncom routine.

    e.g. when receiving a single character like % I must send directly other data

    Also needed string to int and int to string.

    cannot find this in help

    What is the best to setup such routine for basic4ppc

    thanks in advance

    grCor
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Basic4ppc automatically converts numbers and strings.
    Using a timer is more foolproof than using the OnCom event.
    You need something like:
    Code:
    Sub Timer1_Tick
     
    If Serial.InBufferCount > 0 Then
      data = 
    Serial.InputString
      
    if StrIndexOf(data,"%",0) > -1 then '% was sent
       Serial.Output("somestring")
      
    end if
     
    end if
    End Sub
    The GPS tutorial may also help you: http://www.basic4ppc.com/forum/showthread.php?t=1093
     
Loading...