⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kpd_test_misc0.c

📁 MMI层OBJ不能完全编译
💻 C
📖 第 1 页 / 共 5 页
字号:
   UINT16         received_event;
   T_RV_HDR*      msg_p;
   BOOL           exit = FALSE;

   T_KPD_SUBSCRIBER subscriber_id1;
   T_KPD_SUBSCRIBER subscriber_id2;
   T_KPD_VIRTUAL_KEY_TABLE notified_keys;
   T_RV_RETURN kpd_return_path;

   /* Test definition */
   kpd_test_trace("*** KPD TEST MISC11: Two subscribers");
   kpd_test_trace("*** KPD TEST MISC11: First subscriber:");
   kpd_test_trace("*** KPD TEST MISC11:    - notified for all keys for pressed and released event");
   kpd_test_trace("*** KPD TEST MISC11:    - Keys 1,4,7 also defined in long press (1 sec)");
   kpd_test_trace("*** KPD TEST MISC11:    - Keys 2,5,8 also defined in repeat press (1/0.5 sec)");
   kpd_test_trace("*** KPD TEST MISC11: Second subscriber:");
   kpd_test_trace("*** KPD TEST MISC11:    - notified for keys 1,2,3 and * for pressed and released event");
   kpd_test_trace("*** KPD TEST MISC11:    - Key 1 also defined in repeat press (2/1 sec)");
   kpd_test_trace("*** KPD TEST MISC11:    - Key 2 also defined in long press (2 sec)");
   kpd_test_trace("*** KPD TEST MISC11: Press DISC to exit");

   /* Keypad registration for subscriber1 */
   kpd_return_path.addr_id = kpd_test_path.addr_id + KPD_TEST_MBOX_1;
   kpd_return_path.callback_func = 0;
   notified_keys.nb_notified_keys = KPD_NB_PHYSICAL_KEYS;
   kpd_subscribe (&subscriber_id1,
                  KPD_DEFAULT_MODE,
                  &notified_keys,
                  kpd_return_path);
   kpd_define_key_notification(subscriber_id1,&notified_keys, KPD_FIRST_PRESS_NOTIF|KPD_RELEASE_NOTIF, 0, 0);

   /* Keypad registration for subscriber2 */
   kpd_return_path.addr_id = kpd_test_path.addr_id + KPD_TEST_MBOX_2;
   kpd_return_path.callback_func = 0;
   notified_keys.nb_notified_keys = 4;
   notified_keys.notified_keys[0] = KPD_KEY_1;
   notified_keys.notified_keys[1] = KPD_KEY_2;
   notified_keys.notified_keys[2] = KPD_KEY_3;
   notified_keys.notified_keys[3] = KPD_KEY_STAR;
   kpd_subscribe (&subscriber_id2,
                  KPD_DEFAULT_MODE,
                  &notified_keys,
                  kpd_return_path);
   kpd_define_key_notification(subscriber_id2,&notified_keys, KPD_FIRST_PRESS_NOTIF|KPD_RELEASE_NOTIF, 0, 0);

   /* Definition of repeat keys */
   notified_keys.nb_notified_keys = 3;
   notified_keys.notified_keys[0] = KPD_KEY_1;
   notified_keys.notified_keys[1] = KPD_KEY_4;
   notified_keys.notified_keys[2] = KPD_KEY_7;
   kpd_define_key_notification(subscriber_id1,&notified_keys, KPD_FIRST_PRESS_NOTIF|KPD_RELEASE_NOTIF|KPD_LONG_PRESS_NOTIF, 10, 5);
   
   notified_keys.nb_notified_keys = 3;
   notified_keys.notified_keys[0] = KPD_KEY_2;
   notified_keys.notified_keys[1] = KPD_KEY_5;
   notified_keys.notified_keys[2] = KPD_KEY_8;
   kpd_define_key_notification(subscriber_id1,&notified_keys, KPD_FIRST_PRESS_NOTIF|KPD_RELEASE_NOTIF|KPD_INFINITE_REPEAT_NOTIF, 10, 5);
  
   notified_keys.nb_notified_keys = 1;
   notified_keys.notified_keys[0] = KPD_KEY_1;
   kpd_define_key_notification(subscriber_id2,&notified_keys, KPD_FIRST_PRESS_NOTIF|KPD_RELEASE_NOTIF|KPD_INFINITE_REPEAT_NOTIF, 20, 10);
   
   notified_keys.nb_notified_keys = 1;
   notified_keys.notified_keys[0] = KPD_KEY_2;
   kpd_define_key_notification(subscriber_id2,&notified_keys, KPD_FIRST_PRESS_NOTIF|KPD_RELEASE_NOTIF|KPD_LONG_PRESS_NOTIF, 20, 10);

   /* loop to process messages */
   while (!exit)
   {
      /* Wait for the necessary events (infinite wait for a msg in the mailbox 1 / 2). */
      received_event = rvf_wait(RVF_TASK_MBOX_0_EVT_MASK,0);

      if (received_event & RVF_TASK_MBOX_0_EVT_MASK)
      {
         /* Read the message */
         msg_p = (T_RV_HDR *) rvf_read_mbox(0);

         if (msg_p->dest_addr_id == (kpd_test_path.addr_id + KPD_TEST_MBOX_1))
         {
            switch (msg_p->msg_id)
            {
               case KPD_KEY_EVENT_MSG:
                  {
                  T_KPD_KEY_EVENT_MSG* msg_key_event_p = (T_KPD_KEY_EVENT_MSG*) msg_p;

                  display_message(msg_key_event_p,2);

                  if ((msg_key_event_p->key_info.virtual_key_id == KPD_KEY_DISCONNECT) && (msg_key_event_p->key_info.state == KPD_KEY_RELEASED))
                  {
                     kpd_unsubscribe(&subscriber_id1);
                     kpd_unsubscribe(&subscriber_id2);
                     exit = TRUE;
                  }

                  break;
                  }

               case KPD_STATUS_MSG:
                  kpd_test_trace("Received status message in mailbox 1");
                  break;

               default :
                  break;

            }
            rvf_free_buf(msg_p);
         }

         if (msg_p->dest_addr_id == (kpd_test_path.addr_id + KPD_TEST_MBOX_2))
         {
            switch (msg_p->msg_id)
            {
               case KPD_KEY_EVENT_MSG:
                  {
                  T_KPD_KEY_EVENT_MSG* msg_key_event_p = (T_KPD_KEY_EVENT_MSG*) msg_p;

                  display_message(msg_key_event_p, 3);

                  break;
                  }

               case KPD_STATUS_MSG:
                  kpd_test_trace("Received status message in mailbox 2");
                  break;

               default :
                  break;

            }
            rvf_free_buf(msg_p);

         }
      }
   }


   return test_verdict;
}



