Compare Data


Closed Thread
Results 1 to 10 of 10

Thread: Compare Data

  1. #1

    Default Compare Data

    Hi,

    IŽneed a Solution for my Firmware,I must to compare Received Data,but the Problem is that the lenght of the strings are not always the same.

    For Example i send $WP+CALL=12345... and I should receive this $OK:CALL or $ERR:CALL when I use this $WP+GSMINFO=1234 i should receive $MSG:GSMINFO="xxx",27,0,0.

    All the answers have this first character "$" and I want to put the Answer on my LCD.

    Receive:
    Dummy[Input_Byte_Count] = RCREG ' Clear USART Flag by reading USART data
    If Dummy[0] = 36 then ' Character $
    High LCD_Light
    Lcdout $fe, 1 ' Clear screen
    If Dummy[Input_Byte_Count] = 10 then 'Line Feed
    Pause 5
    Lcdout $fe,$80,str Dummy\Input_Byte_Count+1
    Pause 5
    Input_Byte_Count = 0
    else
    Input_Byte_Count = Input_Byte_Count + 1
    endif
    else
    Dummy[0] = $00
    endif
    Resume

    Is this a good way to do this ?

    Thanks for any answer

    Regards Pesti

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    Pesticida, Is there some EOL character sent at the "End of Line"? You can use this character (ie.CR/LF) as a terminator for the input string to your LCD display...

    Dave Purola
    N8NTA

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Hi,

    Yes Feed New Line.

    Regards Pesti

  4. #4


    Did you find this post helpful? Yes | No

    Default

    I think that my Problem is that if I use Dummy=RCREG with RCIF Interrupt I become a overflow.

    I must to try with Hserin.

    Regards

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Pesticida View Post
    I think that my Problem is that if I use Dummy=RCREG with RCIF Interrupt I become a overflow.

    I must to try with Hserin.

    Regards
    And again, just like the last bunch of posts, you answer awaits you in the PBP manual...It's all about terminating the SERIN2/HSERIN input with an optional character...
    It's in the book if you just take the time to look.
    I understand what you're trying to do and as soon as you read the book, really read the book, the answer will show up...right in front of you...especially since you said that each line is ended with some sort of optional character, in your case, a line feed character.

  6. #6


    Did you find this post helpful? Yes | No

    Default

    Sorry but i dont have exactly explain my Problem,I know how this work but my problem is how to make a routine that check for example if I receive this $OK:CALL, then is the call ok and so on.

    How to verify Long strings?

    I send this $WP+CALL=12345... and then from gsm module receive $OK:CALL.

    Thanks Skimask

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Pesticida View Post
    Sorry but i dont have exactly explain my Problem,I know how this work but my problem is how to make a routine that check for example if I receive this $OK:CALL, then is the call ok and so on.
    How to verify Long strings?
    I send this $WP+CALL=12345... and then from gsm module receive $OK:CALL.
    Thanks Skimask
    Yes, I know...I get it...
    Ok, if you know you start out with a NULL string, and you know what messages you are supposed to be receiving, and you know each of these messages may or may not be a different length, it shouldn't be much of a problem to look at the string, starting from the end (whether it's used or not) and working your way back to the start, looking for the character/characters which may or may not identify the string you are looking for...

  8. #8


    Did you find this post helpful? Yes | No

    Default

    You mean i must do for example something like this:

    Mystring var byte [24] ' maximal 24 bytes
    String_Lenght var byte


    But I must count how Long is my string from start $ to End Line feed.
    For Example Ihave this $OK:CALL

    String_Lenght for this example is 9 with Line feed

    if Mystring[String_Lenght-2] = 76 then Character2 'L
    Character2:
    if Mystring[String_Lenght-3] = 76 then Character3 'L
    Character3:
    if Mystring[String_Lenght-4] = 65 then Character4 'A
    Character4:
    if Mystring[String_Lenght-5] = 67 then Character3 'C

    and so on

    but I think this is not the good way ,this is to complicated for several strings!

  9. #9
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Pesticida View Post
    You mean i must do for example something like this:
    Mystring var byte [24] ' maximal 24 bytes
    String_Lenght var byte
    But I must count how Long is my string from start $ to End Line feed.
    For Example Ihave this $OK:CALL
    String_Lenght for this example is 9 with Line feed
    if Mystring[String_Lenght-2] = 76 then Character2 'L
    Character2:
    if Mystring[String_Lenght-3] = 76 then Character3 'L
    Character3:
    if Mystring[String_Lenght-4] = 65 then Character4 'A
    Character4:
    if Mystring[String_Lenght-5] = 67 then Character3 'C

    and so on

    but I think this is not the good way ,this is to complicated for several strings!
    There is no String_Length function, you have to count backwards from the end to find the length of the string manually.
    One easy-ish way I can think of...
    You have X number of possible messages to be returned.
    Add up the character values of each possible character in that message.
    When a complete message is received and you have added up the individual characters, the message either may or may not match a number already in a table you have preconstructed for that purpose.
    Example:
    Message received is 'OK' + LF
    ASCII value's are O = 79, K = 75, LF = 10, therefore the message is 79+75+10 = 164.
    After you've added them all up you get 164. Go to a Select Case..... Case 164 .... blah blah blah... and there you go.
    Problem is...here's another message...
    Message received is 'AY' + LF
    A = 65, Y = 89, LF = 10, message = 65+89+10 = 164...the code would see the same message, so you'd have to actually go 'inside' the received message to figure out which one it is...
    Or you could just use a number of LOOKUP statements to figure it out.

  10. #10


    Did you find this post helpful? Yes | No

    Default

    Thank You Skimask this is a Perfect Solution, while I have just 10 Answers what I need.

    I will try your example.

    Regards Pesti

Similar Threads

  1. Using Nokia LCD
    By BobP in forum mel PIC BASIC Pro
    Replies: 300
    Last Post: - 3rd May 2018, 04:47
  2. Nokia 3310 display text
    By chai98a in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 26th August 2007, 03:39
  3. Big characters on HD44780 4x20
    By erpalma in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 7th January 2007, 02:21
  4. LCD + bar graph
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 5th October 2005, 14:50
  5. Sinus calculating !
    By Don Mario in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 28th November 2004, 23:56

Members who have read this thread : 1

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