C语言 对于小型嵌入式系统,什么是好的脚本语言?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6759391/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 09:10:16  来源:igfitidea点击:

What is a good scripting language for a small embedded system?

cscriptingembedded

提问by u??

I am looking for a scripting language that can be included in an embedded system to allow the user to pre-configure the unit behaviour based on the system events (I/O port changes, time events...). The sort of control required is

我正在寻找一种可以包含在嵌入式系统中的脚本语言,以允许用户根据系统事件(I/O 端口更改、时间事件...)预先配置单元行为。所需的控制类型是

if (some_event)
{ 
    do some stuff
    delay N seconds
    do more stuff
    if (some condition)
    {
        do something
    }
    else
    {
        delay until condition
        do something else
    }
}

Each of the "do stuff" parts of the would typically be to change the state of the IO or to allow/disallow the processing of one or more events.

的每个“做事”部分通常是更改 IO 的状态或允许/禁止处理一个或多个事件。

There is no requirement for text processing or file handling unless it is required internally by the scripting language implementation.

除非脚本语言实现在内部需要,否则不需要文本处理或文件处理。

The processor that I am using has some 8K of RAM and 20K of program store available after the normal operating code has been built. The firmware is written in C, so any source for the scripting language must also be in C.

在构建正常的操作代码后,我使用的处理器有一些 8K 的 RAM 和 20K 的程序存储可用。固件是用 C 编写的,所以脚本语言的任何源代码也必须是用 C 编写的。

采纳答案by Crashworks

We use Squirrelfor this job. It is similar to Lua, but reference counted instead of garbage collected, so it tends to work better in very tight memory. On the downside, its community is much smaller.

我们使用Squirrel来完成这项工作。它与Lua类似,但引用计数而不是垃圾收集,因此它在非常紧张的内存中往往能更好地工作。不利的一面是,它的社区要小得多。

I have also seen Lisp embeddedsuccessfully, particularly a Scheme-like derivative.

我还看到Lisp成功嵌入,尤其是类似 Scheme 的衍生产品。

See also this other StackOverflow question: What are the available interactive languages that run in tiny memory?

另请参阅另一个 StackOverflow 问题:在微小内存中运行的可用交互式语言是什么?

回答by Jeff Foster

Luais my first choice as an embedded language. It's written in C, easy to expose your own functions to Lua, and by the looks of it some work has been done to get it working on embedded systems.

Lua是我作为嵌入式语言的首选。它是用 C 编写的,很容易将你自己的函数暴露给 Lua,从它的外观来看,已经做了一些工作来让它在嵌入式系统上工作。

回答by lhf

For embedded systems, try eLua.

对于嵌入式系统,请尝试eLua

回答by Gilles 'SO- stop being evil'

A traditional choice is Forth. Small embedded systems such as microcontrollers are Forth's platform of choice. There are Forth many implementations with a variety of features, target platforms and licensing. The Forth Interest Group has a list of commercial implementationand non-commercial implementations.

一个传统的选择是Forth。诸如微控制器之类的小型嵌入式系统是 Forth 的首选平台。Forth 有许多具有各种特性、目标平台和许可的实现。Forth Interest Group 有一份商业实施非商业实施的清单。

回答by Matten

I would give Lua a shot as it is a very small scripting language. It can be fully embedded

我会给 Lua 一个机会,因为它是一种非常小的脚本语言。它可以完全嵌入

Lua is a fast language engine with small footprint that you can embed easily into your application. Lua has a simple and well documented API that allows strong integration with code written in other languages. It is easy to extend Lua with libraries written in other languages. It is also easy to extend programs written in other languages with Lua. Lua has been used to extend programs written not only in C and C++, but also in Java, C#, Smalltalk, Fortran, Ada, Erlang, and even in other scripting languages, such as Perl and Ruby.

Lua 是一种快速的语言引擎,占用空间小,您可以轻松地将其嵌入到您的应用程序中。Lua 有一个简单且文档齐全的 API,允许与用其他语言编写的代码进行强集成。使用其他语言编写的库很容易扩展 Lua。使用 Lua 扩展其他语言编写的程序也很容易。Lua 不仅用于扩展用 C 和 C++ 编写的程序,还用于扩展用 Java、C#、Smalltalk、Fortran、Ada、Erlang 甚至其他脚本语言(如 Perl 和 Ruby)编写的程序。

Lua homepage

Lua主页

回答by MarkusSchaber

I had good experience using pawn (http://www.compuphase.com/pawn/pawn.htm) in a former project. A derivate of it is also used in the "E17" desktop environment, they call it "embryo". (https://trac.enlightenment.org/e/wiki/Embryo).

我在以前的项目中使用 pawn ( http://www.compuphase.com/pawn/pawn.htm)有很好的经验。它的一个派生也用于“E17”桌面环境,他们称之为“胚胎”。(https://trac.enlightenment.org/e/wiki/Embryo)。

回答by harald

You could also try JavaScript, the V8 enginefrom Google is very easy to embed. Also the language itself is really small, so you can pretty much shape it into something that's suitable for your domain.

你也可以试试 JavaScript,谷歌的V8 引擎很容易嵌入。此外,语言本身非常小,因此您几乎可以将其塑造成适合您领域的东西。

回答by Bryan Oakley

There are four fairly common languages for embedding (in no particular order):

有四种相当常见的嵌入语言(排名不分先后):

Of these, Lisp and Forth are arguably the least end-user friendly. Lua currently seems to be the most popular (it's very popular in the gaming world), Tcl is arguably the simplest to learn (only 12 rules for the whole language) and is the defacto language in the EDA world.

其中,Lisp 和 Forth 可以说是对最终用户最不友好的。Lua 目前似乎是最流行的(它在游戏界非常流行),Tcl 可以说是最容易学习的(整个语言只有 12 条规则)并且是 EDA 世界中事实上的语言。

回答by niko

Hope these helps you embedding perl script in c applications

希望这些可以帮助您在 C 应用程序中嵌入 perl 脚本

http://www.ibm.com/developerworks/linux/tutorials/l-perlscript/index.html

http://www.ibm.com/developerworks/linux/tutorials/l-perlscript/index.html

Just google it for more informataion.I believe perl helps you alot in pattern (strings) searching. To learn perl go through this tutorial

只需谷歌它以获取更多信息。我相信 perl 可以帮助您进行模式(字符串)搜索。要学习 perl,请阅读本教程

http://mj12net.org/courses/perl/Teach%20Yourself%20Perl%20in%2021%20Days.pdf

http://mj12net.org/courses/perl/Teach%20Yourself%20Perl%20in%2021%20Days.pdf

Its a good tutorial,You can explore more than u think. Thank you

这是一个很好的教程,您可以探索比您想象的更多。谢谢