Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

I might be crazy. Is it possible serial events triggered by interrupt behave differently?


  • Please log in to reply
4 replies to this topic

#1 65tux

65tux

    Advanced Member

  • Members
  • PipPipPip
  • 38 posts

Posted 11 June 2013 - 04:22 PM

The bruise on my forehead is getting too big from pounding my head against the wall so I thought I would do a sanity check here.  Feel free to tell me I am crazy.

 

Using an ND+2 build 4.2.2 to send commands via uart to a display.  The display responds with a <cr> when the command has completed.  The symptom I am seeing is, whenever I send a serial command from "main" the response coming back from the display via the comm1_DataReceived event is immediate.  Whenever I send commands that are triggered by either an input interrupt or by data received from the display (touchscreen button push) the response from the display takes several seconds.  Because my code times out and moves on, I will get several responses all at once from the serial port buffer.  It is very repeatable and I can't see how it could be caused by the display, since again, responses to serial writes triggered by the "main" loop are always immediate.

 

Am I nuts?

 



#2 NooM

NooM

    Advanced Member

  • Members
  • PipPipPip
  • 490 posts
  • LocationAustria

Posted 11 June 2013 - 04:49 PM

//edit: removed, guess i understood that wrong.



#3 65tux

65tux

    Advanced Member

  • Members
  • PipPipPip
  • 38 posts

Posted 11 June 2013 - 10:37 PM

Pretty sure I have all but proven it.  By putting all my code (send and receive) in one sub it works perfectly.  When using the DataReceived event handler receives are significantly delayed.



#4 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 12 June 2013 - 08:40 AM

Do you have any synchronization (events, locking etc.) in your program? It sounds like the code in DataReceived event handler is blocking the other code, because it is expected to run on a different thread (?)



#5 65tux

65tux

    Advanced Member

  • Members
  • PipPipPip
  • 38 posts

Posted 12 June 2013 - 10:27 AM

I assumed input interrupts were in a separate thread - is that not true?  If anything, it seems the other way around to me - the other logic is blocking the DataReceived.

 

The basic code is - when I get an interrupt, set a "waiting" flag and call a sub to send a command string to the display.  That sub has a whiile "waiting" loop.  The DataReceived will clear "waiting" when the response comes in.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.