Serin2/Serout2 Question


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2005
    Posts
    37

    Default Serin2/Serout2 Question

    I cannot seem to get the following code to work properly!

    serin2 GPIO.5,Baud,2000,mainloop,[str command\20\13]
    SEROUT2 GPIO.0,Baud,[str command\20,13]

    The data coming in on GPIO.5 is in this format: "A-0000.023 -0000.044 -0000.124 <cr>" all I want to do is just receive the data and forward the data out GPIO.0! Should I be using STR or DEC?

    Can anyone point me in the right direction?

    Thanks,

    Scott

  2. #2
    Join Date
    Jan 2006
    Location
    Slovenia EU
    Posts
    32


    Did you find this post helpful? Yes | No

    Default

    Hello Scott,

    I hope that this help you,

    1) A string constant is output as a literal string of characters.
    2) A numeric value (either a variable or a constant) will send the corresponding ASCII character. Most notably, 13 is carriage return and 10 is line feed.
    3) A numeric value preceded by BIN will send the ASCII representation of its binary value. For example, if B0 = 8, then BIN B0 (or BIN 8) will send "1000".
    4) A numeric value preceded by DEC will send the ASCII representation of its decimal value. For example, if B0 = 123, then DEC B0 (or DEC 123) will send "123".
    5) A numeric value preceded by HEX will send the ASCII representation of its hexadecimal value. For example, if B0 = 254, then HEX B0 (or HEX 254) will send "FE".
    6) REP followed by a character and count will repeat the character, count time. For example, REP A0"\4 will send "0000".
    7) STR followed by a byte array variable and optional count will send a string of characters. The string length is determined by the count or when a 0 character is encountered in the string.

    BIN, DEC and HEX may be preceded or followed by several optional parameters. If any of them are preceded by an I (for indicated), the output will be preceded by either a A%@, A#@ or A$@ to indicate the following value is binary, decimal or hexadecimal.

    If any are preceded by an S (for signed), the output will be sent preceded by a A-A if the high order bit of the data is set. This allows the transmission of negative numbers. Keep in mind that all of the math and comparisons in PBP are unsigned. However, unsigned math can yield signed results. For example, take the case of B0 = 9 - 10. The result of DEC B0 would be A255". Sending SDEC B0 would give A-1" since the high order bit is sent. So with a little trickery, the unsigned math of PBP can yield signed results.

    BIN, DEC and HEX may also be followed by a number. Normally, these modifiers display exactly as many digits as are necessary, zero blanked (leading zeros are not sent). However, if a number follows the modifier, SEROUT2 will always send that number of digits, adding leading zeros as necessary. It will also trim of any extra high order digits. For example, BIN6 8 would send A001000" and BIN2 8 would send A00".

    Any or all of the modifier combinations may be used at once. For example, ISDEC4 B0.


    regards,
    Samo

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by scottl View Post
    Can anyone point me in the right direction?
    you never even dared to answer the last discussion about that.. so i'll redirect you to it as it worked properly here.

    http://www.picbasic.co.uk/forum/showthread.php?t=7501

    Before starting a new post ALWAYS close/answer to your previous one(s).
    Steve

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

Similar Threads

  1. Crystals & Caps - Super noob question??
    By kevj in forum General
    Replies: 4
    Last Post: - 24th September 2007, 17:11
  2. FREQOUT - PWM question
    By Etcho in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 25th February 2007, 23:51
  3. PIC16F684 Program question
    By Nicholas in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th December 2006, 14:30
  4. Question for a math guru
    By Christopher4187 in forum General
    Replies: 3
    Last Post: - 22nd November 2006, 09:45
  5. Please answer my first question
    By John_001 in forum Off Topic
    Replies: 1
    Last Post: - 15th September 2006, 06:49

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