/* Returns 0 for successful reset of at least one device; 1 for no devices detected, 2 for bus shorted to 0v, 3 for bus shorted to +5v */ static uint8_t owb_reset(void) { uint8_t r; /* Idle 1-wire bus is high. Pull low for 480us to reset. */ OWB_LOW(); OWB_OUT(); _delay_us(20); if (OWB_READ()==1) return 3; _delay_us(460); ATOMIC_BLOCK(ATOMIC_FORCEON) { OWB_IN(); _delay_us(64); r=OWB_READ(); /* 0 if any slave is present or bus is shorted, else 1 */ } /* After the presence pulse the slaves should all stop pulling down */ _delay_us(480 - 64); if (OWB_READ()==0) { record_error(&owb_shorted_cnt); return 2; } if (r) record_error(&owb_missing_cnt); return r; }
void graph::ops::do_record_fatal_error (const OMX_HANDLETYPE handle, const OMX_ERRORTYPE error, const OMX_U32 port) { std::string msg ("["); msg.append (handle2name (handle)); if (port != OMX_ALL) { msg.append (":port:"); msg.append (boost::lexical_cast< std::string >(port)); } msg.append ("]\n ["); msg.append (std::string (tiz_err_to_str (error))); msg.append ("]"); record_error (error, msg); }
void bundle_slurp(struct para_bundle * pb, struct ifile ifi, _Bool reg) { int fd = open_ifile(ifi); if (fd == -1) { record_error(); return; } FSAF * f = fsaf_fdopen(fd, ifi.s); if (f == 0) fatal_enomem(0); struct srcfile * sf = malloc(sizeof *sf); if (sf == 0) fatal_enomem(0); sf->ifi = ifi; sf->fd = fd; sf->fs = f; sf->next = pb->files; pb->files = sf; para_parser_init(&sf->pp, f, false, false, reg); while (true) { if (pb->num_paras == pb->max_num) { size_t max_num = pb->max_num == 0 ? 256 : 2 * pb->max_num; para_t ** paras = realloc(pb->paras, max_num * sizeof *paras); if (paras == 0) fatal_enomem(0); pb->max_num = max_num; pb->paras = paras; } assert(pb->num_paras < pb->max_num); assert(pb->paras != 0); para_t * p = new_para(&pb->pool, &sf->pp); if (p == 0) fatal_enomem(0); para_parse_next(p); if (para_eof(&sf->pp)) break; debug("pb->num_paras = %zi", pb->num_paras); pb->paras[pb->num_paras++] = p; } // DO NOT CLOSE fsaf -- this makes the whole para_bundle useless! // fsaf_close(f); close_ifile(ifi, fd); }
int add_macros( pmtoken current_token, pmmacro first_macro ) { pmmacro current_macro, scan_macro; current_macro = first_macro; while (current_token) { if (current_token->state == SLABEL_OR_MACRO) { if (current_token->next->state == SMACRO) { /* We have a new macro ! */ if (strcmp(current_token->next->text, "MACRO")) { record_error("malformed macro line"); } else { /* Add current_token to macro list */ current_macro = create_macro( current_token, current_macro ); } } } current_token = current_token->next; } }
pmmacro create_macro( pmtoken start_token, pmmacro current_macro ) { pmtoken token, token_copy; pmdefine arg; int first; current_macro->next = malloc( sizeof(mmacro)); current_macro = current_macro->next; current_macro->next = NULL; strcpy( current_macro->name, start_token->text ); /* Find the token after the next RST and copy off the args */ token = start_token->next->next; first = 1; current_macro->args = NULL; while ((token)&&(token->state != RST)) { /* Add an arg to the list */ if (first) { current_macro->args = malloc( sizeof(mdefine)); first = 0; arg = current_macro->args; } else { arg->next = malloc(sizeof(mdefine)); arg = arg->next; } strcpy( arg->find, token->text ); arg->next = NULL; token = token->next; } if (token) { token = token->next; /* Start of macro body */ if (token) { /* ...potentially null */ /* Copy from here into the macro */ first = 1; while ((token)&&(strcmp(token->text, "ENDM"))) { if (first) { current_macro->macro = malloc(sizeof(mtoken)); first = 0; token_copy = current_macro->macro; token_copy->next = NULL; } else { token_copy->next = malloc(sizeof(mtoken)); token_copy = token_copy->next; } memcpy( token_copy, token, sizeof(mtoken)); token_copy->next = NULL; token = token->next; } /* Strip out all the tokens that describe the macro */ start_token->previous->next = token->next; return current_macro; } record_error( "Improperly terminated macro" ); return NULL; } record_error( "Improperly terminated macro" ); return NULL; };