Wait for a string on a serial port


Closed Thread
Results 1 to 20 of 20

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    960


    Did you find this post helpful? Yes | No

    Default Wait for a string on a serial port

    Quote Originally Posted by sayzer View Post
    Default OSC value is for Internal 4Mhz clock.
    Right, thanks for pointing this to me
    Roger

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,626


    Did you find this post helpful? Yes | No

    Default Re: Wait for a string on a serial port

    Henrik, for my edification is this the correct answer? Please don't roll your eyes too far if this is too much of a NOOB question.
    Don't worry about any eyes rolling, this type of thing comes up quite often and hopefully we all learn from it.

    All four lines obviously compares the value stored in the variable SWITCH with whatever value is on the right side of the equal sign. But out of the four lines, only the first one would make any difference compared to other ones when put into a program. The other Three would execute exactly the same because they all compare SWTICH to the a value of 49 (while the first line compares SWITCH to a value of 1).

    1 is simply the value of 1
    "1" however is the ASCII character 1 (which happens to correspond to the value 49 expressed in decimal notation).
    49 is the ASCII code, expressed in decimal notation, for ASCII character "1"
    $30 is the hexadecimal representation of the decimal value 30 which is the ASCII code for character we know as "1"
    %00110001 is the binary representation of the decimal value 30 which is the ASCII code for the character we know as "1"

    If, instead of camparing SWITCH to something you'd assign values to it:
    Code:
    SWITCH = 1
    SWITCH = "1"
    SWITCH = 49
    SWITCH = $30
    SWITCH = %00110001
    Only the first line is different, the other four lines all does exactly the same thing - it's just different ways of expressing, or interpreting, the same thing.

    /Henrik.

Similar Threads

  1. How to Serial comm. wait for a string?
    By elcrcp in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 29th December 2015, 11:25
  2. wait for a string
    By sahin5002 in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 3rd April 2009, 00:27
  3. grabbing a serial string and passing it
    By cpayne in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 4th March 2006, 00:39
  4. Serial String parsing
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 29th June 2005, 19:11
  5. serial string parsing
    By billybobbins in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 8th September 2004, 22:34

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