简体   繁体   English

是否有Arduino Serial库的跨平台“端口”?

[英]Is there a cross-platform “port” of the Arduino Serial library?

I want to port an Arduino library (namely, the HerkuleX servo control library) from Arduino to the PC (namely, a desktop running Linux). 我想将Arduino库(即HerkuleX伺服控制库)从Arduino移植到PC(即运行Linux的桌面)。 Since Arduino libraries are written in C++, this should be fairly easy. 由于Arduino库是用C ++编写的,因此应该相当容易。 However, the HerkuleX library makes use of the Arduino's Serial library, which AFAIK is specific to the hardware. 但是,HerkuleX库使用了Arduino的串行库,AFAIK专用于硬件。 Does anyone know of a cross-platform serial library (like Boost.Asio) with the same API as the Arduino one? 有没有人知道一个跨平台的串行库(如Boost.Asio)与Arduino相同的API? I thought for sure it would exist already, but Google failed me. 我确信它已经存在了,但Google让我失望了。 If not, I assume I'll have to pick an existing serial library and make a wrapper around it myself so it behaves like the Arduino Serial library. 如果没有,我假设我将不得不选择一个现有的串行库并自己创建一个包装器,因此它的行为类似于Arduino Serial库。 (That way if the upstream Arduino library is updated, re-porting it to PC won't be too much hassle.) (这样,如果更新上游Arduino库,将其重新移植到PC将不会太麻烦。)

Unfortunately the Arduino serial library is not portable. 不幸的是,Arduino串行库不可移植。 The code relies heavily on hardware and the AVR aritechiture of the Arduino. 代码严重依赖于硬件和Arduino的AVR aritechiture。 Here is the source and header file. 这是文件和文件。 As you can see in the header file it includes functions from the AVR library. 正如您在头文件中看到的,它包含AVR库中的函数。

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

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