/********************************************************************************/
/*                                                                              */
/*      Function Name:   kpd_test_misc_12                                       */
/*                                                                              */
/*      Notes:         This function executes KPD misc tests.                   */
/*                                                                              */
/*      Revision History:                                                       */
/*      11/05/01      Laurent Sollier         Create.                           */
/*                                                                              */
/********************************************************************************/
T_RV_MISC_RET kpd_test_misc_12(void)
{
   T_RV_MISC_RET  test_verdict   = TEST_PASSED;
   T_RV_RET ret;
   UINT8 i,j;
   char texte[100];

   T_KPD_SUBSCRIBER subscriber_id[32];
   T_KPD_VIRTUAL_KEY_TABLE notified_keys;
   T_RV_RETURN kpd_return_path;

   /* Test definition */
   kpd_test_trace("*** KPD TEST MISC12: ERROR TEST:");
   kpd_test_trace("*** KPD TEST MISC12: Subscription function");

   /* Keypad registration  */
   for (i = 0; i < 32; i++)
   {
      kpd_return_path.addr_id = kpd_test_path.addr_id + ((i)<<8);
      kpd_return_path.callback_func = 0;
      notified_keys.nb_notified_keys = KPD_NB_PHYSICAL_KEYS;
      ret = kpd_subscribe (&subscriber_id[i],
                           KPD_DEFAULT_MODE,
                           &notified_keys,
                           kpd_return_path);
      if (ret == RV_INTERNAL_ERR)
      {
         sprintf(texte, "*** KPD TEST MISC12: Number of authorized subscriber: %d\n", i);
         kpd_test_trace(texte);
         break;
      }
      else
      {
         sprintf(texte, "*** KPD TEST MISC12: Subscription number: %d\n", i);
         kpd_test_trace(texte);
      }
   }
   /* Unsubscription */
   for (j = 0; j < i; j++)
     kpd_unsubscribe(&subscriber_id[j]);

   /* Keypad registration with bad number of keys */
   kpd_return_path.addr_id = kpd_test_path.addr_id + KPD_TEST_MBOX_1;
   kpd_return_path.callback_func = 0;
   notified_keys.nb_notified_keys = 200;
   ret = kpd_subscribe (&subscriber_id[0],
                        KPD_DEFAULT_MODE,
                        &notified_keys,
                        kpd_return_path);

   if (ret == RV_INVALID_PARAMETER)
   {
      kpd_test_trace("*** KPD TEST MISC12: Error in key table => OK");
   }
   else
   {
      kpd_test_trace("*** KPD TEST MISC12: Error in key table has not been detected => ERROR");
      test_verdict = TEST_FAILED;
   }

   /* Keypad registration with bad number of keys */
   kpd_return_path.addr_id = kpd_test_path.addr_id + KPD_TEST_MBOX_1;
   kpd_return_path.callback_func = 0;
   notified_keys.nb_notified_keys = 250;
   ret = kpd_subscribe (&subscriber_id[0],
                        KPD_DEFAULT_MODE,
                        &notified_keys,
                        kpd_return_path);

   if (ret == RV_INVALID_PARAMETER)
   {
      kpd_test_trace("*** KPD TEST MISC12: Error in key table => OK");
   }
   else
   {
      kpd_test_trace("*** KPD TEST MISC12: Error in key table has not been detected => ERROR");
      test_verdict = TEST_FAILED;
   }

   return test_verdict;
}



