本地构建和自动化构建_如何构建最强大,最安全的家庭自动化系统

本地构建和自动化构建

by Amir Off

由Amir Off

如何构建最强大,最安全的家庭自动化系统 (How to build the most robust and secure home automation system)

In this article, I’ll discuss how I built a Smart Home Automation System with Angular and Node.js on a Raspberry Pi without relying on any external cloud services.

在本文中,我将讨论如何在Raspberry Pi上不依赖任何外部云服务的情况下,使用Angular和Node.js构建智能家居自动化系统。

介绍 (Intro)

Over the last few days, I spent some nights designing and developing a home automation system based on JavaScript, with the use of Angular and Node.js. And, like with any other project, the planning involved some deep research on the internet.

在过去的几天里,我花了一些晚上使用Angular和Node.js设计和开发基于JavaScript的家庭自动化系统。 并且,与任何其他项目一样,该计划涉及对互联网的一些深入研究。

It turned out that there are plenty of fish in the sea —plenty of solutions on how to implement a home automation system. Some offer paid services in “the cloud” and others explain how to build your own using a technology called MQTT.

事实证明,海中有很多鱼-有关如何实施家庭自动化系统的大量解决方案。 一些提供“云”中的付费服务,另一些解释如何使用称为MQTT的技术构建自己的服务。

None of the solutions made any sense to me. All options were either expensive, or had inconvenient implementations or even security flaws.

没有一种解决方案对我有意义。 所有选项要么昂贵,要么实现不便,甚至存在安全漏洞。

But, before we go any further, let’s explain what MQTT is. MQTT stands for MQ Telemetry Transport. It is a publish/subscribe, extremely simple and lightweight messaging protocol. MQTT is designed for constrained devices and low-bandwidth, high-latency, or unreliable networks.

但是,在进一步介绍之前,让我们解释一下MQTT是什么。 MQTT代表MQ遥测传输 。 它是一种发布/订阅,极其简单和轻便的消息传递协议。 MQTT专为受限设备和低带宽,高延迟或不可靠的网络而设计。

The design principles are to minimise network bandwidth and device resource requirements whilst attempting to ensure reliability and some degree of assurance of delivery. These principles also turn out to make the protocol ideal for the emerging “machine-to-machine” (M2M) or “Internet of Things” world of connected devices, and for mobile applications where bandwidth and battery power are at a premium.

设计原则是在尝试确保可靠性和一定程度的交付保证的同时,最小化网络带宽和设备资源要求。 这些原则也使该协议成为新兴的连接设备的“机器对机器”(M2M)或“物联网”世界以及带宽和电池电量极为宝贵的移动应用的理想选择 。

Why wasn’t I convinced about using MQTT, or by any of the solutions I found on the internet? Two reasons:

为什么我对使用MQTT或我在互联网上找到的任何解决方案都不满意? 两个原因:

  1. While the MQTT technology seems very convenient for IoT devices, I still thought it was unnecessary. The system which I will be showing in the following tutorial operates in the same medium where the IoT devices live. All benefits that MQTT has for being “fast” and having “low-bandwidth” become irrelevant. Plus there’s all the hassle that is involved in its implementation and all the extra overhead with the additional npm packages that are required for it to work in a JavaScript environment. Instead, I will be using generic JavaScript and Node.js libraries only, nothing more!

    尽管MQTT技术对于物联网设备非常方便,但我仍然认为这是不必要的。 我将在以下教程中显示的系统在IoT设备所在的相同介质上运行。 MQTT所具有的“快速”和“低带宽”的所有优点变得无关紧要。 另外,它的实现还涉及所有麻烦,并且在JavaScript环境中运行它需要额外的npm软件包带来的所有额外开销。 相反,我将仅使用通用JavaScript和Node.js库,仅此而已!
  2. What about the security part? Well, I’m not a big fan of “the cloud” or cloud computing in general. In some cases it can be very beneficial, but in most cases it’s just unnecessary. Think about it: why would you have a service that is required for controlling your home appliances to be hosted somewhere else in “the cloud” and not in your own network?

    安全部分呢? 好吧,我一般都不喜欢“云”或云计算。 在某些情况下,这可能是非常有益的,但在大多数情况下,这是不必要的。 想一想:为什么您需要一项服务,以控制您的家用电器托管在“云”中而不是您自己的网络中?

One might think that “the cloud” provides the ability to access your home appliances from anywhere in the world via the internet.

