/* FS = 8000 */ void tlv320_init(void) { uint8_t tlv[4]; if (i2c_read(codec_addr, 0, tlv, 4) < 0) { tracef("%s(): i2c_read() failed!", __func__); return; } tracef("%s(): 0x%02x 0x%02x 0x%02x 0x%02x", __func__, tlv[0], tlv[1], tlv[2], tlv[3]); // tlv320_wr(2, CR2_DIFBP | CR2_I2CX_SET(4) | CR2_HPC_I2C); // tlv320_wr(2, CR2_I2CX_SET(4) | CR2_HPC_I2C); tlv320_wr(3, CR3_PWDN_NO | CR3_OSR_512 | CR3_ASRF_1); /* 8000 sps */ tlv320_wr(4, CR4_M_SET(44)); /* 11025 sps */ // tlv320_wr(4, CR4_M_SET(32)); tlv320_wr(4, CR4_NP_SET(1, 2)); tlv320_wr(5, CR5A_ADGAIN_DB(0)); tlv320_wr(5, CR5B_DAGAIN_DB(0)); tlv320_wr(5, CR5C_DGSTG_MUTE | CR5C_INBG_6DB); tlv320_wr(6, CR3_AINSEL_INP_M1); tlv320_wr(1, CR1_CX | CR1_IIR | CR1_BIASV_LO | CR1_DAC16); };
int jitbuf_init(struct jitbuf *jb, uint32_t tsclk_rate, uint32_t sample_rate, uint32_t delay_ms) { uint32_t delay; uint32_t tbuf; int cnt; /* ceiling delay time in TSCLK periods */ delay = ((delay_ms * tsclk_rate) + 999) / 1000; /* ceiling buffer period in TSCLK periods */ tbuf = (SNDBUF_LEN * tsclk_rate) / sample_rate; cnt = delay / tbuf; tracef("%s(): delay=%d[ms],%d[TSCLK],%d[bufs]", __func__, delay_ms, delay, cnt); tracef("%s(): tbuf=%d[TSCLK]", __func__, tbuf); jb->head_ts = 0; jb->head = 0; jb->tail = 0; jb->delay = delay; jb->tbuf = tbuf; return 0; }
int init_target(void) { struct target_info * target; target = target_lookup(getenv("TARGET")); if (target == NULL) { target = target_first(); trace("WARNING: invalid target."); tracef("Fallback to default: %s.", target->name); }; trace("* target select..."); /* TODO: ice driver selection */ if (target_ice_configure(stdout, target, 1) < 0) { tracef("ERROR: target_ice_configure()!"); return -1; } tracef("* target: %s [%s-%s-%s %s-%s-%s]", target->name, target->arch->name, target->arch->model, target->arch->vendor, target->arch->cpu->family, target->arch->cpu->model, target->arch->cpu->vendor); if (target_config(stdout) < 0) { tracef("ERROR: target_config()!"); return -1; } return 0; }
/***************************************************************************** * * Name: calculate_late_charge * * Description: Calculate late charges against unpaid invoices * if needed * and create an NRC pcns for them. * * Input: none * Output: none ( new NRC type pcns ) * Returns: none * *****************************************************************************/ void calculate_late_charge(void) { Arb_date effective_dt; /* Don't calculate the late fee against unpaid invoices if: ** -System parameter hasn't enabled late fees (Late_fees_enabled = 0) ** -It's an interim bill && Late_fees_enabled = 1 ** -It's a quote. */ if (!Late_fees_enabled || (IS_INTERIM_BILL && Late_fees_enabled == 1 ) || Quote_mode) { tracef((char *)"calculate_late_charge", (char *)" Nothing to do"); return; } /** If Late_fees_enabled = 2 calculate only if account is disconnecting */ if ( Late_fees_enabled == 2) { if( okay_to_calc_disc_late_fee(dbfetch)) { effective_dt = Customer.termination_date; } else { tracef((char *)"calculate_late_charge", (char *)" Nothing to do"); return; } } else /* Late_fees_enabled == 1 */ { if ( Customer.account_status <= 0 ) /* regular case */ effective_dt = Customer.to; else /* disc request */ { if (Late_fee_suppress_disconnect > 0 ) return; else effective_dt = (!Arbdate_is_null(&Customer.termination_date) ? Customer.termination_date : Customer.to); } } if (process_invoice_late_fee(dbfetch, &effective_dt) != SUCCESS) gen_bill_error(BIPMOD, ERROR_ABORT_ACCOUNT, BIP_LATE_FEE_FAIL, BIP_LATE_FEE_FAIL, get_error_msg()); else { tracef((char *)"calculate_late_charge", (char *)" completed succesfully"); if ( Late_fees_enabled == 2) /*use CMF_BALANCE.late_fee_exempt < 0 to avoid late charge calculation in future */ arb_numeric_from_int(&Invoice_balance.cur_late_fee_exempt, -1); } return; }
int jitbuf_enqueue(struct jitbuf * jb, sndbuf_t * buf, uint32_t ts) { uint32_t head; uint32_t lvl; int32_t dt; /* get the queue head pointer */ head = jb->head; /* level of the current level of the queue */ lvl = head - jb->tail; if (lvl > JITBUF_FIFO_LEN) { tracef("%s(): ERROR ts=%d, fifo overflow!", __func__, ts); /* Queue is full, discard */ return -1; } if (lvl == JITBUF_FIFO_LEN) { tracef("%s(): ts=%d, fifo full!", __func__, ts); /* Queue is full, discard */ return -1; } if (sndbuf_use(buf) == NULL) { tracef("%s(): ts=%d, sndbuf_use() failed!", __func__, ts); /* Queue is full, discard */ return -1; } if (lvl == 0) { int cnt; /* Queue empty. Fill with silence up to "delay" time. */ dt = jb->delay; tracef("%s(): ts=%d, buffer empty, resync!", __func__, ts); /* Get how many frames we have to insert in the gap */ cnt = dt / jb->tbuf; /* The gap canont be higher than the available space in the fifo, less 1 position (reserved for insertion) */ cnt = MIN(cnt, JITBUF_FIFO_LEN - (lvl + 1)); tracef("%s(): dt=%d head=%d cnt=%d", __func__, dt, head, cnt); /* Fill the gap with silence */ while (cnt--) jb->fifo[head++ & (JITBUF_FIFO_LEN - 1)] = (sndbuf_t *)&sndbuf_zero; } jb->fifo[head++ & (JITBUF_FIFO_LEN - 1)] = buf; jb->head = head; jb->head_ts = ts + jb->tbuf; return 1; }
/*----------------------------------------------------------------------------+ | Function : WriteDetailStackToDB | | Description : Push the JNL_DETAIL stack onto the database using whatever method | of insertion has been chosen via the BLK_SWITCH system parameter | | Input : stk_ptr Pointer to detail stack | | Output : None | | Return : SUCCESS or FAILURE +----------------------------------------------------------------------------*/ int WriteDetailStackToDB (JNL_DETAIL_STACK *stk_ptr) { char *name = "WriteDetailStackToDB"; int rtv = SUCCESS; /*----------------------------------------------------------------------------+ | If no records, no work to do! +----------------------------------------------------------------------------*/ if (stk_ptr == NULL || stk_ptr->curr_pos == 0) return rtv; /*----------------------------------------------------------------------------+ | Push detail stack using appropriate method +----------------------------------------------------------------------------*/ switch (stk_ptr->method) { case JNL_BLK_BLK_CPY: tracef (name, "Writing %d JNL_DETAIL rows with Sybase bulk copy.", stk_ptr->curr_pos); if (BulkCopyRowInsertToDB (stk_ptr) == SUCCESS) WriteLogMessage (stk_ptr->ctrl_fd, stk_ptr->proc_id, __FILE__, __LINE__, JNL_BCP_SUCCESS, stk_ptr->curr_pos, NULL, "JNL_DETAIL", NULL, JNL_FORMAT_INT_CHAR); else rtv = FAILURE; break; case JNL_BLK_STK_INS: tracef (name, "Writing %d JNL_DETAIL with stacked inserts", stk_ptr->curr_pos); if (StackRowInsertToDB (stk_ptr) == SUCCESS) WriteLogMessage (stk_ptr->ctrl_fd, stk_ptr->proc_id, __FILE__, __LINE__, JNL_STK_SUCCESS, stk_ptr->curr_pos, NULL, "JNL_DETAIL", NULL, JNL_FORMAT_INT_CHAR); else rtv = FAILURE; break; case JNL_BLK_ARY_INS: tracef (name, "Writing %d JNL_DETAIL rows with Oracle array insert", stk_ptr->curr_pos); if (ArrayRowInsertToDB (stk_ptr) == SUCCESS) WriteLogMessage (stk_ptr->ctrl_fd, stk_ptr->proc_id, __FILE__, __LINE__, JNL_ARY_SUCCESS, stk_ptr->curr_pos, NULL, "JNL_DETAIL", NULL, JNL_FORMAT_INT_CHAR); else rtv = FAILURE; break; case JNL_BLK_SNG_INS: default: tracef (name, "Writing %d JNL_DETAIL rows with single row inserts", stk_ptr->curr_pos); if (SingleRowInsertToDB (stk_ptr) == SUCCESS) WriteLogMessage (stk_ptr->ctrl_fd, stk_ptr->proc_id, __FILE__, __LINE__, JNL_SGL_SUCCESS, stk_ptr->curr_pos, NULL, "JNL_DETAIL", NULL, JNL_FORMAT_INT_CHAR); else rtv = FAILURE; break; } stk_ptr->curr_pos = 0; return rtv; }
/** * is_internal is TRUE when called from wdjCallOldProc, that is to * say, when we're auto-unhooking. In that case, unhook no matter * what the ref_count is. */ static BOOL internal_unhook( WNDPROC id, HWND hwnd, BOOL is_internal ) { SUBCLASSING *pHead = getHead( hwnd ); SUBCLASSING *pThis = find( id, hwnd ); WNDPROC expected = 0; SUBCLASSING *pPrev = 0; if ( 0 == pThis ) { tracef( _T( "wdjUnhook: Subclassing %#x not found for hwnd %#x" ), id, hwnd ); DebugBreak(); return FALSE; //*** FUNCTION EXIT POINT } if ( !is_internal && 0 < --pThis->ref_count ) { tracef( _T( "wdjUnhook: " ) _T( "Decreasing ref_count for %#x (hwnd=%#x) to %d" ), pThis->wndProc, hwnd, pThis->ref_count ); return TRUE; //*** FUNCTION EXIT POINT } // Figure out what we're expecting as the saved proc if ( pHead == pThis ) { expected = getWndProc( hwnd ); } else { pPrev = findPrev( pHead, pThis ); expected = pPrev->wndProcSaved; } // Are we blocked? if ( expected != id ) { tracef( _T( "wdjUnhook: Subclassing %#x for %#x blocked by %#x" ), id, hwnd, expected ); return FALSE; //*** FUNCTION EXIT POINT } // OK, unlink if ( pHead == pThis ) { assert( 0 == pPrev ); tracef( _T( "wdjUnhook: Removing head of list wndproc %#x from window %#x" ), pThis->wndProc, hwnd ); SubclassWindow( hwnd, pThis->wndProcSaved ); setHead( hwnd, pThis->pNext ); } else { assert( 0 != pPrev ); tracef( _T( "wdjUnhook: Unlinking wndproc %#x from window %#x" ), pThis->wndProcSaved, hwnd ); pPrev->pNext = pThis->pNext; pPrev->wndProcSaved = pThis->wndProcSaved; } free( pThis ); releasePropertyName(); return TRUE; //*** FUNCTION EXIT POINT }
/*----------------------------------------------------------------------------+ | Function : NewDetailStack | | Description : Allocate a buffer for storing JNL_DETAIL rows. This is used to | hold rows prior to batch inserting them into the database using | Oracle array inserts or Sybase BCP. | | NOTE: The ctrl_fd is the pipe on which log information will be sent. | If it is left NULL it is assumed that this is being called in | the parent process and log entries can be written directly. | | Input : dbp Database connection which is used for writing DETAIL rows | method Insertion method to use | bsize Batch size to use for stack / DB buffer | ctrl_fd Control pipe handle (NULL if not used) | proc_id Process id for process using these routines | | Output : None | | Return : Pointer to detail stack, NULL if failure +----------------------------------------------------------------------------*/ JNL_DETAIL_STACK * NewDetailStack (Arb_connection *dbp, JNL_BLK_METHOD method, int bsize, FILE *ctrl_fd, JNL_PROCESS_ID proc_id) { char *name = "InitialiseDetailStack"; JNL_DETAIL_STACK *stk_ptr = NULL; /*----------------------------------------------------------------------------+ | Some error checking... +----------------------------------------------------------------------------*/ if (bsize <= 0 || dbp == NULL) { tracef (name, "Invalid batch size (%d) or NULL dbp pointer passed", bsize); return NULL; } if (method <= JNL_BLK_NULL || method >= JNL_BLK_NUM_METHODS) { tracef (name, "Invalid value for JNL BLK_SWITCH parameter (%d)", method); return NULL; } /*----------------------------------------------------------------------------+ | Initialise stack and allocate space for the detail rows +----------------------------------------------------------------------------*/ if ((stk_ptr = malloc (sizeof(JNL_DETAIL_STACK))) == NULL) { WriteLogMessage (ctrl_fd, proc_id, __FILE__, __LINE__, JNL_MEM_ALLOC, sizeof(JNL_DETAIL_STACK), NULL, "JNL_DETAIL_STACK Struct", NULL, JNL_FORMAT_INT_CHAR); return NULL; } stk_ptr->stk_ptr = (JNL_DETAIL *)calloc (bsize, sizeof(JNL_DETAIL)); if (stk_ptr->stk_ptr == NULL) { free (stk_ptr); WriteLogMessage (ctrl_fd, proc_id, __FILE__, __LINE__, JNL_MEM_ALLOC, bsize*sizeof(JNL_DETAIL), NULL, "JNL_DETAIL Stack", NULL, JNL_FORMAT_INT_CHAR); return NULL; } stk_ptr->ctrl_fd = ctrl_fd; stk_ptr->proc_id = proc_id; stk_ptr->batch_size = bsize; stk_ptr->total_jd = 0; /*DENqa71320, initialized to 0*/ stk_ptr->dbp = dbp; stk_ptr->curr_pos = 0; stk_ptr->method = method; return stk_ptr; }
BOOL wdjSubclass( WNDPROC wndProc, HWND hwnd, void *pData ) { SUBCLASSING *pHead = getHead( hwnd ); SUBCLASSING *pThis = find( wndProc, hwnd ); WNDPROC curr = getWndProc( hwnd ); // If this subclassing has been applied before, just increase // the reference count and smile. It won't be called twice in // the chain, it won't be moved to the front of the chain, // and it won't be unhooked until wdjUnhook() has been called // the same number of times that wdjSubclass() was called. if ( 0 != pThis ) { assert( pData == pThis->pData ); ++pThis->ref_count; tracef( _T( "wdjSubclass: Increasing ref_count for " ) _T( "%#x (hwnd=%#x) to %d" ), pThis->wndProc, hwnd, pThis->ref_count ); return TRUE; //*** FUNCTION EXIT POINT } // Applying the current window function as a subclassing is // almost certainly an error, so don't. (If the new and current // window function are the same because of previous subclassing, // it's OK, and caught by the previous test for 0 != pThis. if ( curr == wndProc ) { tracef( _T( "wdjSubclass: Attempting to apply current wndproc " ) _T( "%#x to %#x refused" ), pThis->wndProc, hwnd ); DebugBreak(); return FALSE; //*** FUNCTION EXIT POINT } // We have a spankin' new subclassing for this window: if ( allocPropertyName() ) { if ( 0 != (pThis = malloc( sizeof( *pThis ) ) ) ) { if ( initNode( hwnd, pThis, wndProc, pData, pHead ) ) { if ( setHead( hwnd, pThis ) ) { tracef( _T( "wdjSubclass: Adding new wndproc %#x " ) _T( "to window %#x" ), pThis->wndProc, hwnd ); return TRUE; //*** FUNCTION EXIT POINT } SubclassWindow( hwnd, pThis->wndProcSaved ); } free( pThis ); } releasePropertyName(); } return FALSE; //*** FUNCTION EXIT POINT }
void tlv320_status(void) { uint8_t tlv[8]; tracef("%s()...", __func__); if (i2c_read(codec_addr, 0, tlv, 8) < 0) { tracef("%s(): i2c_read() failed!", __func__); return; } tracef("%s(): 0x%02x 0x%02x 0x%02x 0x%02x", __func__, tlv[0], tlv[1], tlv[2], tlv[3]); tracef("%s(): 0x%02x 0x%02x 0x%02x 0x%02x", __func__, tlv[4], tlv[5], tlv[6], tlv[7]); }
int net_init(void) { tracef("%s():...", __func__); if (lattice_ice40_configure(ice40lp384_bin, sizeof_ice40lp384_bin) < 0) { trace("lattice_ice40_configure() failed!"); return -1; } /* IO init */ stm32_gpio_mode(RS485_RX, ALT_FUNC, PULL_UP); stm32_gpio_af(RS485_RX, GPIO_AF7); stm32_gpio_mode(RS485_TX, ALT_FUNC, PUSH_PULL | SPEED_MED); stm32_gpio_af(RS485_TX, GPIO_AF7); #ifdef RS485_CK stm32_gpio_mode(RS485_CK, ALT_FUNC, PUSH_PULL | SPEED_MED); stm32_gpio_af(RS485_CK, GPIO_AF7); #endif #ifdef RS485_TRIG stm32_gpio_mode(RS485_TRIG, INPUT, PULL_UP); #endif #ifdef RS485_TXEN stm32_gpio_mode(RS485_TXEN, OUTPUT, PUSH_PULL | SPEED_MED); stm32_gpio_set(RS485_TXEN); #endif #ifdef RS485_LOOP stm32_gpio_mode(RS485_LOOP, OUTPUT, PUSH_PULL | SPEED_MED); stm32_gpio_set(RS485_LOOP); #endif #ifdef RS485_MODE stm32_gpio_mode(RS485_MODE, OUTPUT, PUSH_PULL | SPEED_LOW); stm32_gpio_set(RS485_MODE); #endif if (!net.initialized) { /* Link init */ rs485_init(&net.link, RS485_USART, RS485_LINK_SPEED, USART1_DMA, USART1_DMA_CHAN, USART1_RX_DMA_STRM, USART1_TX_DMA_STRM); /* initialize the packet buffer pool */ pktbuf_pool_init(); net_recv_init(); net.probe_flag = thinkos_flag_alloc(); net.initialized = true; } return 0; }
int net_recv(void * buf, int len) { void * pkt; pkt = pktbuf_alloc(); if (pkt == NULL) { DCC_LOG(LOG_ERROR, "pktbuf_alloc() failed!"); tracef("%s(): pktbuf_alloc() failed!\n", __func__); return -1; } len = rs485_pkt_receive(&net.link, &pkt, pktbuf_len); // tracef("%s(): len=%d\n", __func__, len); DCC_LOG1(LOG_TRACE, "%d", len); DCC_LOG2(LOG_TRACE, "pkt=%p len=%d", pkt, len); if (pkt != NULL) { memcpy(buf, pkt, len); pktbuf_free(pkt); } return len; }
bool CConfigManager::getConfig(const char* name, CConfigTable& table) { CGuard guard(m_mutex); int ret = applySuccess; if (strcmp(name, "All") == 0) { table = m_configAll; tracef("CConfigManager::getConfig get all Configs.\n"); return true; } if(m_configDefault[name].type() == Json::nullValue) { warnf("CConfigManager::getConfig '%s', but default config is not set yet!\n", name); // 直接返回,不做默认配置替换和配置校验 table = m_configAll[name]; return table.type() != Json::nullValue; } table = m_configAll[name]; tracepoint(); infof("name is [%s]\n", name); //std::cout << table << std::endl; return table.type() != Json::nullValue; }
int bpr_table(RA charges, int type) { int count, index, index1; NEW_CHARGE *new_chg; char datebuff[256]; char from_date[256]; char to_date[256]; char *money; Arb_numeric amount; unsigned char display_type; g_curr_table = BPR_TABLE; /* set the g_curr_table for is_valid_new_charge */ count = UsesRA(charges); for(index = 0; index <= count; index++) { new_chg = (NEW_CHARGE *) RAIndex(charges, index); /* check new charge to determine if it needs to be formatted */ display_type = is_valid_new_charge(new_chg, g_curr_table, g_curr_prod); tracef ("bpr_table", "display type %d", display_type); if (!display_type) continue; /* if it matches and type is TABLE_COUNT, return, otherwise print it */ if (TABLE_COUNT == type) return TRUE; /* g_table_total += FormatRecurringCharges(g_curr_prod, PART_PERIOD); */ FormatRecurringCharges(g_curr_prod, PART_PERIOD, &amount); arb_num_arith (&g_table_total, &g_table_total, ARB_NUM_ADD, &amount); } return FALSE; }
int main(int argc, char **argv) { int i; unsigned int nr_iter = 100; useconds_t nr_usec = 0; char *tmp_file_path = NULL; if (argc >= 2) { nr_iter = atoi(argv[1]); } if (argc >= 3) { /* By default, don't wait unless user specifies. */ nr_usec = atoi(argv[2]); } if (argc >= 4) { tmp_file_path = argv[3]; } for (i = 0; i < nr_iter; i++) { tracef("Test message %d with string \"%s\"", i, str); /* * First loop we create the file if asked to indicate * that at least one tracepoint has been hit. */ if (i == 0 && tmp_file_path) { create_file(tmp_file_path); } usleep(nr_usec); } return 0; }
/*************************************************************************** * * Name: orig_type_to_target_type * * Description: Given the original type of charge, as read from ADJ, returns * the valid target type of the adjustment that can adjust it * * Input: orig_type -- value of ADJ.orig_type * orig_subtype -- value of ADJ.orig_subtype * * Output: None * Returns: valid value of ADJ_TRANS_DESCR.trans_target_type * ***************************************************************************/ static int orig_type_to_target_type(int orig_type, int orig_subtype) { int target_type = 0; switch (orig_type) { case SUMMARY_TYPE: /* 87584: ADJ_TAX_TARGET SHOULD BE TREATED AS SAME AS ADJ_MISC_TARGET if ((orig_subtype == TAX_SUBTOTAL_TYPE) || (orig_subtype == TAX_PREPAID_SUBTOTAL_TYPE)) target_type = ADJ_TAX_TARGET; else */ target_type = ADJ_MISC_TARGET; break; case NRC_TYPE: target_type = ADJ_NRC_TARGET; break; case USAGE_TYPE: target_type = ADJ_USAGE_TARGET; break; case RC_TYPE: target_type = ADJ_RC_TARGET; break; case ADJ_TYPE: target_type = ADJ_MISC_TARGET; break; default: tracef((char *)"orig_type_to_target_type", (char *)"Adjustment orig_type %d, can't be adjusted!", orig_type); gen_bill_error(BIPMOD, ERROR_CONTINUE, BIP_BAD_ADJ_SOURCE, BIP_BAD_DATA_ERR, orig_type); target_type = ADJ_MISC_TARGET; break; } return target_type; }
void net_pkt_recv(struct net_pkt * pkt, int len) { void * buf = NULL; int data_len; uint16_t crc; data_len = len - sizeof(struct net_pkt); crc = pkt->crc; pkt->crc = 0; if (crc16ccitt(0, pkt, data_len + sizeof(struct net_pkt)) != crc) { tracef("%s(): CRC error!", __func__); data_len = -1; net.stat.rx.err_cnt++; } else if (data_len != pkt->data_len) { tracef("%s(): invalid data_len=%d!", __func__, data_len); data_len = -1; net.stat.rx.err_cnt++; } else { net.stat.rx.pkt_cnt++; net.stat.rx.octet_cnt += data_len + sizeof(struct net_pkt); if (pkt->seq != net.rx_seq) { int32_t n; n = (int32_t)(pkt->seq - net.rx_seq); if (n > 0) { tracef("%s(): SEQ error: %d pkts lost!", __func__, n); net.stat.rx.seq_err_cnt += n; } net.rx_seq = pkt->seq; } net.rx_seq++; if (buf != NULL) { uint8_t * src; uint8_t * dst; int i; src = (uint8_t *)pkt->data; dst = (uint8_t *)buf; for (i = 0; i < data_len; ++i) dst[i] = src[i]; } } }
/** * @brief Send a number of bytes to the server. * * @param[in] msg The message, a sequence of bytes. * @param[in] n The number of bytes from msg to send. * * @return 0 for success, any other value for failure. */ int sendn_to_server (const void * msg, size_t n) { if (TO_SERVER_BUFFER_SIZE - to_server_end < n) { tracef (" sendn_to_server: available space (%i) < n (%zu)\n", TO_SERVER_BUFFER_SIZE - to_server_end, n); return 1; } memmove (to_server + to_server_end, msg, n); tracef ("s> server (string) %.*s\n", (int) n, to_server + to_server_end); tracef ("-> server %zu bytes\n", n); to_server_end += n; return 0; }
/*----------------------------------------------------------------------------+ | Function : JournalFeedRun | | Description : Entry point for JNL feed file processing. Will retrieve data from | JNL_DETAIL or JNL_TRANS and produce a report formatted according to | layout defined in JNL_FEED_LAYOUT etc. | | Input : None | | Output : None | | Return : None +----------------------------------------------------------------------------*/ void JournalFeedRun (void) { char *name = "JournalFeedRun"; int timer_total; int timer_item; tracef (name, "<<<************ TYPE FOUR RUN ************>>>"); tracef (name, "Initializing JNL feed task"); emit (JNLMOD, JNL_TASK_START, JNL_TYPE_JNL_FEED_TRANS, JnlTypeDescription (JNL_TYPE_JNL_FEED_TRANS)); clear_cycle_run_error(); if (crt_jnl_refno()==FAILURE) { return; } JNL_START_TIMER (g_iJnl_ref_no, JNL_TYPE_JNL_FEED_TRANS, "TOTAL", timer_total); AddTaskToControlLog(); if (lock_run() == FAILURE) return; free_feed_info(); init_feed_info(); JNL_START_TIMER (g_iJnl_ref_no, JNL_TYPE_JNL_FEED_TRANS, "FEED_CREATION", timer_item); jnl_build_feed_file(); JNL_LOG_TIMER (timer_item); JNL_START_TIMER (g_iJnl_ref_no, JNL_TYPE_JNL_FEED_TRANS, "COMMIT", timer_item); CommitJournalRun(); JNL_LOG_TIMER (timer_item); free_feed_info(); JNL_LOG_TIMER (timer_total); emit (JNLMOD, JNL_TASK_FINISHED, JNL_TYPE_JNL_FEED_TRANS, JnlTypeDescription (JNL_TYPE_JNL_FEED_TRANS)); tracef (name, "Completed JNL feed task"); tracef (name, "***********************************************"); }
void tlv320_reset(void) { uint8_t tlv[4]; tracef("%s()...", __func__); if (i2c_read(codec_addr, 0, tlv, 4) < 0) { tracef("%s(): i2c_read() failed!", __func__); return; } /* reset the device */ tlv320_wr(3, CR3_PWDN_NO | CR3_SWRS); /* wait at least 132MCLK ~ 12us (11.2896 MHz) */ thinkos_sleep(1); }
void __attribute__((noreturn)) net_recv_task(void) { void * pkt; int len; DCC_LOG1(LOG_TRACE, "thread=%d", thinkos_thread_self()); tracef("%s(): <%d> started...", __func__, thinkos_thread_self()); for (;;) { pkt = pktbuf_alloc(); if (pkt == NULL) { DCC_LOG(LOG_ERROR, "pktbuf_alloc() failed!"); tracef("%s(): pktbuf_alloc() failed!", __func__); thinkos_sleep(1000); continue; } len = rs485_pkt_receive(&net.link, &pkt, pktbuf_len); if (len < 0) { tracef("%s(): rs485_pkt_receive() failed!", __func__); thinkos_sleep(1000); continue; } if (len == 0) { tracef("%s(): rs485_pkt_receive() == 0!", __func__); thinkos_sleep(1000); continue; } if (pkt != NULL) { if (net.probe_mode) net_probe_recv((char *)pkt, len); else if (net.pkt_mode) net_pkt_recv((struct net_pkt *)pkt, len); else net_recv((char *)pkt, len); pktbuf_free(pkt); } } }
void net_recv(char * s, int len) { net.stat.rx.pkt_cnt++; net.stat.rx.octet_cnt += len; s[len] = '\0'; // tracef("net rx: len=%d", len); tracef("\"%s\"", s); }
void audio_stream_enable(void) { if (!audio_drv.enabled) return; if (audio_drv.stream_enabled) return; audio_drv.stream_enabled = true; tracef("%s(): audio stream enabled.", __func__); }
void audio_stream_disable(void) { if (!audio_drv.enabled) return; if (!audio_drv.stream_enabled) return; audio_drv.stream_enabled = false; tracef("%s(): audio stream disabled.", __func__); }
// // Return the size of a previously allocated memory block. // size_t Heap::size(void* ptr) { Print tracef(this->output()); if (this->tracing) { tracef("Heap[%o]::size(%p)\n", this, ptr); } Alignment* optr = static_cast<Alignment*>(ptr); size_t osize = 0; if (0 != optr) { osize = *(optr - 1); } if (this->tracing) { tracef("Heap[%p]::size(%p)=%lu\n", this, ptr, osize); } return osize; }
// // Free a block of memory. // void Heap::free(void* ptr) { Print tracef(this->output()); if (this->tracing) { tracef("Heap[%p]::free(%p)\n", this, ptr); } Alignment* optr = static_cast<Alignment*>(ptr); if (0 != optr) { size_t osize = *(--optr); size_t nsize = bytes(words(osize)); this->current -= nsize; delete [] optr; ++this->frees; } else { ++this->nulls; } }
int usb_shell(void) { int th; th = thinkos_thread_create_inf((void *)usb_task, NULL, &usb_shell_inf); tracef("USB CDC-ACM shell thread=%d", th); return th; }
int tftpd_start(void) { int th; th = thinkos_thread_create_inf((void *)tftp_daemon_task, (void *)&debugger, &tftpd_inf); tracef("TFTPD started th=%d", th); return 0; }
void ILSGlobalSolverSequential::optimize (vector < ROUTE_DATA_TYPE > &route, int once) { unsigned long temp; INIT_TRACEF temp = routeLength (route, coords); bestGlobalMinimaLengths.push_back (temp); bestGlobalMinima.push_back (route); trace ("[%s] Initial minimum (%ld) -> Length: %ld = %.5f%% of the target\n", localSolver->getDescription().c_str(), bestGlobalMinima.size(), bestGlobalMinimaLengths.back(), 100.0 * (double) bestGlobalMinimaLengths.back() / (double) solution); tracef ("%ld, %.5f\n", bestGlobalMinimaLengths.back(), 100.0 * (double) bestGlobalMinimaLengths.back() / (double) solution); do { localSolver->optimize (route, bestGlobalMinimaLengths); temp = routeLength (route, coords); if (temp < bestGlobalMinimaLengths.back() ) { bestGlobalMinimaLengths.push_back (temp); bestGlobalMinima.push_back (route); trace ("[%s] New global minimum (%ld) -> Length: %ld = %.5f%% of the target\n", localSolver->getDescription().c_str(), bestGlobalMinima.size(), bestGlobalMinimaLengths.back(), 100.0 * (double) bestGlobalMinimaLengths.back() / (double) solution); tracef ("%ld, %.5f\n", bestGlobalMinimaLengths.back(), 100.0 * (double) bestGlobalMinimaLengths.back() / (double) solution); } else { route = bestGlobalMinima.back(); } if (once == 1) break; randomPerturbation (route); } while ( (solution * (1.0f + error) < bestGlobalMinimaLengths.back() ) && (timelimit == 0 || (getTotalTime() < timelimit) ) ); }
int main(int argc, char *argv[]) { int i, chg, rev, np; progname = argv[0]; if (argc != 2) { fprintf(stderr, "Usage: %s dict\n", progname); exit(1); } tracef("Started"); readdict(argv[1]); tracef("Dictionary read"); rdict = (Word **)xmalloc(nword*sizeof(Word *)); memcpy(rdict, dict, nword*sizeof(Word *)); qsort(dict, nword, sizeof(Word *), wordcmp); /* sort forwards */ tracef("Sorted fwd"); qsort(rdict, nword, sizeof(Word *), rwordcmp); /* sort backwards */ tracef("Sorted bwd"); for (i=0; i<nword; i++) { dict[i]->map = (1<<(dict[i]->len+1))-1; } tracef("Set map"); rev = FALSE; do { chg = FALSE; for (i=0; i<nword; i++) { if ((rev? check_rword: check_word)(dict[i])) chg = TRUE; } if ((np = purge()) != 0) chg = TRUE; tracef("%d words purged", np); rev = !rev; } while (chg); printdict(dict); return 0; }