HSERIN and XOUT command


Closed Thread
Results 1 to 21 of 21

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hi Aratti,

    This could be a problem.

    In the Main loop, actually Loop:, there is an XIN statement that runs on every loop. Then if you receive data in the interrupt handler, the TxCommand is called which does an XOUT. The XOUT could potentially be triggered in the middle of the XIN. Possibly leaving XIN waiting for something it will never receive.

    That could keep the HSEROUT's from being executed.

    If you set a "flag" in the interrupt handler when it receives data, then do the XOUT in the main loop when it sees the flag, it won't try to do both XIN and XOUT at the same time.

    Added: You may also need to have the RX interrupt receive bytes 1 at a time instead of a full string, to keep it from interfereing with the XIN to begin with.

    hth,
    Last edited by Darrel Taylor; - 10th May 2009 at 03:23. Reason: Added:
    DT

  2. #2
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default No luck

    Hi Darell, thank you for your answer. I did try your suggestion without any luck.
    In doing these changes I came to the conclusion that Xin command is the problem, infact simply removing Xin from the code and Txing numbers with a For/Next loop everything work fine. As soon as I enable Xin the problem is back again.

    At this time it seems I have got only one bullet left "use two pics" one for Xin and one for Xout.

    Al.
    Last edited by aratti; - 10th May 2009 at 19:13.
    All progress began with an idea

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    I did try your suggestion without any luck.
    Did you also change the RX handler to receive only 1 byte at a time? Waiting for a whole string takes a LONG time.

    And, have you tried the XIN without the interrupts? Is XIN working at all?
    You can add a Timeout to XIN, in case it's not receiving anything.

    Is the XIN supposed to be running continuously in a loop, or as a response to the 250 command?
    If it was in response to the command, it's more likely that incoming data will not occur again in the middle of the XIN.
    <br>
    DT

  4. #4
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Did you also change the RX handler to receive only 1 byte at a time?
    Yes I did But it doesn't work very well. A command must be sent twice or three times to be executed, while with the whole string method commands are all decoded and executed correctly at the first time. Very likely my code is not so efficient as the whole string.

    Here the code used: (Where : RxBuffer VAR PIR1.5)
    Code:
    Getbytes:
    A0=0
    While RxBuffer=1 
    Hserin 100,ErrorFlag,[Rdata[A0]]
    A0=A0+1
    Wend
    @ INT_RETURN

    And, have you tried the XIN without the interrupts? Is XIN working at all?
    Yes with "SERIN2/SEROUT2" did work, not with "HSERIN/HSEROUT". But as you can understand, I need to jump out from Xin loop when an X10 command is received via Xbee in order to service it with the Xout command.


    Is the XIN supposed to be running continuously in a loop, or as a response to the 250 command?
    Xin is supposed to continuouly scan the main for X10 commands coming in from the different sources capable to issue such a command. The incoming data will be used to update a memory area containing the status of various lamps and appliances (On/Off).

    Al.
    All progress began with an idea

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


    Did you find this post helpful? Yes | No

    Default

    how about get rid of the timeout label and the IF-THEN?
    Steve

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

  6. #6
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default

    As written, Xin is blocking. You need a timeout and jump_to_label.

  7. #7
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    how about get rid of the timeout label and the IF-THEN?
    Steve, are you refering to the code in my post#11?


    As written, Xin is blocking. You need a timeout and jump_to_label.
    dhoston, Xin is blocking the USART with and without the timeout

    Al.
    Last edited by aratti; - 11th May 2009 at 20:49.
    All progress began with an idea

Members who have read this thread : 0

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