Menu

help with storeing incomming serial

Help
2010-08-19
2013-05-30
  • Nobody/Anonymous

    I have this:
    #chip 12F683, 8 'mhz
    #config INTRC_OSC_NOCLKOUT, MCLRE=off, WDT=off, bod=0ff

    dir GPIO.1 out ;open
    dir gpio.0 in ;rx

    #define RecAHigh GPIO.0 off
    #define RecALow GPIO.0 on
    InitSer 1,r1200,1,8,1,none,invert
    dim temp as string

    main:
    SerReceive 1, Temp
    if temp = "1234" then opendoor

    goto main

    sub opendoor
    set gpio.1 on
    wait 2 s
    set gpio.1 off
    wait 10 s
    end sub

    but i get a error on compile that says "cannot store ser_byte in the string varible temp"

    Why?

     
  • Nobody/Anonymous

    The SerReceive command reads a byte variable from the Serial Port
    so the line SerReceive 1, Temp wont work as temp is defined to be a string.
    SerReceive will only read a single incoming byte .

     
  • Nobody/Anonymous

    so how can i get it to store a string of 4 bytes?

     
  • mmotte

    mmotte - 2010-08-20

    a few things to know
    String is a special array where you store the length in the first element  temp

    to fill the array/string, I think you have to receive and put in each element
    DIM  temp as string
    ……….
    SerReceive 1, Temp(1)
    SerReceive 1, Temp[(2)
    SerReceive 1, Temp(3)
    SerReceive 1, Temp(4)
    Temp(0) = 4

    I don't see a string compare in "lowlevel" string routines

    So one at a time to check for valid "keycode"

          IF Temp(1) != "1" then goto main
         IF Temp(2) != "2" then goto main
         IF Temp(3) != "3" then goto main
         IF Temp(4) != "4" then goto main
    opendoor

    This is just to give some ideas how to do it.
    GL
    Mike

     
  • Nobody/Anonymous

    just wondering why the reply didn't show up
    wierd

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.