Shop OBEX P1 Docs P2 Docs Learn Events
UART hangup - possible race condition? — Parallax Forums

UART hangup - possible race condition?

GregSGregS Posts: 15
edited 2009-09-04 13:29 in General Discussion
I am using the Uart to receive data (using .receiveByte() as a blocking call) - guaranteed within 12 hours the Javelin hangs inside this call (no memory leaks etc - I checked, also checked power supply, input data stream, ...).· When I change the code to use .byteAvailable()· in a loop before the .receiveByte(), the Javelin runs forever!· I know, I know·- I have the solution!!· But I want to know why the first option doesn't work reliably?·- is there a race condition in .receiveByte which can "miss" an incoming byte and causes the method to hang?

Peter refers to the "original" Uart and lists some code.· Is the Uart code available in the public domain and if so, how do I get it?

Thanks
GregS

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2009-09-04 13:14
    All that is available are the Uart class. The javelin firmware is not public.
    Attached are the Uart class (Uart_org.java) as distributed with the IDE v2.0.3
    The other (Uart.java) is the modified class that I use.

    They differ in the way the buffers are handled.

    What Uart class are you using?

    regards peter
  • GregSGregS Posts: 15
    edited 2009-09-04 13:29
    Thanks for the reply.

    I am using the vanilla Uart (receiving a 20 byte packet every 15 seconds at 4800baud - not a much data at a slow speed!).· There is virtually no foreground processor load.· I have also tried reordering the code in memory·(additional methods, initialized arrays, etc) in case there was a memory problem in the Javelin (I only have one) - still exhibits the same problem.· I have also received the data in parallel (a PC and Javelin receiving the same data stream) - not a data source problem unless one of the Uarts (transmitter or Javelin) drifts, but my code has the ability to resynchronize if receiving restarts.

    Regards Greg
Sign In or Register to comment.