Shop OBEX P1 Docs P2 Docs Learn Events
basic stamp with RS-232 link - Page 2 — Parallax Forums

basic stamp with RS-232 link

2»

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2007-03-03 18:44
    Robban said...
    and from what i have inderstood it is only the 1AF8 that is the data...

    Question is...is there a command in Pbasic to "mask" out the 1AF8 or do i have to make a small program for this?
    Use one (or more)·of the data formatting options (see PBASIC Help for SERIN -- WAIT, STR, SKIP, etc.)
  • RobbanRobban Posts: 124
    edited 2007-03-04 10:17
    i tried the skip command,but then i only got one charter...and since the line is diffrent for every "sensor" i cant´t use the wait command...

    *confused*
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2007-03-04 22:12
    Hi Robban, with each command you send the elm unit you should·know how many bytes it will return and which bytes you require. In the example you have been dealing with you are saying that the elm returns four bytes and you only require the last two bytes. What you could do is assign a variable for the SKIP and HexStr dependent on what you were expecting to recieve. Assuming you are using allan's code

    SEROUT tx,baud, [noparse][[/noparse]"0100",13]

    skip_len=2

    return_len=4


    SERIN rx,baud, [noparse][[/noparse]SKIP skip_len,STR HexStr\return_len]

    the skip and return variables would be dependent on the issued command

    Jeff T.
  • RobbanRobban Posts: 124
    edited 2007-03-07 16:44
    ok...i got that, can i then convert the 1a f8 to the actual value (6904)?
  • allanlane5allanlane5 Posts: 3,815
    edited 2007-03-07 20:27
    "SERIN rx,baud, [noparse][[/noparse]SKIP skip_len,STR HexStr\return_len]"

    Yes, but you'd use:

    SERIN rx, baud, [noparse][[/noparse]SKIP skip_len, HEX HexVal.HighByte, HEX HexVal.LowByte]

    HexVal (defined as a WORD) would then have the value 6904 in it, if given the two strings "1A" and "F8".
    Or "1a" and "f8", same thing. And if you're begin given the string "1AF8", then you'd use:

    SERIN rx, baud, [noparse][[/noparse]SKIP skip_len, HEX HexVal]

    The "HEX" is a 'deformatting' keyword, that converts a hexadecimal formatted string into the equivalent decimal value, then puts the resulting value into a variable.
Sign In or Register to comment.