可能有人认为“云”提供了通过互联网从世界任何地方访问您的家用电器的能力。

But think about this: when your home network doesn’t have internet connection, “the cloud” becomes redundant. More importantly, you can still make your home automation system accessible from the internet using port-forwarding even if it’s hosted on your local network.

但是请考虑一下:当您的家庭网络没有Internet连接时,“云”将变得多余。 更重要的是,即使端口托管在本地网络上,您仍然可以使用端口转发从互联网访问家庭自动化系统。

This is when it “clicked” for me, and I thought about hosting the whole system on a Raspberry Pi and keeping it in my local network.

这是当它为我“点击”时,我考虑过将整个系统托管在Raspberry Pi上,并将其保留在我的本地网络中。

技术 (The technology)

  1. Software: The reason why I chose Angular and Node.js is because they’re based on JavaScript and I’m already familiar with it. After all, I wanted to design and develop a progressive web app that communicates with my IoT devices via HTTP — and JavaScript offered all the functionality that I needed.

    软件:之所以选择Angular和Node.js是因为它们基于JavaScript,并且我已经很熟悉。 毕竟,我想设计和开发一个渐进式Web应用程序,该应用程序可通过HTTP与我的IoT设备进行通信-JavaScript提供了我需要的所有功能。

  2. Hardware: The system works with microcontrollers like the Arduino Uno/Mega/Du/MKR1000, Adafruit HUZZAH CC3000, and any other microcontroller with a WiFi connection. I am using the ESP8266 as a base component for my home automation system. It’s a low-cost WiFi microchip with microcontroller capability. It has everything I need and for a cheap price! Lastly, we need to host the system somewhere on our local network — so what’s better than the Raspberry Pi?

    硬件:该系统可与Arduino Uno / Mega / Du / MKR1000,Adafruit HUZZAH CC3000和任何其他具有WiFi连接的微控制器一起使用。 我将ESP8266用作家庭自动化系统的基本组件。 这是一款具有微控制器功能的低成本WiFi微芯片。 它具有我需要的一切,而且价格便宜! 最后,我们需要将系统托管在本地网络上的某个地方–那么有什么比Raspberry Pi更好的呢?

This won’t be a coding tutorial where I dive deep into coding, since this project is open-source and I will be publishing everything on GitHub. I will only demonstrate how to implement your own home automation system and will be going through each step. If you’re a developer please fork the repository and get involved in improving it.

这不是我将深入研究编码的编码教程,因为该项目是开源的,我将在GitHub上发布所有内容。 我将仅演示如何实现自己的家庭自动化系统,并将逐步进行每个步骤。 如果您是开发人员,请分叉存储库并参与改进。

设置 (The setup)

I estimate that it will take about 40 minutes to finish this whole setup plus any time spent online searching for solutions for installation errors.

我估计大约需要40分钟才能完成整个安装过程,并且花费任何时间在线搜索安装错误的解决方案。

需要什么? (What is needed?)

A Raspberry Pi is required. In my example I’m using a Raspberry Pi 3, but it should work with most versions. The components needed are:

需要Raspberry Pi。 在我的示例中,我使用的是Raspberry Pi 3,但它适用于大多数版本。 所需的组件是:

  1. Raspberry Pi board

    树莓派板
  2. MicroSD card (A class 10 with 16 GB or higher is recommended)

    MicroSD卡(建议使用16 GB或更高的Class 10)
  3. A USB MicroSD card reader or SD card adapter

    USB MicroSD读卡器或SD卡适配器
  4. HDMI monitor and a USB keyboard (only required temporarily for the first boot of the Raspberry Pi)

    HDMI监视器和USB键盘(仅在Raspberry Pi首次启动时临时需要)
  5. Ethernet cable (not needed for Raspberry Pi 3 as it has built in WiFi)

    以太网电缆(Raspberry Pi 3内置WiFi不需要)

在Raspberry Pi上安装Raspbian OS (Installing Raspbian OS on the Raspberry Pi)

Raspbian is a free operating system based on Debian Linux, and it is optimized for Raspberry Pi.

Raspbian是基于Debian Linux的免费操作系统,并且已针对Raspberry Pi进行了优化。

I recommend the headless “LITE” version. It has no desktop environment or any graphical user interface, and it’s remotely accessible from a computer or device on the same network via SSH. We’re keeping things simple since this is the only way we are going to access the Raspberry Pi. The LITE version has all the functionality we’re looking for.

