Ejemplo n.º 1
0
int main(int argc, char *argv[])
{
   int ctime;

   printf("SOEM (Simple Open EtherCAT Master)\nRedundancy test\n");

   if (argc > 3)
   {
      dorun = 0;
      ctime = atoi(argv[3]);

      /* create RT thread */
      osal_thread_create_rt(&thread1, stack64k * 2, &ecatthread, (void*) &ctime);

      /* create thread to handle slave error handling in OP */
      osal_thread_create(&thread2, stack64k * 4, &ecatcheck, NULL);

      /* start acyclic part */
      redtest(argv[1],argv[2]);
   }
   else
   {
      printf("Usage: red_test ifname1 ifname2 cycletime\nifname = eth0 for example\ncycletime in us\n");
   }

   printf("End program\n");

   return (0);
}
Ejemplo n.º 2
0
int main(int argc, char *argv[])
{
   ec_adaptert * adapter = NULL;   
   printf("SOEM (Simple Open EtherCAT Master)\nSimple test\n");

   if (argc > 1)
   {      
      /* create thread to handle slave error handling in OP */
      osal_thread_create(&thread1, 128000, &ecatcheck, (void*) &ctime);
      strcpy(ifbuf, argv[1]);
      /* start cyclic part */
      simpletest(ifbuf);
   }
   else
   {
      printf("Usage: simple_test ifname1\n");
   	/* Print the list */
      printf ("Available adapters\n");
      adapter = ec_find_adapters ();
      while (adapter != NULL)
      {
         printf ("Description : %s, Device to use for wpcap: %s\n", adapter->desc,adapter->name);
         adapter = adapter->next;
      }
   }   
   
   printf("End program\n");
   return (0);
}
Ejemplo n.º 3
0
INT32 hifsdiod_start(void)
{
    int iRet = -1;
	init_waitqueue_head(&gHifsdiodEvent);
#if 0
    osal_event_init(&gHifsdiodEvent);
    gConIdQueryThread.pThreadData = (VOID *)NULL;
    gConIdQueryThread.pThreadFunc = (VOID *)hif_sdio_proc;
    osal_memcpy(gConIdQueryThread.threadName, gConIdQueryName , osal_strlen(gConIdQueryName));
	

    iRet = osal_thread_create(&gConIdQueryThread);
    if (iRet < 0) 
    {
        HIF_SDIO_ERR_FUNC("osal_thread_create fail...\n");
        goto ERR_EXIT1;
    }
#else
    gConIdQueryThread = kthread_create(hif_sdio_proc, NULL, gConIdQueryName);
    if (NULL == gConIdQueryThread) 
    {
        HIF_SDIO_ERR_FUNC("osal_thread_create fail...\n");
        goto ERR_EXIT1;
    }

#endif

#if 0
    /* Start STPd thread*/
    iRet = osal_thread_run(&gConIdQueryThread);
    if(iRet < 0)
    {
        HIF_SDIO_ERR_FUNC("osal_thread_run FAILS\n");
        goto ERR_EXIT1;
    }
#else
    if (gConIdQueryThread) {
        wake_up_process(gConIdQueryThread);
    }
	else
	{
	    goto ERR_EXIT1;
	}
#endif
    iRet = 0;
	HIF_SDIO_INFO_FUNC("succeed\n");

	return iRet;
	
ERR_EXIT1:
	HIF_SDIO_ERR_FUNC("failed\n");
	return iRet;
 }
MTKSTP_BTM_T *stp_btm_init(void)
{
    INT32 i = 0x0;
    INT32 ret =-1;
    
    osal_unsleepable_lock_init(&stp_btm->wq_spinlock);
    osal_event_init(&stp_btm->STPd_event);
    stp_btm->wmt_notify = wmt_lib_btm_cb;
    
    RB_INIT(&stp_btm->rFreeOpQ, STP_BTM_OP_BUF_SIZE);
    RB_INIT(&stp_btm->rActiveOpQ, STP_BTM_OP_BUF_SIZE);

    /* Put all to free Q */
    for (i = 0; i < STP_BTM_OP_BUF_SIZE; i++) 
    {
         osal_signal_init(&(stp_btm->arQue[i].signal));
         _stp_btm_put_op(stp_btm, &stp_btm->rFreeOpQ, &(stp_btm->arQue[i]));
    }

    /*Generate PSM thread, to servie STP-CORE for packet retrying and core dump receiving*/
    stp_btm->BTMd.pThreadData = (VOID *)stp_btm;
    stp_btm->BTMd.pThreadFunc = (VOID *)_stp_btm_proc;
    osal_memcpy(stp_btm->BTMd.threadName, BTM_THREAD_NAME , osal_strlen(BTM_THREAD_NAME));

    ret = osal_thread_create(&stp_btm->BTMd);
    if (ret < 0) 
    {
        STP_BTM_ERR_FUNC("osal_thread_create fail...\n");
        goto ERR_EXIT1;
    }
    
    /* Start STPd thread*/
    ret = osal_thread_run(&stp_btm->BTMd);
    if(ret < 0)
    {
        STP_BTM_ERR_FUNC("osal_thread_run FAILS\n");
        goto ERR_EXIT1;
    }

    return stp_btm;

ERR_EXIT1:

    return NULL;

}
Ejemplo n.º 5
0
int main(int argc, char *argv[])
{
   printf("SOEM (Simple Open EtherCAT Master)\nSimple test\n");

   if (argc > 1)
   {
      /* create thread to handle slave error handling in OP */
//      pthread_create( &thread1, NULL, (void *) &ecatcheck, (void*) &ctime);
      osal_thread_create(&thread1, 128000, &ecatcheck, (void*) &ctime);
      /* start cyclic part */
      pthread_create(&read_thread, NULL, read_stdin, NULL);
      simpletest(argv[1]);
   }
   else
   {
      printf("Usage: simple_test ifname1\nifname = eth0 for example\n");
   }

   printf("End program\n");
   return (0);
}
Ejemplo n.º 6
0
static INT32 mtk_wmt_func_on_background(void)
{
	INT32 iRet = 0;
	OSAL_THREAD bgFuncOnThread;
	P_OSAL_THREAD pThread = &bgFuncOnThread;
	/* Create background power on thread */
    osal_strncpy(pThread->threadName, ("mtk_wmtd_pwr_bg"), sizeof(pThread->threadName));
    pThread->pThreadData = NULL;
    pThread->pThreadFunc = (VOID *)wmt_pwr_on_thread;
    iRet = osal_thread_create(pThread);
    if (iRet) {
        WMT_ERR_FUNC("osal_thread_create(0x%p) fail(%d)\n", pThread, iRet);
        return -1;
    }
	/* 3. start: start running background power on thread*/
    iRet = osal_thread_run(pThread);
    if (iRet) {
        WMT_ERR_FUNC("osal_thread_run(0x%p) fail(%d)\n", pThread, iRet);
        return -2;
    }
	return 0;
}