RedisReply* CoroRedisClient::SyncCall(RedisCommandFrame& cmd, int timeout) { Clear(); m_expected_multi_reply_count = 1; m_ch->Write(cmd); CreateTimeoutTask(timeout); if (0 != WaitCoro()) { return NULL; } if (!m_connect_success) { m_error_reply.SetErrorReason("client connection closed."); return &m_error_reply; } if (IsTimeout()) { m_error_reply.SetErrorReason("server timeout"); return &m_error_reply; } RedisReply* r = NULL; if (m_multi_replies.size() > 0) { r = m_multi_replies[0]; } CancelTimeoutTask(); return r; }
bool I2C::IsError() { bool isError = false; if (IsARLO()) { ClearARLO(); isError = true; ++_errorCountARLO; } if (IsAF()) { ClearAF(); isError = true; ++_errorCountAF; } if (IsTimeout()) { ClearTimeout(); isError = true; ++_errorCountTO; } if (IsBusError()) { ClearBusError(); isError = true; ++_errorCountBE; } return isError; }
RedisReplyArray* CoroRedisClient::SyncMultiCall(RedisCommandFrameArray& cmds, int timeout) { Clear(); m_expected_multi_reply_count = cmds.size(); for (size_t i = 0; i < cmds.size(); i++) { m_ch->Write(cmds[i]); } CreateTimeoutTask(timeout); if (0 != WaitCoro()) { return NULL; } if (!m_connect_success) { m_error_reply.SetErrorReason("client connection closed."); FillErrorReply(); return &m_multi_replies; } if (IsTimeout()) { m_error_reply.SetErrorReason("server timeout."); FillErrorReply(); return &m_multi_replies; } CancelTimeoutTask(); return &m_multi_replies; }
/* ============= SV_CheckStuck This is a big hack to try and fix the rare case of getting stuck in the world clipping hull. ============= */ void SV_CheckStuck (edict_t *ent) { int i, j; int z; vec3_t org; static float lastmsg = 0, lastmsg2 = 0; if (!SV_TestEntityPosition(ent)) { VectorCopy (ent->v.origin, ent->v.oldorigin); return; } VectorCopy (ent->v.origin, org); VectorCopy (ent->v.oldorigin, ent->v.origin); if (!SV_TestEntityPosition(ent)) { if (IsTimeout (&lastmsg2, 2)) Con_DPrintf ("Unstuck.\n"); SV_LinkEdict (ent, true); return; } for (z=0 ; z< 18 ; z++) for (i=-1 ; i <= 1 ; i++) for (j=-1 ; j <= 1 ; j++) { ent->v.origin[0] = org[0] + i; ent->v.origin[1] = org[1] + j; ent->v.origin[2] = org[2] + z; if (!SV_TestEntityPosition(ent)) { if (IsTimeout (&lastmsg2, 2)) Con_DPrintf ("Unstuck.\n"); SV_LinkEdict (ent, true); return; } } VectorCopy (org, ent->v.origin); if (IsTimeout (&lastmsg, 2)) Con_DPrintf ("player is stuck.\n"); }
void I2C::HandleErrorInterrupt() { if (_irqErrorHandler) { I2C_IRQ_Error_Info info; if (IsBusError()) { info.BusError = true; ClearBusError(); } if (IsARLO()) { info.ArbitrationLoss = true; ClearARLO(); } if (IsAF()) { info.AckFailure = true; ClearAF(); } if (IsOVR()) { info.OverrunUnderrun = true; ClearOVR(); } if (IsPECError()) { info.PECError = true; ClearPECERR(); } if (IsTimeout()) { info.Timeout = true; ClearTimeout(); } if (IsSMBAlert()) { info.SMBAlert = true; ClearSMBAlert(); } _irqErrorHandler->HandleErrorInterrupt(this, info); } }
//---------------------------------------------------------------------- // IEEE SEND ATN static int8_t IeeeAtnOut(uint8_t by) { while(1) { IeeeNrfd(1); IeeeNdac(1); if(last_byte >= 0) { // SEND LAST BYTE WITH EOI IeeeEoi(0); IeeeByteOut(last_byte); IeeeEoi(1); last_byte = -1; } else { ieee_timer = 255; // 255ms timeout while(!IEEE_DAV) // WAIT WHILE DAV { if(IsTimeout()) { ieee_status |= IEEE_ST_ATTO; // ATN-OUT timeout return 1; } } } IeeeAtn(0); // SET ATN _delay_us(ATN_DELAY); if(IeeeByteOut(by)) break; // // ATN ok, device selected ==> next send SA // return 0; } // // abort // IeeeAtn(1); // ATN hi return 1; }
//---------------------------------------------------------------------- // IEEE GET BYTE static uint8_t IeeeIn(void) { uint8_t rc=0; #ifdef DEBUG1 uartPrintf_p("IeeeIn()"); uartPutCrLf(); #endif IeeeNdac(0); // NDAC low IeeeNrfd(1); // ready for data! ieee_timer = 65; // 65ms timeout while(1) // WAIT FOR DAV { if(!IEEE_DAV) { break; } if(IsTimeout()) { ieee_status |= IEEE_ST_RDTO; // read timeout IeeeNdac(0); // NDAC low IeeeNrfd(0); // NRFD low return 0; } } _delay_us(1); rc = ~IEEE_DATA; if(!IEEE_EOI) { ieee_status |= IEEE_ST_EOI; // last byte - EOI eoi = 1; // for XUM1541_IOCTL } IeeeNrfd(0); // NRFD low _delay_us(1); IeeeNdac(1); // data accepted! while(!IEEE_DAV) // WAIT FOR DAV HIGH wdt_reset(); IeeeNdac(0); // NDAC low return rc; }
bool CoroChannel::SyncConnect(Address* addr, int timeout) { if (NULL == m_ch) { return false; } if (!m_ch->Connect(addr)) { return false; } CreateTimeoutTask(timeout); if (0 != WaitCoro()) { return -1; } if (IsTimeout()) { return false; } return m_connect_success; }
//---------------------------------------------------------------------- // IEEE SEND BYTE static int8_t IeeeByteOut(uint8_t by) { int8_t rc=0; IeeeDav(1); if(IEEE_NRFD && IEEE_NDAC) { ieee_status |= IEEE_ST_DNP; // !!DEVICE NOT PRESENT return 1; } while(!IEEE_NRFD) // WAIT WHILE NRFD wdt_reset(); // watchdog IeeeDataOut(~by); // OUTPUT! _delay_us(5); IeeeDav(0); ieee_timer = 65; // 65ms timeout while(!IEEE_NDAC) // WAIT FOR DAC { if(IsTimeout()) { ieee_status |= IEEE_ST_WRTO; // 65ms write timeout rc = 1; break; } } IeeeDav(1); IeeeDataIn(); // DATAPORT INPUT! return rc; }
/* ================== SV_StartSound Each entity can have eight independant sound sources, like voice, weapon, feet, etc. Channel 0 is an auto-allocate channel, the others override anything already running on that entity/channel pair. An attenuation of 0 will play full volume everywhere in the level. Larger attenuations will drop off. (max 4 attenuation) ================== */ void SV_StartSound (edict_t *entity, int channel, char *sample, int volume, float attenuation) { int sound_num; int field_mask; int i; int ent; static float lastmsg = 0; if (volume < 0 || volume > 255) { Con_Warning ("SV_StartSound: volume = %d, max = %d\n", volume, 255); volume = CLAMP(0, volume, 255); } if (attenuation < 0 || attenuation > 4) { Con_Warning ("SV_StartSound: attenuation = %f, max = %d\n", attenuation, 4); attenuation = CLAMP(0, attenuation, 4); } if (channel < 0 || channel > 7) { Con_Warning ("SV_StartSound: channel = %i, max = %d\n", channel, 7); channel = CLAMP(0, channel, 7); } // drop silently if there is no room if (sv.datagram.cursize > ((sv.protocol == PROTOCOL_NETQUAKE) ? 1024 : MAX_DATAGRAM) - 16) return; // find precache number for sound for (sound_num=1 ; sound_num<MAX_SOUNDS && sv.sound_precache[sound_num] ; sound_num++) if (!strcmp(sample, sv.sound_precache[sound_num])) break; if ( sound_num == MAX_SOUNDS || !sv.sound_precache[sound_num] ) { if (IsTimeout (&lastmsg, 2)) { // let's not upset and annoy the user Con_DPrintf ("SV_StartSound: %s not precacheed\n", sample); } return; } ent = NUM_FOR_EDICT(entity); field_mask = 0; if (volume != DEFAULT_SOUND_PACKET_VOLUME) field_mask |= SND_VOLUME; if (attenuation != DEFAULT_SOUND_PACKET_ATTENUATION) field_mask |= SND_ATTENUATION; //johnfitz -- PROTOCOL_FITZQUAKE if (ent >= 8192) { if (sv.protocol == PROTOCOL_FITZQUAKE || sv.protocol == PROTOCOL_MARKV || sv.protocol == PROTOCOL_RMQ) field_mask |= SND_LARGEENTITY; else return; // don't send any info protocol can't support } if (sound_num >= 256 || channel >= 8) { if (sv.protocol == PROTOCOL_FITZQUAKE || sv.protocol == PROTOCOL_MARKV || sv.protocol == PROTOCOL_RMQ) field_mask |= SND_LARGESOUND; else return; // don't send any info protocol can't support } //johnfitz // directed messages go only to the entity the are targeted on MSG_WriteByte (&sv.datagram, svc_sound); MSG_WriteByte (&sv.datagram, field_mask); if (field_mask & SND_VOLUME) MSG_WriteByte (&sv.datagram, volume); if (field_mask & SND_ATTENUATION) MSG_WriteByte (&sv.datagram, attenuation*64); //johnfitz -- PROTOCOL_FITZQUAKE if (field_mask & SND_LARGEENTITY) { MSG_WriteShort (&sv.datagram, ent); MSG_WriteByte (&sv.datagram, channel); } else MSG_WriteShort (&sv.datagram, (ent<<3) | channel); if (field_mask & SND_LARGESOUND) MSG_WriteShort (&sv.datagram, sound_num); else MSG_WriteByte (&sv.datagram, sound_num); //johnfitz for (i=0 ; i<3 ; i++) MSG_WriteCoord (&sv.datagram, entity->v.origin[i]+0.5*(entity->v.mins[i]+entity->v.maxs[i]), sv.protocolflags); }
/* =================== R_SplitEntityOnNode =================== */ void R_SplitEntityOnNode (mnode_t *node) { efrag_t *ef; mplane_t *splitplane; mleaf_t *leaf; int sides; static float lastmsg = 0; if (node->contents == CONTENTS_SOLID) { return; } // add an efrag if the node is a leaf if ( node->contents < 0) { if (!r_pefragtopnode) r_pefragtopnode = node; leaf = (mleaf_t *)node; // grab an efrag off the free list ef = cl.free_efrags; if (!ef) { if (IsTimeout (&lastmsg, 2)) Con_Printf ("Too many efrags! (max = %d)\n", MAX_EFRAGS); return; // no free fragments... } cl.free_efrags = cl.free_efrags->entnext; ef->entity = r_addent; // add the entity link *lastlink = ef; lastlink = &ef->entnext; ef->entnext = NULL; // set the leaf links ef->leaf = leaf; ef->leafnext = leaf->efrags; leaf->efrags = ef; return; } // NODE_MIXED splitplane = node->plane; sides = BOX_ON_PLANE_SIDE(r_emins, r_emaxs, splitplane); if (sides == 3) { // split on this plane // if this is the first splitter of this bmodel, remember it if (!r_pefragtopnode) r_pefragtopnode = node; } // recurse down the contacted sides if (sides & 1) R_SplitEntityOnNode (node->children[0]); if (sides & 2) R_SplitEntityOnNode (node->children[1]); }
static void DelayMs(uint16_t ms) { ieee_timer = ms; while(!IsTimeout()); }