简体   繁体   English

启用硬件的应用程序的软件设置

[英]Software setup for hardware enabled application

I have a Raspberry PI that is tightly coupled with a device that I want to control. 我有一个Raspberry PI,它与要控制的设备紧密结合。

The desired setup I want to have would look something like this: 我想要的理想设置如下所示:

  1. The physical device with interactive hardware controls on the device (speaker, mic, buttons) 在设备上具有交互式硬件控件的物理设备(扬声器,麦克风,按钮)
  2. A Raspberry PI coupled to the device 与设备耦合的Raspberry PI
  3. On the PI: 在PI上:

    1. A daemon app that reacts to changes from the hardware 守护程序应用程序,对硬件的更改做出反应
    2. A Webinterface that shows the current state of the device and allows to configure the device Web界面,显示设备的当前状态并允许配置设备
  4. The system should somehow be able to update itself with new software when it becomes available (apg-get or some other mechnism). 系统可用时,应该可以使用新软件进行自身更新(apg-get或其他某种机制)。

For the Webinterface I am going to use a rails app, which is not a problem as such. 对于Webinterface,我将使用Rails应用程序,因此这不是问题。 What is not clear to me is the event-driven software that is talking to the hardware through gpio. 我不清楚的是事件驱动软件正在通过gpio与硬件通信。 Firstly, I would prefer to do this using ruby, so that I don't have a big technology gap when developing the solution. 首先,我更喜欢使用ruby进行此操作,这样在开发解决方案时不会有太大的技术差距。

  1. How can I ensure that both apps start up and run in the background when the raspberry PI starts 当树莓派PI启动时,如何确保两个应用程序都在后台启动并运行
  2. How do I notify the webapp of an event (eg a button was pressed). 我如何通知Webapp事件(例如,已按下按钮)。
  3. I wonder if it makes sense that the two pieces of software have a shared database to communicate. 我想知道这两个软件具有共享的数据库进行通信是否有意义。
  4. How to best setup some auto-update-mechanism for both pieces of software without requiring the user to take any actions. 如何在不要求用户采取任何措施的情况下,为这两种软件最好地设置一些自动更新机制。

Apps 应用

This will be dependent on the operating system 这将取决于操作系统

If you install a lightweight version of Linux, you might be able to create some runtime applications or something. 如果安装Linux的轻量级版本,则可以创建一些运行时应用程序或其他内容。 I've never done anything like this; 我从来没有做过这样的事; but I know from Windows you can create startup programs -- likewise, you should be able to do something similar in Linux 但是我知道从Windows您可以创建startup程序-同样,您应该能够在Linux中执行类似的操作

BTW you wouldn't "run" the Rails app - you'll fire up the server to capture any requests. 顺便说一句,您不会“运行” Rails应用程序-您将启动服务器以捕获所有请求。 You'd basically run your app locally in "production" mode - allowing you to send requests, either through localhost , or setup a pseudo domain in the HOSTS file of your box 您基本上可以在“生产”模式下在本地运行您的应用程序-允许您通过localhost发送请求,或者在包装箱的HOSTS文件中设置伪域

-- -

Web App 网络应用

The web app itself is RESTful , meaning (I believe), it will only act upon having requests sent to it. Web应用程序本身是RESTful的 ,这意味着(我相信),它将仅在发送请求后才起作用。 Because this works over the HTTP protocol, it essentially means you'll need some sort of (web) service to send requests to the web app: 由于这是通过HTTP协议运行的,因此从本质上讲,您需要某种(网络)服务才能将请求发送到Web应用:

Representational state transfer (REST) is a way to create, read, update or delete information on a server using simple HTTP calls 代表性状态传输(REST)是一种使用简单的HTTP调用在服务器上创建,读取,更新或删除信息的方法

Although I've never done this myself, I would use the ruby app on your PI to send HTTP requests to your Rails app. 尽管我自己从来没有做过,但是我会在PI上使用ruby应用程序将HTTP请求发送到Rails应用程序。 This will certainly add a level of complexity, but will ensure you an interface the two types of data-transfer 这肯定会增加一定程度的复杂性,但可以确保您将两种类型的数据传输接口

The difference you have is Rails / any other web app will only act on request. 您与众不同的地方是Rails /其他任何Web应用程序仅应要求提供服务。 "Native" applications will run as long as the operating system is operating; 只要操作系统在运行,“本机”应用程序就会运行; meaning you can "listen" for updates from the hardware etc. 意味着您可以“收听”来自硬件等的更新。

What I would do is split the functionality: 我要做的就是拆分功能:

  1. Hardware input > send to service 硬件输入>发送到服务
  2. Service > sends to Rails 服务>发送到Rails
  3. Rails > sends response to service Rails>发送响应到服务
  4. Service > processes response 服务>流程响应

This may seem inefficient, but I think it's the best way to capture local-based input from your hardware. 这看似效率低下,但我认为这是从硬件中捕获基于本地的输入的最佳方法。 You'll have to use a localhost rails app, running with something like nginx or some other efficient server 您必须使用localhost rails应用程序,并与nginx或其他一些高效的服务器一起运行

-- -

Database 数据库

it would only make sense if they shared the data. 只有他们共享数据才有意义。 You should remember that a database is different than a datatable . 你应该记住,一个database比一个不同的datatable A database stores many tables, and is generally meant for a single purpose; 数据库存储许多表,通常仅用于单一目的。 whilst a datatable stores a single type of data . 数据表存储单一类型的数据

From what you've written, I would recommend using two databases running on the same db server. 根据您的撰写,我建议使用在同一数据库服务器上运行的两个数据库。 This will give you the ability to create as many tables as you want for these databases - giving you scope to add as many different pieces of data you wish to each. 这将使您能够为这些数据库创建尽可能多的 -使您能够向每个数据库添加尽可能多的不同数据。 Sharing data can be done using an API or a web service 共享数据可以使用API​​或网络服务来完成

-- -

Updating 更新

Rails app will not need to be "updated" - you'll just need to deploy a fresh version. Rails应用程序不需要“更新”-您只需要部署一个新版本。 The beauty of Internet-centric software :) 以Internet为中心的软件之美:)

In terms of your Rasberry-PI "on-board" software update - I don't have much experience with this, so can only recommend 关于您的Rasberry-PI“板载”软件更新-我对此没有太多经验,因此只能推荐

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM