Added udsWaitDataAvailable(), based on gspWaitForEvent().

This commit is contained in:
yellows8 2016-04-05 12:07:24 -04:00
parent 4123baba50
commit d2f9655d8a
2 changed files with 25 additions and 0 deletions

View File

@ -182,6 +182,15 @@ Result udsBind(udsBindContext *bindcontext, u16 NetworkNodeID);
*/
Result udsUnbind(udsBindContext *bindcontext);
/**
* @brief Waits for the bind event to occur, or checks if the event was signalled. This event is signalled every time new data is available via udsPullPacket().
* @return Always true. However if wait=false, this will return false if the event wasn't signalled.
* @param bindcontext The bind context.
* @param nextEvent Whether to discard the current event and wait for the next event.
* @param wait When true this will not return until the event is signalled. When false this checks if the event was signalled without waiting for it.
*/
bool udsWaitDataAvailable(udsBindContext *bindcontext, bool nextEvent, bool wait);
/**
* @brief Receives data over the network.
* @param bindcontext Bind context.

View File

@ -458,6 +458,22 @@ Result udsUnbind(udsBindContext *bindcontext)
return ret;
}
bool udsWaitDataAvailable(udsBindContext *bindcontext, bool nextEvent, bool wait)
{
bool ret = true;
u64 delayvalue = U64_MAX;
if(!wait)delayvalue = 0;
if(nextEvent)svcClearEvent(bindcontext->event);
if(svcWaitSynchronization(bindcontext->event, delayvalue)!=0 && !wait)ret = false;
if(!nextEvent)svcClearEvent(bindcontext->event);
return ret;
}
static Result usd_parsebeacon(u8 *buf, u32 size, udsNetworkScanInfo *networkscan)
{
Result ret=0;