SerIn & wait


Closed Thread
Results 1 to 5 of 5

Thread: SerIn & wait

  1. #1
    Join Date
    Sep 2005
    Location
    Switzerland
    Posts
    46

    Default SerIn & wait

    Hi guys,
    i was wondering if it's possible to use 'and' and 'or' into SerIn instruction.
    For example:
    Serin2 Porta.1,188,3000,[wait("ABC") and ("123"), ................
    I tried some possible ways but without success.
    Thanks
    Bye

  2. #2
    Join Date
    Oct 2003
    Location
    holland
    Posts
    251


    Did you find this post helpful? Yes | No

    Default

    Serin2 normaly takes 1 byte as an input. If you want to take more than one byte you will have to say how much binairy or decimal or hexadecimal bytes you want to recieve at once. Look into you PBP book 5.72 (my page 132)

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    could be a situation to use STR ArraVar\XCharacter\EndedByXYZ

    using STR ArrayVar\7\13

    if you send ABC\13 it will consider only the ABC

    If you Send ABC123\13 it will consider all character.

    Now read ArrayVar[3] to know wich string combination you received.

    Now if there's a way hidden way to know how much character you received by one of the internal ressource of PBP (macro or PBP variable)it can add some flexibility. Maybe Darrel or somebody else may dig in it.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    Sep 2005
    Location
    Switzerland
    Posts
    46


    Did you find this post helpful? Yes | No

    Default

    Thanks for your replies.
    I believe i was not clear enough with my explanation.
    I receive a serial string : wers-ABC,897-00587
    now this string does not contain ABC and 123 so in this
    case serin2 command has nothing to do, it loops waiting for another
    string.
    If I receive a serial string: qwts-ABC,123-98756 now serin2 has
    to do something.
    Serin2 has to wait not only the characters ABC but ABC and 123.
    This is a classic serin line: SerIn2 pinin,396 [wait ("ABC"),testbyte]
    but in my code line serin2 should wait not only for ABC but ABC and 123.
    Hope to be enough clear.
    Thanks and bye

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    this on work with HSERIN, should also work with SERIN2
    Code:
        DEFINE   LOADER_USED 1
        DEFINE   OSC 20
        DEFINE   HSER_RCSTA 90h
        DEFINE   HSER_TXSTA 24h
        DEFINE   HSER_SPBRG 129 ' 9600 Bauds
        DEFINE   HSER_CLROERR 1
        
        discard  var byte
        ArrayVar var byte[10]
    
    start:
        hserin 5000,NotReceivedYet,[wait("abc"),discard,wait("123"),str arrayvar\10\13] 
        hserout ["Discard:",discard,13,10,_
                 "Received:",str arrayvar,13,10]
        goto start
    
    NotReceivedYet:
        hserout [13,10,"no!",13,10]
        goto start
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. Can't read sequential addresses in external EEPROM
    By tjkelly in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th February 2010, 14:46
  2. HARDWARE I2C SAMPLE CODE question
    By Michael Wakileh in forum Code Examples
    Replies: 2
    Last Post: - 16th June 2009, 21:07
  3. serin question?
    By sachymo in forum General
    Replies: 5
    Last Post: - 27th July 2008, 10:04
  4. Problem with PBP interrupt and Serin, please help
    By rgregor in forum mel PIC BASIC
    Replies: 0
    Last Post: - 22nd August 2006, 19:02
  5. Serin with low voltage
    By f_lez in forum General
    Replies: 3
    Last Post: - 21st August 2006, 11:52

Members who have read this thread : 4

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts