void main_test () { buf_t *p; int i = 0; const unsigned delay = 20; mdelay(start_delay); data_pattern = mem_alloc (&pool, packet_size); memset (data_pattern, 0xa5, packet_size); if (packet_size >= 12) memcpy (data_pattern+6, eth.netif.ethaddr, 6); unsigned long time0 = timer_milliseconds(&timer); while (1) { //for (i = 0; i < nb_of_packets; ++i) { /* Check received data. */ p = netif_input (ð.netif); if (p) { if (memcmp (p->payload, data_pattern, packet_size) != 0) nerr++; nb_of_received++; buf_free (p); continue; } /* Send packets - make transmit queue full. */ if (i++ < nb_of_packets) { p = buf_alloc (&pool, packet_size, 16); if (p) { memcpy (p->payload, data_pattern, packet_size); netif_output (ð.netif, p, 0, 0); } else debug_printf("no mem\n"); } if ((nb_of_received == nb_of_packets) || timer_passed(&timer, time0, delay * nb_of_packets * 2)) break; timer_delay (&timer, delay); } nerr += nb_of_packets - nb_of_received; STOP; }
void udp_task (void *data) { int i; buf_t *p; unsigned old_count = 0; unsigned long start, end, elapsed; unsigned long long bytes; start = timer_milliseconds (&timer); debug_printf ("Press ENTER to start sending to %d.%d.%d.%d:%d\n", server_ip[0], server_ip[1], server_ip[2], server_ip[3], PORT); debug_getchar (); udp_socket (&sock, &ip, PORT); trace_udp.udps_ip = (unsigned)sock.ip; for (;;) { p = buf_alloc (&pool, BUF_SIZE * 4, 42); for (i = 0; i < BUF_SIZE; ++i) buf[i] = count++; memcpy (p->payload, buf, sizeof(buf)); if (!udp_sendto (&sock, p, server_ip, PORT)){ count -= BUF_SIZE; debug_printf ("Press ENTER to start sending to %@.4D:%d\n", server_ip, PORT); while (debug_peekchar () < 0) task_yield(); debug_getchar (); } if (timer_passed (&timer, start, 1000)) { end = timer_milliseconds (&timer); elapsed = end - start; bytes = (count - old_count) << 2; old_count = count; debug_printf ("snd rate: %lu (bytes/sec)\n", (unsigned) (bytes * 1000 / elapsed)); start = end; } } }
void minerloop_queue(struct thr_info *thr) { struct thr_info *mythr; struct cgpu_info *cgpu = thr->cgpu; struct device_drv *api = cgpu->drv; struct timeval tv_now; struct timeval tv_timeout; struct cgpu_info *proc; bool should_be_running; struct work *work; if (thr->work_restart_notifier[1] == -1) notifier_init(thr->work_restart_notifier); while (likely(!cgpu->shutdown)) { tv_timeout.tv_sec = -1; timer_set_now(&tv_now); for (proc = cgpu; proc; proc = proc->next_proc) { mythr = proc->thr[0]; should_be_running = (proc->deven == DEV_ENABLED && !mythr->pause); redo: if (should_be_running) { if (unlikely(!mythr->_last_sbr_state)) { mt_disable_finish(mythr); mythr->_last_sbr_state = should_be_running; } if (unlikely(mythr->work_restart)) { mythr->work_restart = false; do_queue_flush(mythr); } while (!mythr->queue_full) { if (mythr->next_work) { work = mythr->next_work; mythr->next_work = NULL; } else { request_work(mythr); // FIXME: Allow get_work to return NULL to retry on notification work = get_and_prepare_work(mythr); } if (!work) break; if (!api->queue_append(mythr, work)) mythr->next_work = work; } } else if (unlikely(mythr->_last_sbr_state)) { mythr->_last_sbr_state = should_be_running; do_queue_flush(mythr); } if (timer_passed(&mythr->tv_poll, &tv_now)) api->poll(mythr); should_be_running = (proc->deven == DEV_ENABLED && !mythr->pause); if (should_be_running && !mythr->queue_full) goto redo; reduce_timeout_to(&tv_timeout, &mythr->tv_poll); } do_notifier_select(thr, &tv_timeout); } }
void minerloop_async(struct thr_info *mythr) { struct thr_info *thr = mythr; struct cgpu_info *cgpu = mythr->cgpu; struct device_drv *api = cgpu->drv; struct timeval tv_now; struct timeval tv_timeout; struct cgpu_info *proc; bool is_running, should_be_running; if (mythr->work_restart_notifier[1] == -1) notifier_init(mythr->work_restart_notifier); while (likely(!cgpu->shutdown)) { tv_timeout.tv_sec = -1; timer_set_now(&tv_now); for (proc = cgpu; proc; proc = proc->next_proc) { mythr = proc->thr[0]; // Nothing should happen while we're starting a job if (unlikely(mythr->busy_state == TBS_STARTING_JOB)) goto defer_events; is_running = mythr->work; should_be_running = (proc->deven == DEV_ENABLED && !mythr->pause); if (should_be_running) { if (unlikely(!(is_running || mythr->_job_transition_in_progress))) { mt_disable_finish(mythr); goto djp; } if (unlikely(mythr->work_restart)) goto djp; } else // ! should_be_running { if (unlikely(is_running && !mythr->_job_transition_in_progress)) { disabled: ; mythr->tv_morework.tv_sec = -1; if (mythr->busy_state != TBS_GETTING_RESULTS) do_get_results(mythr, false); else // Avoid starting job when pending result fetch completes mythr->_proceed_with_new_job = false; } } if (timer_passed(&mythr->tv_morework, &tv_now)) { djp: ; if (!do_job_prepare(mythr, &tv_now)) goto disabled; } defer_events: if (timer_passed(&mythr->tv_poll, &tv_now)) api->poll(mythr); reduce_timeout_to(&tv_timeout, &mythr->tv_morework); reduce_timeout_to(&tv_timeout, &mythr->tv_poll); } do_notifier_select(thr, &tv_timeout); } }
void test_arinc_main() { debug_printf("func_tx = %x, control1_tx = %x\n", func_tx, control1_tx); debug_printf("func_rx = %x, control1_rx = %x, control2_rx = %x\n", func_rx, control1_rx, control2_rx); debug_printf("channel out = %d, in = %d\n", MY_OUT_CHANNEL, MY_IN_CHANNEL); debug_printf("ssm data sdi label\n"); unsigned int counter = 0xee; ARINC_msg_t *const pCounter = (ARINC_msg_t *)&counter; pCounter->label = 0x30; pCounter->sdi = 1; pCounter->data = 0x1f; const int fifoCnt = 60; int i = 0; unsigned int data = 0; ARINC_msg_t *const pData = (ARINC_msg_t *)&data; int received = 0; unsigned long time0 = timer_milliseconds(&timer); for(;;) { // const ARINC_msg_t firstSentData = *pCounter; for (i=0; i<fifoCnt; ++i) { arinc_write(&atx, *pCounter); debug_printf("sent = %x = %x %x %x %x, status = %x\n", counter, pCounter->ssm, pCounter->data, pCounter->sdi, pCounter->label, ARM_ARINC429T->STATUS); ++counter; } for(;;) { if (arinc_read(&arx, pData)) { ++received; debug_printf("received=%08x (ssm=%x data=%x sdi=%x label=%x), status1 = %x, status2 = %x\n", data, pData->ssm, pData->data, pData->sdi, pData->label, ARM_ARINC429R->STATUS1, ARM_ARINC429R->STATUS2); // debug if (timer_passed(&timer, time0, 1000)) { static int ddd = 0; if (ddd == 0) debug_printf("received frames cnt = %d -------------\n", received); ddd = 1; } } else { if ((ARM_ARINC429R->STATUS1 & ARM_ARINC429R_STATUS1_ERR(MY_IN_CHANNEL)) > 0) { // Ошибка приёма debug_printf("rec error\n"); } else { debug_printf("no data received\n"); } break; } } timer_delay(&timer, 1000); // mdelay(1000); } }