我推荐无头“ LITE”版本。 它没有桌面环境或任何图形用户界面,并且可以通过SSH从同一网络上的计算机或设备进行远程访问。 我们将事情保持简单,因为这是我们访问Raspberry Pi的唯一方法。 LITE版本具有我们正在寻找的所有功能。

  1. Download the latest Raspbian image from the official Raspberry Pi website.

    从Raspberry Pi官方网站下载最新的 Raspbian映像。

  2. Flash the Raspbian OS image to the SD card with Etcher or any other OS image burning software of your choice.

    使用Etcher或您选择的任何其他OS映像刻录软件将Raspbian OS映像闪存到SD卡。

设置Raspberry Pi (Setting up the Raspberry Pi)

To get the Raspberry Pi ready to boot we need to:

要使Raspberry Pi准备启动,我们需要:

  1. Insert the MicroSD card into the Raspberry Pi

    将MicroSD卡插入Raspberry Pi
  2. Connect the USB keyboard and the HDMI cable

    连接USB键盘和HDMI电缆
  3. Connect the Ethernet cable or if you have a Raspberry Pi 3 and want to use WiFi you should set up the network in the next section

    连接以太网电缆,或者如果您有Raspberry Pi 3并想使用WiFi,则应在下一部分中设置网络

When the Raspberry Pi has finished booting up, log in using username pi and password raspberry

Raspberry Pi完成启动后,使用用户名pi和密码raspberry登录

启用WiFi并连接到网络 (Enabling WiFi and connecting to the network)

Skip this step if you chose to connect with an Ethernet cable.

如果您选择使用以太网电缆连接,请跳过此步骤

  1. Open the “wpa-supplicant” configuration file

    打开“ wpa-supplicant”配置文件
$ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

2. add the following at the bottom of the file while adding your wifi name and password:

2.在文件底部添加以下内容,同时添加您的wifi名称和密码:

network={
ssid="your_networks_name"   psk="your_networks_password"
}

3. Press Ctrl+X to save the code. Confirm with Y then Enter

3.Ctrl+X保存代码。 确认与Y然后Enter

4. Reboot the Raspberry Pi with the following command:

4.使用以下命令重新启动Raspberry Pi:

$ sudo reboot

启用S​​SH并更改用户名和密码 (Enabling SSH and changing the username and password)

Now that the Raspberry Pi is connected to the internet, it’s recommended to change the default password.

现在Raspberry Pi已连接到Internet,建议更改默认密码。

  1. Open the Raspberry Pi configuration tool and click the second option “Change User Password” and follow the instructions

    打开Raspberry Pi配置工具,然后单击第二个选项“更改用户密码”,然后按照说明进行操作
$ sudo raspi-config

2. Select option 5 “Interfacing Options” then activate SSH

2.选择选项5“接口选项”,然后激活SSH

3. Reboot the Raspberry Pi. When it’s up, you have SSH enabled and it’s ready to be accessed remotely from your desktop computer

3.重新启动Raspberry Pi。 启动时,您已启用SSH,并且可以从台式计算机远程访问它

$ sudo reboot

配置对Raspberry Pi的远程访问 (Configuring remote access to the Raspberry Pi)

Now, finally, the part when we install the required software on the Raspberry Pi. This part can be executed directly on the Pi through the terminal using a HDMI monitor and a USB keyboard. For convenience — and since we enable remote SSH connection — we’re going to connect from another desktop environment. This is the best and easiest way to remotely access and control the Pi whenever changes and configurations are needed.

现在,最后是我们在Raspberry Pi上安装所需软件的部分。 这部分可以使用HDMI监视器和USB键盘通过终端直接在Pi上执行。 为了方便起见,并且由于我们启用了远程SSH连接,因此我们将从另一个桌面环境进行连接。 每当需要更改和配置时,这是远程访问和控制Pi的最佳和最简便的方法。

So, basically, this is how you can access the command line interface of a Raspberry Pi remotely from another computer or any device on the same network using SSH. This can be done in two ways:

因此,基本上,这就是您可以使用SSH从另一台计算机或同一网络上的任何设备远程访问Raspberry Pi的命令行界面的方法。 这可以通过两种方式完成:

  1. Using the Command Prompt or PowerShell (I’m using Windows on a Desktop computer), replace with your username and IP address

    使用命令提示符或PowerShell(我在台式计算机上使用Windows),替换为您的用户名和IP地址
$ ssh username@ipaddress

If you do not know the IP address, type “hostname -I" in the Raspberry Pi command line.

