Adding timeout to ADAT receiver?

If you have a simple question and just want an answer.
littlebigdondon
Newbie
Posts: 1
Joined: Wed Nov 19, 2014 7:08 pm

Adding timeout to ADAT receiver?

Post by littlebigdondon »

I'm trying to add a simple timeout to the ADAT receiver because occasionally, if you were to unplug the optical cable before it passes the  p when pinsneq(violation) :> int _;  statement, it will just hang and never exit the thread. I need to perform some actions upon exiting the thread, so I figured just reading the port counter every go-around (or using a timer), and using a select statement to just like in the timeout examples would be my best bet.

    while(1) {
        violation = word;
        select {
            case t when timerafter(count + 100000) :> void:
                printf("timer reached\n");
                return;
            case p when pinsneq(violation) :> int _ @ count:
                break;
        }
   ...
   ...
   ...
}
 

Now, I know the adat_rx module is supposedly reliable, but just adding the select statement & sampling the port counter seems to throw the timing out of whack, causing the thread to exit when it hits the end of the loop and checks  if (word != 0 && word+1 != 0) .

 

Any thoughts on how I could reliably exit the thread if waiting on p to not equal violation takes too long?

 
User avatar
sethu_jangala
XCore Expert
Posts: 589
Joined: Wed Feb 29, 2012 10:03 am

Post by sethu_jangala »

select

{

  case t when timerafter(count + 100000) :> count:

    printf("timer reached\n");

    return;

  case p when pinsneq(violation) :> void:

    t:>count;

  break;

}