xref: /docs/en/application-dev/tools/cem-tool.md (revision e41f4b71)
1e41f4b71Sopenharmony_ci# Common Event Manager
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThe Common Event Manager enables you to print common event information and publish common events. It provides the common event debugging and testing capabilities, for example, printing all public event subscribers, sent public events, and recipients, and simulating public event release.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **NOTE**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> Before using this tool, you must obtain the <!--Del-->[<!--DelEnd-->hdc tool<!--Del-->](../../device-dev/subsystems/subsys-toolchain-hdc-guide.md)<!--DelEnd--> and run the hdc shell command.
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci## Commands
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci### help
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci* Function
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ci  Prints help information.
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ci* Method
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci  ```
20e41f4b71Sopenharmony_ci  cem help
21e41f4b71Sopenharmony_ci  ```
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci### publish
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ci* Function
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci  Publishes a common event.
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci* Method
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ci  ```
32e41f4b71Sopenharmony_ci  cem publish [<options>]
33e41f4b71Sopenharmony_ci  ```
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ci  The table below describes the available options.
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_ci  | Name        | Description                                  |
38e41f4b71Sopenharmony_ci  | ------------ | ------------------------------------------ |
39e41f4b71Sopenharmony_ci  | -e/--event   | Name of the common event to publish. Mandatory.                    |
40e41f4b71Sopenharmony_ci  | -o/--ordered | Indicates that the common event to publish is ordered. Optional. By default, non-ordered events are published.  |
41e41f4b71Sopenharmony_ci  | -c/--code    | Result code of the common event. Optional.                  |
42e41f4b71Sopenharmony_ci  | -d/--data    | Data carried in the common event. Optional.                |
43e41f4b71Sopenharmony_ci  | -h/--help    | Help information.                                  |
44e41f4b71Sopenharmony_ci
45e41f4b71Sopenharmony_ci* Example
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_ci  ```bash
48e41f4b71Sopenharmony_ci  # Publish a common event named testevent.
49e41f4b71Sopenharmony_ci  cem publish --event "testevent"
50e41f4b71Sopenharmony_ci  ```
51e41f4b71Sopenharmony_ci  
52e41f4b71Sopenharmony_ci  ![cem-publish-event](figures/cem-publish-event.png)
53e41f4b71Sopenharmony_ci  
54e41f4b71Sopenharmony_ci  ```bash
55e41f4b71Sopenharmony_ci  # Publish an ordered common event named testevent. The result code of the event is 100 and the data carried is "this is data".
56e41f4b71Sopenharmony_ci  cem publish -e "testevent" -o -c 100 -d "this is data"
57e41f4b71Sopenharmony_ci  ```
58e41f4b71Sopenharmony_ci  
59e41f4b71Sopenharmony_ci  ![cem-publish-all](figures/cem-publish-all.png)
60e41f4b71Sopenharmony_ci
61e41f4b71Sopenharmony_ci### dump
62e41f4b71Sopenharmony_ci
63e41f4b71Sopenharmony_ci> **NOTE**
64e41f4b71Sopenharmony_ci> 
65e41f4b71Sopenharmony_ci> The Common Event Manager has two editions: **eng** and **user**. The **dump** command can be used only in the **eng** edition. If it is used in the **user** edition, the message **error: user version cannot use dump** is reported.
66e41f4b71Sopenharmony_ci
67e41f4b71Sopenharmony_ci* Function
68e41f4b71Sopenharmony_ci
69e41f4b71Sopenharmony_ci  Displays information about common events.
70e41f4b71Sopenharmony_ci
71e41f4b71Sopenharmony_ci* Method
72e41f4b71Sopenharmony_ci
73e41f4b71Sopenharmony_ci  ```
74e41f4b71Sopenharmony_ci  cem dump [<options>]
75e41f4b71Sopenharmony_ci  ```
76e41f4b71Sopenharmony_ci
77e41f4b71Sopenharmony_ci  The table below describes the available options.
78e41f4b71Sopenharmony_ci
79e41f4b71Sopenharmony_ci  | Name      | Description                                    |
80e41f4b71Sopenharmony_ci  | ---------- | -------------------------------------------- |
81e41f4b71Sopenharmony_ci  | -a/--all   | Information about all common events that have been sent since system startup.|
82e41f4b71Sopenharmony_ci  | -e/--event | Information about a specific event.                  |
83e41f4b71Sopenharmony_ci  | -h/--help  | Help information.                                    |
84e41f4b71Sopenharmony_ci
85e41f4b71Sopenharmony_ci* Example
86e41f4b71Sopenharmony_ci
87e41f4b71Sopenharmony_ci  ```bash
88e41f4b71Sopenharmony_ci  # Display details of a common event named testevent.
89e41f4b71Sopenharmony_ci  cem dump -e "testevent"
90e41f4b71Sopenharmony_ci  ```
91e41f4b71Sopenharmony_ci
92e41f4b71Sopenharmony_ci  ![cem-dump-e](figures/cem-dump-e.png)
93