如果您不知道 IP地址,请在Raspberry Pi命令行中键入“ hostname -I"

2. The second method is using a client program like PuTTY or any other functioning client SSH software. Here’s an easy guide for using PuTTY.

2.第二种方法是使用客户端程序,例如PuTTY或任何其他程序 客户端SSH软件。 这是使用PuTTY的简单指南

在Raspberry Pi上安装所需的软件 (Installing the required software on the Raspberry Pi)

Before installing anything, it’s recommended to update the Raspberry Pi’s operating system and packages. Doing this regularly will keep it up-to-date.

在安装任何东西之前,建议先更新Raspberry Pi的操作系统和软件包。 定期执行此操作可以使它保持最新状态。

  1. Update the system packages list using the following command:

    使用以下命令更新系统软件包列表:
$ sudo apt-get update

2. Upgrade all your installed packages to their latest version:

2.将所有已安装的软件包升级到最新版本:

$ sudo apt-get dist-upgrade

3. Download and install the latest version of Node.js:

3.下载并安装最新版本的Node.js:

// To download$ curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
// To install$ sudo apt-get install -y nodejs
// Check if the installation was successful:$ node -v

4. Install the Angular CLI globally:

4.全局安装Angular CLI:

$ npm install -g @angular/cli

5. Install the Git version-control system:

5.安装Git版本控制系统:

$ sudo apt-get install git

安装数据库(MongoDB) (Installing the database (MongoDB))

We need a database for storing the registered users and their credentials. Here are the required steps:

我们需要一个数据库来存储注册用户及其凭证。 这是必需的步骤:

  1. Install MongoDB

    安装MongoDB
$ sudo apt-get install mongodb

2. Start the MongoDB process

2.启动MongoDB进程

$ sudo service mongodb start

3. Start the mongo Shell

3.启动mongo Shell

$ mongo

3. Create a database called “smarthaus”

3.创建一个名为“ smarthaus”的数据库

$ use smarthaus

In MongoDB, default database is test. If you didn’t create any database, then collections will be stored in test database.

在MongoDB中,默认数据库为test。 如果您未创建任何数据库,则集合将存储在测试数据库中。

安装Smart Haus (Installing Smart Haus)

1. Check the current work directory using this command:

1.使用以下命令检查当前工作目录:

$ pwd
/* It will probably print "/home/pi"   where "pi" is the current user directory */

It’s recommended to clone the project’s repository under the pi’s user directory but you can navigate somewhere else if you’re sure.

建议在pi的用户目录下克隆项目的存储库,但如果确定的话,可以导航到其他地方。

2. Clone the repository from:

2.从以下位置克隆存储库:

$ git clone https://github.com/ameer157/smarthaus.git

Make sure to navigate inside the directory using:

确保使用以下内容浏览目录:

$ cd smarthaus

Before installing any npm packages using “npm install” please refer to the npm guide to fix permissions to learn how to fix any “EACCESS ”errors you might face during installation. This is very important since it will prevent any npm permission errors, and allows you to install packages globally without using sudo. Using sudo with npm is not recommended and should be avoided.

在使用“ npm install”安装任何npm软件包之前,请参考npm指南以修复权限,以了解如何解决在安装过程中可能遇到的任何“ EACCESS ”错误。 这非常重要,因为它将防止任何npm权限错误,并允许您在不使用sudo的情况下全局安装软件包。 不建议将sudo与npm一起使用, 应避免使用

3. Install all the required packages for the project:

3.安装项目所需的所有软件包:

$ npm install

启动Node.js服务器 (Starting the Node.js server)

Before starting the server we need to build the project using the Angular CLI tool. And lastly, we configure the Raspberry Pi so that it runs the server whenever it boots up.

在启动服务器之前,我们需要使用Angular CLI工具构建项目。 最后,我们配置Raspberry Pi,使其在启动时运行服务器。

  1. Build the project using:

    使用以下命令构建项目:
$ ng build --prod

2. Edit the rc.local file using nano:

2.使用nano编辑rc.local文件:

$ sudo nano /etc/rc.local

3. Add the following on the line before exit 0 then exit and save the file:

3.exit 0之前的行中添加以下内容,然后退出并保存文件:

su pi -c 'cd /home/pi/smarthaus/backend && sudo node server.js > log.txt &'

The Node.js server is now ready! It will run on every system boot up and save logs in under the same directory in a “log.txt” file.

Node.js服务器现在准备就绪! 它将在每次系统启动时运行,并将日志保存在同一目录下的“ log.txt”文件中。

Let’s run it now and see if it works using this command:

现在运行它,并使用以下命令查看它是否有效:

$ sudo node server

The system in now accessible from any device on your network via the Raspberry Pi’s IP address.

现在可以通过Raspberry Pi的IP地址从网络上的任何设备访问该系统。

Please go ahead and fork this project and get involved in developing the missing parts ?

请着手这个项目,并涉足发展中缺少的部分?

结束 (The end)

We got ourselves a working home automation system running safely on a Raspberry Pi in our local network without the use of “the cloud” or somebody else’s server.

我们获得了一个可以正常工作的家庭自动化系统,该系统可以在本地网络中的Raspberry Pi上安全运行,而无需使用“云”或其他人的服务器。

My Raspberry Pi sitting next to my Fingbox and router in the living room ?

我的Raspberry Pi坐在客厅的Fingbox和路由器旁边吗?

I hope you enjoyed reading,Please follow and share for more tech stuff ??

希望您喜欢阅读,请关注 分享更多的技术资料?

翻译自: https://www.freecodecamp.org/news/the-most-robust-and-secure-home-automation-system-6d0ddbb39f29/

本地构建和自动化构建

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/393002.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

leetcode990. 等式方程的可满足性(并查集)

给定一个由表示变量之间关系的字符串方程组成的数组,每个字符串方程 equations[i] 的长度为 4,并采用两种不同的形式之一:“ab” 或 “a!b”。在这里,a 和 b 是小写字母(不一定不同),表示单字母…

random对文件随机重命名

对文件随机重命名,这个用途可广了,大家可以想想 echo off setlocal ENABLEDELAYEDEXPANSION for /r %%a in (*.txt) do ( set c!random! ren %%~dpnsa.txt !c!.txt) pause 本文转自sucre03 51CTO博客,原文链接:http://blog…

AC日记——Periodic RMQ Problem codeforces 803G

G - Periodic RMQ Problem 思路&#xff1a; 题目给一段序列&#xff0c;然后序列复制很多次&#xff1b; 维护序列很多次后的性质&#xff1b; 线段树动态开点&#xff1b; 来&#xff0c;上代码&#xff1a; #include <cstdio> #include <cstring> #include <…

数据之路 - Python爬虫 - 数据存储

一、文件存储 1.文件打开方式 文件打开方式说明r以只读方式打开文件。文件的指针将会放在文件的开头。这是默认模式rb以二进制只读方式打开一个文件。文件指针将会放在文件的开头r以读写方式打开一个文件。文件指针将会放在文件的开头rb以二进制读写方式打开一个文件。文件指针…

创建react应用程序_如何使用React创建一个三层应用程序

创建react应用程序Discover Functional JavaScript was named one of the best new Functional Programming books by BookAuthority!“发现功能JavaScript”被BookAuthority评为最佳新功能编程书籍之一 &#xff01; Splitting a Single Page Application into layers has a …

linux update语句,MySQL 多表 update sql语句总结

MySQL 多表 update 有几种不同的写法。假定我们有两张表&#xff0c;一张表为Product表存放产品信息&#xff0c;其中有产品价格列Price&#xff1b;另外一张表是ProductPrice表&#xff0c;我们要将ProductPrice表中的价格字段Price更新为Price表中价格字段的80%。在Mysql中我…

linux延时与定时操作

1、at ---系统延迟任务发起命令 at time >command ---任务指令 >ctrld ---发起任务 at -l ---列出延时任务Id at -r id ---删除改id任务 at -m ---让无输出的命令产生邮件 at -M ---让有输…

windows修改PowerShell(命令提示符)默认中文编码方式

如果以下方法都没有作用的话&#xff0c;可以直接在代码中调用<stdlib.h>中的system("mode con cp select65001")或者是system("chcp 65001")。当然&#xff0c;前提是你用的也是C、C、C#等强类型编程语言。 **************************************…

leetcode面试题 17.07. 婴儿名字(并查集)

每年&#xff0c;政府都会公布一万个最常见的婴儿名字和它们出现的频率&#xff0c;也就是同名婴儿的数量。有些名字有多种拼法&#xff0c;例如&#xff0c;John 和 Jon 本质上是相同的名字&#xff0c;但被当成了两个名字公布出来。给定两个列表&#xff0c;一个是名字及对应…

appium+python+iOS 环境搭建与使用中常见问题的解决方案链接

