From 312c488fb84526daf71d32e39523a348c9c1aa22 Mon Sep 17 00:00:00 2001
From: Stefan Schmidt <stefan.schmidt@huawei.com>
Date: Mon, 29 Aug 2022 19:57:18 +0200
Subject: [PATCH] modbus-testing_git.bb: Add initial recipe for libmodbus
 examples

The libmodbus project does not offer examples of library usage in their
distribution. To make the life easier for Oniro integrators and
developers we provide a basic set of examples to get a head-start when
developing an application using libmodbus.

The scope for these examples is Oniro, so the recipe here is not
targeted at staging (I have no plans to upstream this), but at the
meta-oniro-core layer.

Signed-off-by: Stefan Schmidt <stefan.schmidt@huawei.com>
---
 .../modbus/modbus-testing_git.bb              | 29 +++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 meta-oniro-core/recipes-connectivity/modbus/modbus-testing_git.bb

diff --git a/meta-oniro-core/recipes-connectivity/modbus/modbus-testing_git.bb b/meta-oniro-core/recipes-connectivity/modbus/modbus-testing_git.bb
new file mode 100644
index 00000000..7f2d8d96
--- /dev/null
+++ b/meta-oniro-core/recipes-connectivity/modbus/modbus-testing_git.bb
@@ -0,0 +1,29 @@
+# SPDX-FileCopyrightText: Huawei Inc.
+#
+# SPDX-License-Identifier: Apache-2.0
+
+SUMMARY = "Libmodbus testing examples"
+SECTION = "net"
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=ef3dabb8f39493f4ea410bebc1d01755 \
+                    "
+DEPENDS = "libmodbus"
+SRCREV = "60f05a6339bff50410b3096a05d36496c67c91b0"
+PV = "0.0+git${SRCPV}"
+
+SRC_URI = "git://gitlab.eclipse.org/stefanschmidt/modbus-testing.git;protocol=https;branch=main"
+
+S = "${WORKDIR}/git"
+
+inherit pkgconfig
+
+do_compile() {
+    $CC modbus-server.c -o modbus-server $(pkg-config --libs --cflags libmodbus) ${CFLAGS} ${LDFLAGS}
+    $CC modbus-client.c -o modbus-client $(pkg-config --libs --cflags libmodbus) ${CFLAGS} ${LDFLAGS}
+}
+
+do_install() {
+    install -d ${D}${sbindir}/
+    install -m 0755 ${S}/modbus-server ${D}${sbindir}/
+    install -m 0755 ${S}/modbus-client ${D}${sbindir}/
+}
-- 
GitLab