├── LICENSE ├── README.md ├── hellomethod ├── LICENSE ├── Makefile.am ├── README.md ├── bootstrap.sh ├── configure.ac ├── main.cpp ├── method_tutorial.cpp ├── method_tutorial.hpp └── xyz │ └── openbmc_project │ └── tutorial │ └── hellomethod │ └── Manager.interface.yaml ├── lessonaddtoflash.md ├── lessonbusmethod.md ├── lessonrobot.md ├── lessonsdk101.md ├── lessonsim101.md ├── lessonwatch.md ├── openbmc-test-automation └── tests │ └── test_hellomethod.robot └── watcher ├── LICENSE ├── Makefile.am ├── README.md ├── bootstrap.sh ├── configure.ac └── main.cpp /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # openbmc-tutorials 2 | A series of simple lessons on working with the OpenBMC Project. 3 | The lessons are laid out assuming you only have access to github. 4 | Some are dependant on previous lessons, when this occurs I have 5 | placed links. 6 | 7 | ## Lessons 8 | 1. [Build the Simulator](lessonsim101.md) 9 | 2. [Hello World with the SDK](lessonsdk101.md) 10 | 3. [Watch the bus](lessonwatch.md) 11 | 4. [Hop on the bus](lessonbusmethod.md) 12 | 5. [Get in the flash](lessonaddtoflash.md) 13 | 6. [Test with Robot](lessonrobot.md) 14 | -------------------------------------------------------------------------------- /hellomethod/LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /hellomethod/Makefile.am: -------------------------------------------------------------------------------- 1 | BUILT_SOURCES = \ 2 | xyz/openbmc_project/tutorial/hellomethod/Manager/server.cpp \ 3 | xyz/openbmc_project/tutorial/hellomethod/Manager/server.hpp 4 | 5 | 6 | sbin_PROGRAMS = hellomethod 7 | hellomethod_SOURCES = \ 8 | method_tutorial.cpp \ 9 | xyz/openbmc_project/tutorial/hellomethod/Manager/server.cpp \ 10 | main.cpp 11 | 12 | 13 | hellomethod_LDFLAGS = $(SYSTEMD_LIBS) $(SDBUSPLUS_LIBS) \ 14 | $(PHOSPHOR_DBUS_INTERFACES_LIBS) 15 | hellomethod_CFLAGS = $(SYSTEMD_CFLAGS) $(SDBUSPLUS_CFLAGS) \ 16 | $(PHOSPHOR_DBUS_INTERFACES_CFLAGS) 17 | 18 | xyz/openbmc_project/tutorial/hellomethod/Manager/server.cpp: xyz/openbmc_project/tutorial/hellomethod/Manager.interface.yaml xyz/openbmc_project/tutorial/hellomethod/Manager/server.hpp 19 | @mkdir -p `dirname $@` 20 | $(SDBUSPLUSPLUS) -r $(srcdir) interface server-cpp xyz.openbmc_project.tutorial.hellomethod.Manager > $@ 21 | 22 | xyz/openbmc_project/tutorial/hellomethod/Manager/server.hpp: xyz/openbmc_project/tutorial/hellomethod/Manager.interface.yaml 23 | @mkdir -p `dirname $@` 24 | $(SDBUSPLUSPLUS) -r $(srcdir) interface server-header xyz.openbmc_project.tutorial.hellomethod.Manager > $@ -------------------------------------------------------------------------------- /hellomethod/README.md: -------------------------------------------------------------------------------- 1 | To build this package, do the following steps: 2 | 3 | 1. ./bootstrap.sh 4 | 2. ./configure ${CONFIGURE_FLAGS} 5 | 3. make 6 | 7 | To full clean the repository again run `./bootstrap.sh clean`. 8 | -------------------------------------------------------------------------------- /hellomethod/bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | AUTOCONF_FILES="Makefile.in aclocal.m4 ar-lib autom4te.cache compile \ 4 | config.guess config.h.in config.sub configure depcomp install-sh \ 5 | ltmain.sh missing *libtool test-driver" 6 | 7 | case $1 in 8 | clean) 9 | test -f Makefile && make maintainer-clean 10 | for file in ${AUTOCONF_FILES}; do 11 | find -name "$file" | xargs -r rm -rf 12 | done 13 | exit 0 14 | ;; 15 | esac 16 | 17 | autoreconf -i 18 | echo 'Run "./configure ${CONFIGURE_FLAGS} && make"' -------------------------------------------------------------------------------- /hellomethod/configure.ac: -------------------------------------------------------------------------------- 1 | AC_PREREQ([2.69]) 2 | AC_INIT([hellomethod], [1.0]) 3 | AC_LANG([C++]) 4 | AC_CONFIG_HEADERS([config.h]) 5 | AM_INIT_AUTOMAKE([subdir-objects -Wall -Werror foreign dist-xz]) 6 | AM_SILENT_RULES([yes]) 7 | 8 | # Checks for programs 9 | AC_PROG_CXX 10 | AC_PROG_INSTALL #Checks/sets the install variable to be used 11 | AC_PROG_MAKE_SET 12 | 13 | # Check for libraries 14 | PKG_CHECK_MODULES([SYSTEMD], [libsystemd >= 221]) 15 | PKG_CHECK_MODULES([PHOSPHOR_DBUS_INTERFACES], [phosphor-dbus-interfaces],, \ 16 | AC_MSG_ERROR(["Requires phosphor-dbus-interfaces package."])) 17 | PKG_CHECK_MODULES([SDBUSPLUS], [sdbusplus],, \ 18 | AC_MSG_ERROR(["Requires sdbusplus package."])) 19 | 20 | # Checks for typedefs, structures, and compiler characteristics. 21 | AX_CXX_COMPILE_STDCXX_14([noext]) 22 | AX_APPEND_COMPILE_FLAGS([-Wall -Werror], [CXXFLAGS]) 23 | 24 | # Checks for library functions 25 | LT_INIT # Removes WARNING: unrecognized options: --with-libtool-sysroot 26 | 27 | # Check for sdbus++ 28 | AC_PATH_PROG([SDBUSPLUSPLUS], [sdbus++]) 29 | AS_IF([test "x$SDBUSPLUSPLUS" == "x"], 30 | AC_MSG_ERROR(["Requires sdbus++"])) 31 | 32 | AC_ARG_VAR(BMC_BUSNAME, [The BMC Dbus busname to own]) 33 | AS_IF([test "x$BMC_BUSNAME" == "x"], [BMC_BUSNAME="xyz.openbmc_project.Tutorials"]) 34 | AC_DEFINE_UNQUOTED([BMC_BUSNAME], ["$BMC_BUSNAME"], [The BMC DBus busname to own]) 35 | 36 | AC_ARG_VAR(BMC_OBJPATH, [The BMC state manager Dbus root]) 37 | AS_IF([test "x$BMC_OBJPATH" == "x"], [BMC_OBJPATH="/xyz/openbmc_project/tutorial/hellomethod"]) 38 | AC_DEFINE_UNQUOTED([BMC_OBJPATH], ["$BMC_OBJPATH"], [The BMC state manager Dbus root]) 39 | 40 | 41 | # Check for header files. 42 | AC_CHECK_HEADER(systemd/sd-bus.h, ,[AC_MSG_ERROR([Could not find systemd/sd-bus.h...systemd developement package required])]) 43 | AC_CHECK_HEADER(sdbusplus/bus/match.hpp, ,[AC_MSG_ERROR([Could not find sdbusplus/server/match.hpp...openbmc/sdbusplus package required])]) 44 | 45 | AC_CONFIG_FILES([Makefile]) 46 | AC_OUTPUT -------------------------------------------------------------------------------- /hellomethod/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "config.h" 4 | #include "xyz/openbmc_project/tutorial/hellomethod/Manager/server.hpp" 5 | #include "method_tutorial.hpp" 6 | 7 | int main(int argc, char**) 8 | { 9 | auto bus = sdbusplus::bus::new_default(); 10 | 11 | // Add sdbusplus ObjectManager. 12 | sdbusplus::server::manager::manager objManager(bus, BMC_OBJPATH); 13 | 14 | phosphor::tutorial::Manager manager(bus, 15 | BMC_OBJPATH); 16 | 17 | bus.request_name(BMC_BUSNAME); 18 | 19 | while(true) 20 | { 21 | bus.process_discard(); 22 | bus.wait(); 23 | } 24 | 25 | exit(EXIT_SUCCESS); 26 | 27 | } -------------------------------------------------------------------------------- /hellomethod/method_tutorial.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "method_tutorial.hpp" 3 | 4 | 5 | namespace phosphor 6 | { 7 | namespace tutorial 8 | { 9 | 10 | void Manager::commit(int32_t transactionId, std::string msg) 11 | { 12 | fprintf(stderr,"Hi from the commit: Message = %s\n", msg.c_str()); 13 | } 14 | 15 | } // tutorial 16 | } -------------------------------------------------------------------------------- /hellomethod/method_tutorial.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "xyz/openbmc_project/tutorial/hellomethod/Manager/server.hpp" 5 | 6 | namespace phosphor 7 | { 8 | namespace tutorial 9 | { 10 | 11 | using ManagerIface = sdbusplus::server::object::object< 12 | sdbusplus::xyz::openbmc_project::tutorial::hellomethod::server::Manager>; 13 | 14 | /** @class Manager 15 | * @brief OpenBMC logging manager implementation. 16 | * @details A concrete implementation for the 17 | * xyz.openbmc_project.Logging.Internal.Manager DBus API. 18 | */ 19 | class Manager : public ManagerIface 20 | { 21 | public: 22 | 23 | /** @brief Constructor to put object onto bus at a dbus path. 24 | * @param[in] bus - Bus to attach to. 25 | * @param[in] path - Path to attach at. 26 | */ 27 | Manager(sdbusplus::bus::bus& bus, const char* objPath) : 28 | ManagerIface(bus, objPath) {}; 29 | 30 | /* 31 | * @fn commit() 32 | * @brief sd_bus Commit method implementation callback. 33 | * @details Create an error/event log based on transaction id and 34 | * error message. 35 | * @param[in] transactionId - Unique identifier of the journal entries 36 | * to be committed. 37 | * @param[in] msg - The error exception message associated with the 38 | * error log to be committed. 39 | */ 40 | void commit(int32_t transactionId, std::string msg) override; 41 | 42 | }; 43 | 44 | } // namespace logging 45 | } // namespace phosphor -------------------------------------------------------------------------------- /hellomethod/xyz/openbmc_project/tutorial/hellomethod/Manager.interface.yaml: -------------------------------------------------------------------------------- 1 | description: > 2 | Some simple method that exposes a method on dbus 3 | methods: 4 | - name: Commit 5 | description: > 6 | You call this and a print should appear 7 | parameters: 8 | - name: transactionId 9 | type: int32 10 | description: > 11 | Example allows for numbers and strings 12 | - name: msg 13 | type: string 14 | description: > 15 | The msg that was sent -------------------------------------------------------------------------------- /lessonaddtoflash.md: -------------------------------------------------------------------------------- 1 | # Add your code to the flash image 2 | 3 | This tutorial will show you how to get the code you have working from [Hop on the bus](lessonbusmethod.md) 4 | in to a flash iamge. This allows you to not have to scp the files over 5 | every time and also introduces you to yocto recipies. 6 | 7 | Simple follow the steps laid out in the [OpenBMC Yocto documentation](https://github.com/openbmc/docs/blob/master/yocto-development.md) 8 | and replace `welcome` with `hellomethod` 9 | 10 | ## Extra Credit 11 | The shows tutorial shows how to add the code to your flash image but doesn't show 12 | how to launch it as part of the boot process. Fix up the build to have it running 13 | at boot. -------------------------------------------------------------------------------- /lessonbusmethod.md: -------------------------------------------------------------------------------- 1 | # A method on the bus 2 | In this tutorial you will create a method and attach to the bus using 3 | yaml and c++. Make sure you have setup the SDK first. The build files 4 | for this tutorial are located [here](hellomethod) 5 | 6 | 7 | ### Makefile updates to support YAML dbus object 8 | Notice the Makefile added more then just a couple of files. These lines tell 9 | the build to generate C++ code from the easy to read 10 | [yaml](hellomethod/xyz/openbmc_project/tutorial/hellomethod/Manager.interface.yaml) file 11 | 12 | ``` 13 | BUILT_SOURCES = \ 14 | xyz/openbmc_project/tutorial/lesson3/Manager/server.cpp \ 15 | xyz/openbmc_project/tutorial/lesson3/Manager/server.hpp 16 | ... 17 | xyz/openbmc_project/tutorial/hellomethod/Manager/server.cpp: xyz/openbmc_project/tutorial/hellomethod/Manager.interface.yaml xyz/openbmc_project/tutorial/hellomethod/Manager/server.hpp 18 | @mkdir -p `dirname $@` 19 | $(SDBUSPLUSPLUS) -r $(srcdir) interface server-cpp xyz.openbmc_project.tutorial.hellomethod.Manager > $@ 20 | 21 | xyz/openbmc_project/tutorial/hellomethod/Manager/server.hpp: xyz/openbmc_project/tutorial/hellomethod/Manager.interface.yaml 22 | @mkdir -p `dirname $@` 23 | $(SDBUSPLUSPLUS) -r $(srcdir) interface server-header xyz.openbmc_project.tutorial.hellomethod.Manager > $@ 24 | ``` 25 | 26 | 27 | ## Steps 28 | 29 | 1. Build like the [readme](hellomethod/README.md) indicates. 30 | 2. Copy the `hellomethod` to the system and run 31 | 3. Examine dbus 32 | 33 | ``` 34 | $ busctl introspect xyz.openbmc_project.Tutorials /xyz/openbmc_project/tutorial/hellomethod 35 | 36 | xyz.openbmc_project.tutorial.hellomethod.Manager interface - - - 37 | .Commit method is 38 | ``` 39 | 40 | And there is the Commit Method, along with the introspection showing what type are the input 41 | parameters. 42 | 43 | 4. Now it is time to call the method. Here are a couple of different ways 44 | 45 | Locally on the system... 46 | 47 | ``` 48 | busctl call xyz.openbmc_project.Tutorials /xyz/openbmc_project/tutorial/hellomethod \ 49 | xyz.openbmc_project.tutorial.hellomethod.Manager Commit is 1 "Hi Chris" 50 | ``` 51 | 52 | Via curl _assuming you have already [logged in](https://github.com/openbmc/docs/blob/master/rest-api.md#logging-in)_ 53 | 54 | ``` 55 | curl -b cjar -k -H "Content-Type: application/json" -X POST -d '{"data": [1, "Hi Chris"]}' \ 56 | https://bmc/xyz/openbmc_project/tutorial/hellomethod/action/commit 57 | 58 | ``` 59 | 60 | 61 | ## Extra Credit 62 | Rather then printing the text to the screen save it to a property. Broadcast a signal annoucing you did it. -------------------------------------------------------------------------------- /lessonrobot.md: -------------------------------------------------------------------------------- 1 | # Test your change with the Robot Framework 2 | 3 | This tutorial will show you how to use the OpenBMC Project's Functional 4 | Testing Framework to valid your code. This lesson relies on the 5 | [Get in the flash](lessonaddtoflash.md) `hellomethod` file for what to test. 6 | 7 | ## What is the Robot Framework 8 | The OpenBMC Project was created by developers who knew the importance of 9 | automated testing. It's not as if code ever changes maintainers or is effected 10 | by anything else _right?_. So from the beginning, automation of the user 11 | interfaces has happened. The [Robot Framework](http://robotframework.org) 12 | fit our needs perfectly. 13 | 14 | 15 | ## Getting Started 16 | The test automation is in its own [repository](https://github.com/openbmc/openbmc-test-automation). 17 | Follow the [quick start](https://github.com/openbmc/openbmc-test-automation#quickstart) 18 | section to install any dependencies. 19 | 20 | In the previous [Get in the flash](lessonaddtoflash.md) tutorial I had 21 | you running the `hellomethod` in qemu. Make sure you still have it running. 22 | 23 | Time to create your first Robot test. This is the same file as [here](openbmc-test-automation/tests/test_hellomethod.robot) 24 | This is what your first Robot test will look like. A few things to note about 25 | syntax 26 | 1. Robot requires 2 spaces between words that should be seperated. 27 | 2. Best practice for OpenBMC testing is to add a Tag with the test case name 28 | to the test case. That allows tests to be skipped for various reasons 29 | 3. Robot is designed to be very readable. Assigning variables in the test 30 | case can make it ugly or code like. Try to avoid it when you can. Use a 31 | python file when you need to code 32 | 33 | 34 | ``` 35 | *** Settings *** 36 | Resource ../lib/rest_client.robot 37 | Resource ../lib/resource.txt 38 | Library Collections 39 | 40 | *** Variables *** 41 | ${URI}= /xyz/openbmc_project/tutorial/hellomethod 42 | 43 | 44 | *** Test Cases *** 45 | 46 | Check if hellomethod exists 47 | [Documentation] Test REST session log-in. 48 | [Tags] check_if_hellomethod_exists 49 | 50 | Initialize OpenBMC 51 | ${resp}= Get Request openbmc ${URI} 52 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} 53 | 54 | 55 | Post a message to commit 56 | [Tags] Post_a_message_to_commit 57 | 58 | @{count_list}= Create List ${2} Hi there from robot 59 | ${data}= create dictionary data=@{count_list} 60 | 61 | ${resp}= openbmc post request ${URI}/action/commit data=${data} 62 | should be equal as strings ${resp.status_code} ${HTTP_OK} 63 | ``` 64 | 65 | Put that file in to the tests dir 66 | 67 | ``` 68 | $ git clone https://github.com/openbmc/openbmc-test-automation 69 | $ cd openbmc-test-automation 70 | $ cp /openbmc-test-automation/tests/test_hellomethod.robot tests 71 | $ export OPENBMC_HOST=localhost 72 | $ export SSH_PORT=2222 73 | $ export HTTPS_PORT=2443 74 | $ tox -e qemu -- tests/test_hellomethod.robot 75 | ``` 76 | 77 | If your test is successful you should see something like this... 78 | 79 | ``` 80 | ============================================================================== 81 | Test Telemetry 82 | ============================================================================== 83 | Check if hellomethod exists :: Test REST session log-in. | PASS | 84 | ------------------------------------------------------------------------------ 85 | Post a message to commit ..URI:https://localhost:2443/xyz/openbmc_project/tutorial/hellomethod/action/commit, method:Post, args:{u'data': {u'data': [2, u'Hi there from robot']}, u'headers': {u'Content-Type': u'application/json'}} 86 | Response code:200, Content:{ 87 | "data": null, 88 | "message": "200 OK", 89 | "status": "ok" 90 | } 91 | Post a message to commit | PASS | 92 | ------------------------------------------------------------------------------ 93 | Test Telemetry | PASS | 94 | 2 critical tests, 2 passed, 0 failed 95 | 2 tests total, 2 passed, 0 failed 96 | ============================================================================== 97 | Output: /home/causten/gitrepo/openbmc-test-automation/output.xml 98 | Log: /home/causten/gitrepo/openbmc-test-automation/log.html 99 | Report: /home/causten/gitrepo/openbmc-test-automation/report.html 100 | ________________________________________________ summary _________________________________________________ 101 | qemu: commands succeeded 102 | congratulations :) 103 | ``` 104 | 105 | Look at the report.html that comes out. Nice! 106 | 107 | 108 | ## Extra Information 109 | Writing test cases that can survive rewrites of programs and multiple systems is 110 | a challenge. Too often I've seen tests cause CI failures instead of finding 111 | CI failures. There is a good [tutorial](https://github.com/robotframework/HowToWriteGoodTestCases/blob/master/HowToWriteGoodTestCases.rst) 112 | on best practices. 113 | 114 | ## Extra Credit 115 | Add some bad paths and verify the HTTP responses are correct. Add a call to 116 | collect FFDC when a test case fails. Skip a test using the 117 | [skip_test](https://github.com/openbmc/openbmc-test-automation/blob/master/test_lists/skip_test_palmetto) 118 | concept. -------------------------------------------------------------------------------- /lessonsdk101.md: -------------------------------------------------------------------------------- 1 | # Hello World ARM style 2 | 3 | In all likelyhood you are running on a PPC64 or x86 system. OpenBMC typically 4 | runs on an ARM chip so welcome to the world of cross compiling. To start, 5 | write yourself a hello world program like this 6 | 7 | ``` 8 | #include 9 | 10 | int main() 11 | { 12 | std::cout << "Hello World!"; 13 | return 0; 14 | } 15 | 16 | ``` 17 | 18 | And then run `g++ hello.cpp; ./a.out` it will work. That is because you compiled 19 | it for the system you are running on. Instead let's compile it for ARM and use 20 | the bindings OpenBMC provides 21 | 22 | ## Build the SDK 23 | If you haven't built OpenBMC yet follow Follow the [guide](https://github.com/openbmc/openbmc#setting-up-your-openbmc-project) 24 | but replace the `bitbake obmc-phosphor-image` with `bitbake -c populate_sdk obmc-phosphor-image`. 25 | If you where planning to use QEMU you can target the machine `palmetto`. 26 | 27 | Now follow the cheatsheet guide for [Building the SDK](https://github.com/openbmc/docs/blob/master/cheatsheet.md#building-the-openbmc-sdk) 28 | The literal text may have changed like `2.1` or `armv5`. Just follow the idea 29 | and you will get there. 30 | 31 | 32 | Now run g++ in your cross compiled environment. Then copy the file on to your 33 | OpenBMC system. Your program should now print on the BMC. 34 | 35 | 36 | ## Extra Credit 37 | You don't have to cross compile. You can target the SDK for your native system. 38 | Doing so can be useful if your OS is running dbus because you then get to interact 39 | with it instead. -------------------------------------------------------------------------------- /lessonsim101.md: -------------------------------------------------------------------------------- 1 | # Build the Simulator 2 | 3 | The Cheatsheet already shows how to build the simulator so follow the [guide](https://github.com/openbmc/docs/blob/master/cheatsheet.md#building-qemu). 4 | 5 | Once the code has been built follow the [Using QEMU](https://github.com/openbmc/docs/blob/master/cheatsheet.md#using-qemu) 6 | portion of the guide. There is a point in the instructions where you need to 7 | satisfy the `/flash-palmetto` path. Head over to the 8 | [build server](https://openpower.xyz/job/openbmc-build/distro=ubuntu,target=palmetto/lastSuccessfulBuild/artifact/images/palmetto/flash-palmetto) 9 | and just use that one for now. 10 | 11 | If you followed the instructions correctly you should reach the login prompt. 12 | 13 | Login `root/0penBmc` 14 | 15 | 16 | You are Done! 17 | 18 | 19 | ## Extra credit 20 | 21 | The cheatsheet shows how to port forward the https and ssl ports. There is 22 | another port that some developers like to use to see what is exposed on the 23 | REST / Dbus. On real hardware it would be port 3000. Try to forward it and 24 | point your web browser there. 25 | -------------------------------------------------------------------------------- /lessonwatch.md: -------------------------------------------------------------------------------- 1 | # Watch the dbus 2 | DBus is IPC. So lets do some. In this tutorial; using C++ and autotools, you 3 | will write a program that will watch for dbus signals. 4 | 5 | Make sure you have setup the SDK first. The build files for this tutorial are 6 | located [here](watcher) 7 | 8 | ``` 9 | . /opt/openbmc-phosphor/2.2/environment-setup-armv5e-openbmc-linux-gnueabi 10 | ./bootstrap.sh 11 | ./configure ${CONFIGURE_FLAGS} 12 | make 13 | ``` 14 | 15 | Copy the watcher program on to the target OpenBMC system, then run... 16 | 17 | ``` 18 | watcher& 19 | dbus-send --system --type=signal / org.openbmc.Sensor array:string:"parm1","neat" 20 | ``` 21 | 22 | Expect to see 23 | 24 | ``` 25 | Message Signature: as 26 | parm1 27 | neat 28 | ``` 29 | 30 | 31 | ## Extra information 32 | Notice the `Message Signature: as` that indicated the signal has a buffer of data, 33 | and the data is an array of strings. In addition to the buffer that we sent, 34 | events over dbus come with other details too. The built in tools such as 35 | busctl, dbus-send and dbus-monitor are very useful 36 | 37 | You can run `dbus-monitor --system' to see all the dbus events but quickly you 38 | will realize things get noisy. Introducing filters... 39 | 40 | ``` 41 | dbus-monitor --system "type='signal', member='Sensor'" 42 | ``` 43 | 44 | Dbus examples and developers guides are not as popular as cat videos so share 45 | when you find one that is [helpful](https://dbus.freedesktop.org/doc/dbus-send.1.html). 46 | 47 | 48 | ## Extra Credit 49 | The `Message Signature` indicates the type of data in the signals buffer. Can 50 | you make the signature 'asi' ? Can you change the code to parse the `i`? 51 | 52 | -------------------------------------------------------------------------------- /openbmc-test-automation/tests/test_hellomethod.robot: -------------------------------------------------------------------------------- 1 | *** Settings *** 2 | Resource ../lib/rest_client.robot 3 | Resource ../lib/resource.txt 4 | Library Collections 5 | 6 | *** Variables *** 7 | ${URI}= /xyz/openbmc_project/tutorial/hellomethod 8 | 9 | 10 | *** Test Cases *** 11 | 12 | Check if hellomethod exists 13 | [Documentation] Test REST session log-in. 14 | [Tags] check_if_hellomethod_exists 15 | 16 | Initialize OpenBMC 17 | ${resp}= Get Request openbmc ${URI} 18 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} 19 | 20 | 21 | Post a message to commit 22 | [Tags] Post_a_message_to_commit 23 | 24 | @{count_list}= Create List ${2} Hi there from robot 25 | ${data}= create dictionary data=@{count_list} 26 | 27 | ${resp}= openbmc post request ${URI}/action/commit data=${data} 28 | should be equal as strings ${resp.status_code} ${HTTP_OK} 29 | 30 | -------------------------------------------------------------------------------- /watcher/LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /watcher/Makefile.am: -------------------------------------------------------------------------------- 1 | sbin_PROGRAMS = buswatcher 2 | 3 | buswatcher_SOURCES = main.cpp 4 | 5 | 6 | buswatcher_LDFLAGS = $(SYSTEMD_LIBS) $(SDBUSPLUS_LIBS) \ 7 | $(PHOSPHOR_DBUS_INTERFACES_LIBS) 8 | buswatcher_CFLAGS = $(SYSTEMD_CFLAGS) $(SDBUSPLUS_CFLAGS) \ 9 | $(PHOSPHOR_DBUS_INTERFACES_CFLAGS) -------------------------------------------------------------------------------- /watcher/README.md: -------------------------------------------------------------------------------- 1 | To build this package, do the following steps: 2 | 3 | 1. ./bootstrap.sh 4 | 2. ./configure ${CONFIGURE_FLAGS} 5 | 3. make 6 | 7 | To full clean the repository again run `./bootstrap.sh clean`. 8 | -------------------------------------------------------------------------------- /watcher/bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | AUTOCONF_FILES="Makefile.in aclocal.m4 ar-lib autom4te.cache compile \ 4 | config.guess config.h.in config.sub configure depcomp install-sh \ 5 | ltmain.sh missing *libtool test-driver" 6 | 7 | case $1 in 8 | clean) 9 | test -f Makefile && make maintainer-clean 10 | for file in ${AUTOCONF_FILES}; do 11 | find -name "$file" | xargs -r rm -rf 12 | done 13 | exit 0 14 | ;; 15 | esac 16 | 17 | autoreconf -i 18 | echo 'Run "./configure ${CONFIGURE_FLAGS} && make"' -------------------------------------------------------------------------------- /watcher/configure.ac: -------------------------------------------------------------------------------- 1 | # Initialization 2 | AC_PREREQ([2.69]) 3 | AC_INIT([buswatcher],[1.0],[https://github.com/causten/openbmc-tutorials/issues]) 4 | AC_CONFIG_SRCDIR([main.cpp]) 5 | AC_CONFIG_HEADERS([config.h]) 6 | AM_INIT_AUTOMAKE([subdir-objects -Wall -Werror foreign dist-xz]) 7 | AM_SILENT_RULES([yes]) 8 | 9 | 10 | # Checks for programs. 11 | AC_PROG_CXX 12 | AM_PROG_AR 13 | 14 | # Check for libraries 15 | PKG_CHECK_MODULES([SYSTEMD], [libsystemd >= 221]) 16 | PKG_CHECK_MODULES([PHOSPHOR_DBUS_INTERFACES], [phosphor-dbus-interfaces],, \ 17 | AC_MSG_ERROR(["Requires phosphor-dbus-interfaces package."])) 18 | PKG_CHECK_MODULES([SDBUSPLUS], [sdbusplus],, \ 19 | AC_MSG_ERROR(["Requires sdbusplus package."])) 20 | 21 | 22 | 23 | LT_INIT 24 | 25 | # Checks for typedefs, structures, and compiler characteristics. 26 | AX_CXX_COMPILE_STDCXX_14([noext]) 27 | AX_APPEND_COMPILE_FLAGS([-Wall -Werror], [CFLAGS]) 28 | AX_APPEND_COMPILE_FLAGS([-Wall -Werror], [CXXFLAGS]) 29 | 30 | # Create configured output 31 | AC_CONFIG_FILES([Makefile]) 32 | AC_OUTPUT -------------------------------------------------------------------------------- /watcher/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | 6 | static int caughtSignal(sd_bus_message* msg, 7 | void* userData, 8 | sd_bus_error* retError) 9 | { 10 | auto sdPlusMsg = sdbusplus::message::message(msg); 11 | 12 | fprintf(stderr, "Message Signature: %s\n", sdPlusMsg.get_signature()); 13 | 14 | 15 | std::vector result; 16 | sdPlusMsg.read(result); 17 | 18 | for (const auto& i : result) { 19 | fprintf(stderr, "%s\n", i.c_str()); 20 | } 21 | 22 | 23 | return 0; 24 | } 25 | 26 | bool cmdDone = false; 27 | 28 | int main(int argc, char *argv[]) 29 | { 30 | 31 | auto bus = sdbusplus::bus::new_default(); 32 | 33 | // Monitor for a specific signal 34 | auto s = "type='signal',interface='org.openbmc',member='Sensor'"; 35 | 36 | // Setup Signal Handler 37 | sdbusplus::bus::match::match caughtSignals(bus, 38 | s, 39 | caughtSignal, 40 | nullptr); 41 | 42 | // Wait for signal 43 | while(!cmdDone) 44 | { 45 | bus.process_discard(); 46 | if (cmdDone) break; 47 | bus.wait(); 48 | } 49 | 50 | 51 | return 0; 52 | } --------------------------------------------------------------------------------