用于嵌入式设备的良好的串行通信协议/堆栈? [英] A good serial communications protocol/stack for embedded devices?

查看:235
本文介绍了用于嵌入式设备的良好的串行通信协议/堆栈?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在为各种项目编写了多种不同的定制串行协议之后,我每次都重新发明轮胎,变得沮丧。为了继续为每个项目开发定制解决方案,我一直在寻找一个更通用的解决方案。我想知道是否有人知道符合以下要求的串行协议(或更好的是,实现):




  • 支持多个设备。我们希望能够支持RS485总线。

  • 保证交货。某种确认机制,以及一些简单的错误检测(CRC16可能很好)。

  • 不是主/从。理想情况下,从机将能够异步发送数据。这主要只是为了审美的原因,轮询每个奴隶的概念对我来说并不理想。

  • 操作系统的独立性。理想情况下,它不会依赖先发制人的多任务环境。我愿意承认这一点,如果我可以得到其他的东西。

  • ANSI C.我们需要能够为几种不同的架构编译它。



速度不是太多的问题,我们愿意放弃一些速度,以满足其他一些需求。但是,我们希望尽可能减少所需资源的数量。



我即将开始实施带有捎带ACK的滑动窗口协议,无需重复,也许有人可以救我麻烦。有没有人知道我可以利用的现有项目?或者也许是一个更好的策略?



更新

我认真考虑过TCP / IP实现,但真的希望对于更轻便的东西TCP / IP的许多功能对我正在努力做的都是过分的。我愿意(勉强地)接受(也许我想要的功能)不包括在更轻的协议中。



更新2

感谢您对CAN的提示。我以前看过它,可能会在将来使用它。我真的希望图书馆处理确认,缓冲,重试等。我想我更多的是寻找网络/传输层,而不是数据链路/物理层。



更新3

这听起来像这个领域的艺术状态是:




  • 修剪掉TCP / IP协议栈。可能从 lwIP uIP

  • 基于CAN的实现可能会严重依赖于CAN总线,因此在其他物理层上不会有用。像 CAN Festival 这样可以帮助您。

  • HDLC或SDLC实施(如这一个)。这可能是我们要采取的路线。



如果您遇到这个问题,请随时发布更多答案。 >

解决方案

您是否考虑过 HDLC SDLC



还有 LAP / D (链接访问协议,D-Channel)。 B
$ b

Uyless Black的数据链路协议 总是在我的书架附近 - 你可能会在那里找到一些有用的材料(甚至仔细阅读不同协议的TOC和研究)


After writing several different custom serial protocols for various projects, I've started to become frustrated with re-inventing the wheel every time. In lieu of continuing to develop custom solutions for every project, I've been searching for a more general solution. I was wondering if anyone knows of a serial protocol (or better yet, implementation) that meets the following requirements:

  • Support multiple devices. We'd like to be able to support an RS485 bus.
  • Guaranteed delivery. Some sort of acknowledgement mechanism, and some simple error detection (CRC16 is probably fine).
  • Not master/slave. Ideally the slave(s) would be able to send data asynchronously. This is mostly just for aesthetic reasons, the concept of polling each slave doesn't feel right to me.
  • OS independence. Ideally it wouldn't rely on a preemptive multitasking environment at all. I'm willing to concede this if I can get the other stuff.
  • ANSI C. We need to be able to compile it for several different architectures.

Speed isn't too much of an issue, we're willing to give up some speed in order to meet some of those other needs. We would, however, like to minimize the amount of required resources.

I'm about to start implementing a sliding window protocol with piggybacked ACKs and without selective repeat, but thought that perhaps someone could save me the trouble. Does anyone know of an existing project that I could leverage? Or perhaps a better strategy?

UPDATE
I have seriously considered a TCP/IP implementation, but was really hoping for something more lightweight. Many of the features of TCP/IP are overkill for what I'm trying to do. I'm willing to accept (begrudgingly) that perhaps the features I want just aren't included in lighter protocols.

UPDATE 2
Thanks for the tips on CAN. I have looked at it in the past and will probably use it in the future. I'd really like the library to handle the acknowledgements, buffering, retries etc, though. I guess I'm more looking for a network/transport layer instead of a datalink/physical layer.

UPDATE 3
So it sounds like the state of the art in this area is:

  • A trimmed down TCP/IP stack. Probably starting with something like lwIP or uIP.
  • A CAN based implementation, it would probably rely heavily on the CAN bus, so it wouldn't be useful on other physical layers. Something like CAN Festival could help along the way.
  • An HDLC or SDLC implementation (like this one). This is probably the route we'll take.

Please feel free to post more answers if you come across this question.

解决方案

Have you considered HDLC or SDLC?

There's also LAP/D (Link Access Protocol, D-Channel).

Uyless Black's "Data Link Protocols" is always nearby on my bookshelf - you might find some useful material in there too (even peruse the TOC & research the different protocols)

这篇关于用于嵌入式设备的良好的串行通信协议/堆栈?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