&#xff08;1&#xff09;WebDriverAgent 安装入门篇&#xff1a;https://www.cnblogs.com/zhanggui/p/9239827.html 重点摘要&#xff1a; 在WDA的Github上也给出了WDA的特性&#xff1a; 1.支持真机 &&模拟器 在模拟器上运行还是比较方便的&#xff0c;在真机上需要…

api工厂接口路径是什么_为什么(几乎)永远不要再使用绝对路径访问API

api工厂接口路径是什么by Vitaly Kondratiev通过维塔利康德拉季耶夫(Vitaly Kondratiev) 为什么(几乎)永远不要再使用绝对路径访问API (Why you should (almost) never use an absolute path to your APIs again) Recent advances in web apps architecture show that a decou…

双机通信c语言程序,上传一个自己编写的I2C双机通信程序

本帖最后由 micro_听海 于 2012-11-24 19:58 编辑这几天一直在搞AVR的twi(twi就是i2c)双机通信程序&#xff0c;使用的是两块arduino开发板。因为最总要这个通信程序最总是要放在winavr的编译环境中&#xff0c;所以没有使用arduino自带的库函数。但是这没关系&#xff0c;因为…

leetcode684. 冗余连接(并查集)

在本问题中, 树指的是一个连通且无环的无向图。 输入一个图&#xff0c;该图由一个有着N个节点 (节点值不重复1, 2, …, N) 的树及一条附加的边构成。附加的边的两个顶点包含在1到N中间&#xff0c;这条附加的边不属于树中已存在的边。 结果图是一个以边组成的二维数组。每一…

Windows Server 2008 部署权限管理RMS

1.1 实战&#xff1a;部署权限管理 试验目的&#xff1a; 在单域环境中部署活动目录权限管理服务&#xff0c;实现文档的保护。 试验环境&#xff1a; ? DCServer安装Windows Server 2008企业版&#xff0c;是ess.com的域控制器&#xff0c;安装企业CA。 ? RMSServer安装Wind…

day5 Python爬虫学习

一 实现京东上的自动搜索并提取信息 from selenium import webdriver # 导入键盘Keys from selenium.webdriver.common.keys import Keys import timedriver webdriver.Chrome()# 检测代码块 try:# 隐式等待&#xff0c;等待标签加载driver.implicitly_wait(10)# 往京东主页…

虚拟dom添加虚拟dom_虚拟DOM缓慢。 认识记忆化的DOM

虚拟dom添加虚拟domby Sindre Osen Aarsaether通过Sindre Osen Aarsaether 虚拟DOM缓慢。 符合已记忆的DOM。 (The Virtual DOM is slow. Meet the Memoized DOM.) 超越虚拟DOM和状态管理 (Moving beyond the Virtual DOM and State Management) The virtual DOM was a fantas…

编写一个字节数的rtu C语言校验程序,Modbus通信协议中CRC校验的快速C语言算法

Modbus通信协议中CRC校验的快速C语言算法2004年第11期            福 建 电 脑  63Modbus通信协议中CRC校验的快速C语言算法孟开元(西安石油大学计算机学院陕西西安710065)【摘 要】 本文主要讨论了Modbus通信协议的RTU帧格式中常用的错误校验方法,即循环冗…

leetcode1319. 连通网络的操作次数(并查集)

用以太网线缆将 n 台计算机连接成一个网络&#xff0c;计算机的编号从 0 到 n-1。线缆用 connections 表示&#xff0c;其中 connections[i] [a, b] 连接了计算机 a 和 b。 网络中的任何一台计算机都可以通过网络直接或者间接访问同一个网络中其他任意一台计算机。 给你这个…

Codeforces 600E Lomsat gelral (树上启发式合并)

题目链接 Lomsat gelral 占坑……等深入理解了再来补题解…… #include <bits/stdc.h>using namespace std;#define rep(i, a, b) for (int i(a); i < (b); i)typedef long long LL;const int N 600010;int n; int cc[N], col[N], sz[N], son[N]; LL ans[N];vect…

如何让CloudStack使用KVM创建Windows实例成功识别并挂载数据盘

问题产生背景&#xff1a; 使用CloudStack KVM组合进行资源池纳管工作&#xff0c;通过ISO镜像文件创建了两个模板&#xff1a; RHEL6U3 64位系统以及WindowsServer2008 R2 SP1 64位系统。然后通过模板创建实例&#xff0c;挂载外接存储&#xff0c;实例启动后&#xff0c;通过…