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

时间:2022-11-29 12:14:33

I want to port an Arduino library (namely, the HerkuleX servo control library) from Arduino to the PC (namely, a desktop running Linux). Since Arduino libraries are written in C++, this should be fairly easy. However, the HerkuleX library makes use of the Arduino's Serial library, which AFAIK is specific to the hardware. Does anyone know of a cross-platform serial library (like Boost.Asio) with the same API as the Arduino one? I thought for sure it would exist already, but Google failed me. 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. (That way if the upstream Arduino library is updated, re-porting it to PC won't be too much hassle.)

我想将Arduino库(即HerkuleX伺服控制库)从Arduino移植到PC(即运行Linux的桌面)。由于Arduino库是用C ++编写的,因此这应该相当容易。但是,HerkuleX库使用了Arduino的串行库,AFAIK专用于硬件。有没有人知道一个跨平台的串行库(如Boost.Asio)与Arduino相同的API?我确信它已经存在,但Google让我失望了。如果没有,我假设我将不得不选择一个现有的串行库并自己创建一个包装器,因此它的行为类似于Arduino Serial库。 (这样,如果更新上游Arduino库,将其重新移植到PC将不会太麻烦。)

1 个解决方案

#1


0  

Unfortunately the Arduino serial library is not portable. The code relies heavily on hardware and the AVR aritechiture of the Arduino. Here is the source and header file. As you can see in the header file it includes functions from the AVR library.

不幸的是,Arduino串行库不可移植。代码很大程度上依赖于硬件和Arduino的AVR aritechiture。这是源文件和头文件。正如您在头文件中看到的,它包含AVR库中的函数。

#1


0  

Unfortunately the Arduino serial library is not portable. The code relies heavily on hardware and the AVR aritechiture of the Arduino. Here is the source and header file. As you can see in the header file it includes functions from the AVR library.

不幸的是,Arduino串行库不可移植。代码很大程度上依赖于硬件和Arduino的AVR aritechiture。这是源文件和头文件。正如您在头文件中看到的,它包含AVR库中的函数。