Serout2 question


+ Reply to Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    137

    Default Serout2 question

    Is there any switch/setting that can send everything in a serout2 command in the 1 complete packet?

    eg
    MyValue = 100
    serout2 PORTB.1, 84, ["This is my value:", dec MyValue, 13,10]

    can be sent out as a complete "This is my value: 100 CRLF"

    The reason I ask is because there's one particular RF transceiver module I have that will only transmit the "This is my value". All my other transceivers will happily transmit the entire parameters including value, CR and LF. This is the same deal for all my serout2 transmits irrespective of string lengths.

    I really want to avoid having to contract everything together into a single variable prior to sending.

    I haven't tried sending using hardware, but if that's a solution, I can work with that.

    The module is a CEbyte E22-400T37S

    Thanks for any assistance.

    Troy
    Last edited by rocket_troy; - 13th March 2024 at 04:18.

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,847

    Default Re: Serout2 question

    The command serout2 PORTB.1, 84, ["This is my value:", dec MyValue, 13,10] is valid and you can use it.

    Also same goes for Hserin too.

    I may have not understood your problem.

    Ioannis

  3. #3
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    137

    Default Re: Serout2 question

    Hi Ioannis,
    The problem isn't with the validity of the code, it's more to do with... well... the combination of the transceiver and the way PBP sends the packet. So, for a statement like that:

    serout2 PORTB.1, 84, ["This is my value:", dec MyValue, 13,10]

    I would've assumed that the compiler would (behind the scenes) contract all that into a single string and send it all at once. But it doesn't appear to. It appears to send everything separated by commas as individual packets - one after another. What I'm guessing is happening is the 1st packet ie. the "This is my value:" string is sent to the serial port and on to my transceiver and whilst the transceiver is sending that off, the code is sending the next packet, which is the value converted to a string. So, it appears as though all subsequent packets from the original string are being discarded by the transceiver - perhaps because it's busy sending that 1st string? So, the result is I only get the original string transmitted "This is my value:" and nothing else - no value, no carriage return or line feed. Only happens with this particular module of transceiver.
    I can't see any setting for the transceiver to adjust the receiving packet processing or delay, so I'm wondering if there's a switch or setting in PBP to send everything as one packet instead of separate individual packets within the 1 single command?

    I'm really trying to avoid contracting everything into a single array via Arraywrite prior to every serout2 command.

    Cheers,

    Troy

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,847

    Default Re: Serout2 question

    The command send all at once. No commas are inserted if you do not explicitly define so.

    The command will send the text string and immediately after that will send the MyValue not as one binary byte but as 1 up to 3 ASCII codes of the value.

    Example 1. If MyValue is 5, the command as you stated will send

    This is my value:5crlf

    The above expressed in ASCII codes will be

    Code:
    $54 $68 $69 $73 $20 $69 $73 $20 $6d $79 $20 $76 $61 $6c $75 $65 $3a $35 $0d $0a
     T   h   i   s       i   s        m   y      v   a   l   u   e   :   5   CR   LF
    Example 2. If MyValue is 123 then you send out

    This is my value:123crlf

    or expressed in ASCII codes

    Code:
    $54 $68 $69 $73 $20 $69 $73 $20 $6d $79 $20 $76 $61 $6c $75 $65 $3a $31 $32 $33 $0d $0a
     T   h   i   s       i   s        m   y      v   a   l   u   e   :   1   2   3   CR   LF
    I think you have not used correctly ascii and binary values. Hope the above clears things for you.

    Ioannis
    Last edited by Ioannis; - 14th March 2024 at 21:13.

  5. #5
    Join Date
    Aug 2011
    Posts
    419

    Default Re: Serout2 question

    Code:
    serout2 PORTB.1, 84, ["This is my value:", dec MyValue, 13,10]
    There's no "packet" created... bytes are streamed out the software UART as they are made ready.

    There may be a small delay between the last char of "This is my value:" and the 'dec MyValue' portions because it takes time for the uC to convert the binary data to an ASCII string. How long that takes would depend on the uC, clock, and MyValue.

  6. #6
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    137

    Default Re: Serout2 question

    Quote Originally Posted by tumbleweed View Post
    Code:
    serout2 PORTB.1, 84, ["This is my value:", dec MyValue, 13,10]
    There's no "packet" created... bytes are streamed out the software UART as they are made ready.

    There may be a small delay between the last char of "This is my value:" and the 'dec MyValue' portions because it takes time for the uC to convert the binary data to an ASCII string. How long that takes would depend on the uC, clock, and MyValue.
    Okay, interesting. So that small delay might be triggering the RF transceiver to interpret the end of the packet. I'm running an 8mhz clock on a PIC18F26K83 so there is scope to play with clock speeds. I'll have a play.

    Troy

Similar Threads

  1. SEROUT2 Question ?
    By andybarrett1 in forum Serial
    Replies: 2
    Last Post: - 12th April 2015, 22:49
  2. Serin2/Serout2 Question
    By scottl in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th November 2007, 09:11
  3. Serout2
    By Mostafa in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 5th April 2007, 07:37
  4. serout2
    By jcleaver in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 12th February 2007, 23:51
  5. serout2 help please...
    By cpayne in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 3rd March 2006, 19:37

Members who have read this thread : 10

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