1
头图

Shifu is an open source IoT development and management platform independently developed by Edgenesis. Developers can easily connect, monitor and control any IoT device through Shifu.

Shifu officially launched on the GitHub platform, released the first version of technical documents, and started internal testing.

We warmly welcome innovative software engineers and developers who are interested in exploring IoT business scenarios to join us and jointly build a developer ecosystem in the IoT era.

Technical document address (copy link to view)
https://cn.docs.edgenesis.io/

GitHub address (join the community to view the code)
https://github.com/Edgenesis/shifu

Shifu technical documentation directory:

// welcome

// Shifu basic structure

// Quick start: install

// Quick start: DeviceShifu

// Quick start: connect to a PLC

// Quick start: add a new driver

welcome

Shifu (github page: https://github.com/Edgenesis/shifu ) is an open source IoT development and management platform based on Kubernetes. Using Shifu, developers can more easily connect, monitor and control any IoT device.

IoT devices

An IoT device is one that can connect and communicate online or locally with other devices, systems, and services, such as:

  • A robotic arm in a manufacturing plant that receives commands from a local automation control system to perform various actions.
  • An automated guided vehicle, which is remotely controlled by its operator.
  • A thermometer on a car that commands the air conditioner to heat up or cool down, while also sending temperature data to the cloud.

communication

Shifu is compatible with different communication protocols and drivers. It unifies different forms of requests from different devices and opens it to users in the form of HTTP, so that users can use the functions of the device more easily.

The relationship between Shifu and users and devices can be represented by the following diagram:

image.png

Communication between Shifu and devices: Shifu is constantly adding compatibility with new protocols and drivers. For a current list of compatibility, see Current Compatible Device Protocols and Drivers.

Currently, Shifu supports the following protocols to interact with devices:

1. HTTP

2. MQTT

3. RTSP for streaming

4. Siemens S7

5.TCP socket

Communication between Shifu and users: Shifu is constantly adding new protocols for users to choose from. For a list of currently available protocols, see Protocols Available to Current User.

Currently, Shifu supports users to communicate using the following protocols:

1. HTTP

Function

As an IoT device management and development platform, Shifu provides the following functions: Get data from devices.

Shifu Basic Architecture

Shifu is a Kubernetes-native platform with all its components running as Pods.

The following figure is an overview of the Shifu architecture:

image.png

EdgeDevice

Shifu defines a CRD EdgeDevice, which describes various pieces of information about an actual device connected to Shifu.

Each EdgeDevice has two parts: EdgeDeviceSpec and EdgeDeviceStatus.

EdgeDeviceSpec contains the basic information of the device.

It has four elements:

image.png

EdgeDevicePhase defines the current state of the device:

image.png

DeviceShifu

EdgeDevice defines a Kubernetes Pod named DeviceShifu. DeviceShifu is a digital representation, or digital twin, of an actual device.

Each DeviceShifu is associated with an actual device. By interacting with DeviceShifu, the user can interact with the actual device.

Southbound - DeviceShifu receives the user's request, converts the request and sends it to the device.

Northbound - DeviceShifu collects device data, converts it, and sends it to the client.

Shifu Utils

Shifu continues to add new tools and services to ensure compatibility of different protocols and drivers.

MQTT Broker

MQTT Broker is used to facilitate the subscription and publication of MQTT messages. Currently, Shifu uses Mosquitto for compatibility.

RTSP Client

RTSP Client ensures the transmission of streaming media information.

Siemens S7 Suite

Siemens S7 Suite supports the operation of Siemens S7 series PLC. Currently, Shifu uses Snap7 for compatibility.

HTTP to SSH driver stub

The HTTP to SSH driver stub enables Shifu to allow users to add new command line drivers at will.

Get started quickly

dependencies

Shifu requires the following dependencies:

Golang: Golang is Shifu's development language.

Docker: Shifu's services exist in the form of Docker images.

kind: Kind is used to run a local Kubernetes cluster as Docker.

kubectl: Operations tool for Kubernetes.

kubebuilder: Kubebuilder is used to install CRDs.

Shifu requires a kubernetes cluster to start. Use kind to do a quick build:

image.png

Once the cluster is created, we can quickly start using Shifu.

Quick configuration

Shifu provides the shifu_install.yml file, which can be used for quick installation:

image.png

step by step

You can also install it as follows:

image.png

After installing Shifu successfully, you can access the new device.

Get started with DeviceShifu quickly

This article will use a simple "helloworld" virtual device example to show how to access the device to Shifu, generate DeviceShifu, and operate it.

Helloworld device

The Helloworld device has only one function: every time a request is received, it returns a "hello world" message.

step

1. Prepare the virtual device

The virtual device to be created this time is a software application. Every time it receives an HTTP GET request, it will return the message "Hello_world from device via shifu!". In addition, we will use Shifu's data collection feature to automatically collect this information every second.

In the development path, create a helloworld.go file with the following content:

image.png

Generate the go.mod file:

image.png

Add Dockerfile:

image.png

Create an image

image.png

2. Prepare EdgeDevice:

Basic information of EdgeDevice: Assuming all configuration files are saved in /helloworld-device/configuration

Deployment configuration:
helloworld-deployment.yaml

image.png

Hardware and Connection Information:
helloworld-edgedevice.yaml

image.png

Service:
helloworld-service.yaml

image.png

3. Prepare DeviceShifu

Using the configuration file below, Shifu will automatically generate DeviceShifu Pods. Assume all configuration files are saved in /helloworld-device/configuration.

ConfigMap:
deviceshifu-helloworld-configmap.yaml

image.png

Deployment:
deviceshifu-helloworld-deployment.yaml

image.png

Service:
deviceshifu-helloworld-service.yaml

image.png

4. Create DeviceShifu

The following steps all require that the Shifu platform is up and running

1. Load the docker image you just built

image.png

2. Let Shifu create a DeviceShifu Pod through configuration

image.png

3. Start an nginx server

image.png

Now use kubectl to view the Pods:

image.png

The cluster should have the following Pods:

image.png

View the created EdgeDevice:

image.png

The detailed information and status of DeviceShifu can be obtained through the describe command:

image.png

4. Using nginx:

image.png

5. Interact with DeviceShifu:

You should get the following output:

image.png

6. View the collected data in the log:

image.png

Now that the helloworld device has been fully integrated into the Shifu framework, it can interact with it through DeviceShifu in the way described above.

If you need to update the configuration, please delete and then apply configurtaion:

image.png

Quickly get started and connect to a PLC

Shifu provides compatibility with Siemens S7 series PLC. Users can use Shifu to modify the memory of the S7 PLC through HTTP requests. This article will introduce how to access a Siemens S7-1200 1214C PLC and interact with it.

connect

Before connecting to Shifu, the PLC should already be physically connected via Ethernet and have an IP address. Here we use 192.168.0.1.

Shifu needs the configuration file shown in the following example to get the IP address and device type: plc-deployment.yaml

image.png

At the same time, Shifu also needs some common configuration files: deviceshifu-plc-configmap.yaml

image.png

deviceshifu-plc-deployment.yaml

image.png

deshifu-plc-service.yaml

image.png

plc-edgedevice.yaml

image.png

plc-service.yaml

image.png

Add PLC device to Shifu, create and start DeviceShifu:

image.png

operate

Shifu supports editing PLC memory via HTTP requests.

sendsinglebit:

To modify a bit, it requires the following parameters:

rootaddress: memory area name, such as M for Merker, Q for Digital Output.

address: The address in the memory area.

start: start position.

digit: The number of bits from the start position.

value: The value that needs to be modified.

For example, plc-device/sendsinglebit?rootaddress=M&address=0&start=2&digit=2&value=1 will change the second bit of M0.2 to 1.

getcontent:

Get the value of a byte in the memory area, which requires the following parameters:

rootaddress: memory area name, such as M for Merker, Q for Digital Output.

address: The address in the memory area.

start: start position.

For example, plc-device/sendsinglebit?rootaddress=M&address=0&start=2 will return a byte value of M0.2.

getcpuordercode:

Get the static information of PLC.

Quick start adding new drivers

If the device communicates by directly calling the executable file in the driver through the command line, Shifu supports direct access to it, so that the device using this type of driver can be remotely operated.

HTTP to SSH driver stub

The function of this component is to convert received HTTP requests into commands to drive executable files and execute them remotely.

configure

First, we need to package the driver with the executable into a Docker container image.

In the Deployment configuration, Shifu requires the following four elements:

EDGEDEVICE_DRIVER_SSH_KEY_PATH: The path of the SSH key that Shifu needs to access the driver container.

EDGEDEVICE_DRIVER_HTTP_PORT (optional): The HTTP server port of the driver container, the default value is 11112.

EDGEDEVICE_DRIVER_EXEC_TIMEOUT_SECOND (optional): The timeout setting for an operation.

EDGEDEVICE_DRIVER_SSH_USER (optional): The user to connect to the driver container via SSH, defaults to root.

Here is a simple example:

image.png


亚马逊云开发者
2.9k 声望9.6k 粉丝

亚马逊云开发者社区是面向开发者交流与互动的平台。在这里,你可以分享和获取有关云计算、人工智能、IoT、区块链等相关技术和前沿知识,也可以与同行或爱好者们交流探讨,共同成长。