/********************************************************************************/
/*                                                                              */
/*      Function Name:   kpd_test_misc_13                                       */
/*                                                                              */
/*      Notes:         This function executes KPD misc tests.                   */
/*                                                                              */
/*      Revision History:                                                       */
/*      11/05/01      Laurent Sollier         Create.                           */
/*                                                                              */
/********************************************************************************/
T_RV_MISC_RET kpd_test_misc_13(void)
{
   T_RV_MISC_RET  test_verdict   = TEST_PASSED;
   T_RV_RET ret;

   T_KPD_SUBSCRIBER subscriber_id = 0;
   T_KPD_VIRTUAL_KEY_TABLE notified_keys;
   T_RV_RETURN kpd_return_path;

   /* Test definition */
   kpd_test_trace("*** KPD TEST MISC13: ERROR TEST:");
   kpd_test_trace("*** KPD TEST MISC13: Try to define repeat key with an invalid subscriber id");

   /* Keypad registration with bad number of keys */
   kpd_return_path.addr_id = kpd_test_path.addr_id + KPD_TEST_MBOX_1;
   kpd_return_path.callback_func = 0;
   notified_keys.nb_notified_keys = 250;
   ret = kpd_subscribe (&subscriber_id,
                        KPD_DEFAULT_MODE,
                        &notified_keys,
                        kpd_return_path);
   if (ret != RV_OK)
   {
      kpd_test_trace("*** KPD TEST MISC13: Subscription has failed => OK");
   }
   else
   {
      kpd_test_trace("*** KPD TEST MISC13: Subscription has succeeded => ERROR");
      test_verdict = TEST_FAILED;
   }

   notified_keys.nb_notified_keys = KPD_NB_PHYSICAL_KEYS;
   ret = kpd_define_key_notification(subscriber_id,
                                     &notified_keys,
                                     KPD_LONG_PRESS_NOTIF,
                                     10,
                                     10);
   if (ret != RV_OK)
   {
      kpd_test_trace("*** KPD TEST MISC13: Repeat key definition has failed => OK");
   }
   else
   {
      kpd_test_trace("*** KPD TEST MISC13: Repeat key definition has succeeded => ERROR");
      test_verdict = TEST_FAILED;
   }

   return test_verdict;
   }



/********************************************************************************/
/*                                                                              */
/*      Function Name:   kpd_test_misc_14                                       */
/*                                                                              */
/*      Notes:         This function executes KPD misc tests.                   */
/*                                                                              */
/*      Revision History:                                                       */
/*      11/05/01      Laurent Sollier         Create.                           */
/*                                                                              */
/********************************************************************************/
T_RV_MISC_RET kpd_test_misc_14(void)
{
   T_RV_MISC_RET  test_verdict   = TEST_PASSED;
   UINT16         received_event;
   T_RV_HDR*      msg_p;
   BOOL           exit1 = FALSE;
   BOOL           exit2 = FALSE;

   T_KPD_SUBSCRIBER subscriber_id0;
   T_KPD_SUBSCRIBER subscriber_id1;
   T_KPD_VIRTUAL_KEY_TABLE notified_keys;
   T_RV_RETURN kpd_return_path;


   /* Test definition */
   kpd_test_trace("*** KPD TEST MISC14: Two subscribers");
   kpd_test_trace("*** KPD TEST MISC14: First subscriber:");
   kpd_test_trace("*** KPD TEST MISC14:    - notified for all keys for pressed and released event");
   kpd_test_trace("*** KPD TEST MISC14: Second subscriber:");
   kpd_test_trace("*** KPD TEST MISC14:    - notified for all keys for pressed and released event");
   kpd_test_trace("*** KPD TEST MISC14:    - Own the keypad for Keys 5, Up, #");
   kpd_test_trace("*** KPD TEST MISC14: Press * to cancel the own keypad privilege");


   /* Keypad registration */
   kpd_return_path.addr_id = kpd_test_path.addr_id + KPD_TEST_MBOX_0;
   kpd_return_path.callback_func = 0;
   notified_keys.nb_notified_keys = KPD_NB_PHYSICAL_KEYS;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -