简体   繁体   English

Arduino Uno 代码可以使用交叉编译器在 BeagleBone Black 上运行吗?

[英]Can Arduino Uno code run on a BeagleBone Black using a cross compiler?

I am currently part of a research team that is developing an unmanned submarine for local rescue divers.我目前是一个研究团队的一员,该团队正在为当地救援潜水员开发无人潜艇。 The goal is to improve and fix the prototype from last year's team.目标是改进和修复去年团队的原型。

Right now the vehicle uses an Arduino Uno and a BeagleBone Black.现在车辆使用 Arduino Uno 和 BeagleBone Black。 The Arduino controls six rotors and a few on-board sensors, while the BeagleBone controls an on-board camera (don't ask why, this setup was chosen. The previous team is long gone, so we have no choice but to move forward). Arduino 控制六个转子和几个板载传感器,而 BeagleBone 控制一个板载摄像头(不要问为什么,选择了这个设置。以前的团队早已不在,所以我们别无选择,只能继续前进)。

According to the last team, the Arduino couldn't control all of the equipment due to "shield" issues.根据最后一个团队的说法,由于“屏蔽”问题,Arduino 无法控制所有设备。 Using the BeagleBone for everything would've been optimal, but the team couldn't rewrite the code in 2 days (no one knew Java).将 BeagleBone 用于所有事情本来是最佳选择,但团队无法在 2 天内重写代码(没有人知道 Java)。 Since I only know Java, my initial plan for the course of the project was to learn C++ and rewrite the code in Java.由于我只懂Java,所以我在项目过程中的最初计划是学习C++,并用Java重写代码。

Recently, I came across the term "cross compiler" which, from what I understood, allowed a program, written in one language, to run on a platform that uses a different language.最近,我遇到了“交叉编译器”这个术语,据我所知,它允许用一种语言编写的程序在使用不同语言的平台上运行。 Would a cross-compiler be able to take code from an Arduino and "convert" it for BeagleBone?交叉编译器能否从 Arduino 中获取代码并将其“转换”为 BeagleBone? It seems like the code would be too complex to be converted from language to language.代码似乎太复杂了,无法从语言转换到语言。 Sorry if I sound "noobish" I'm a mechanical engineer student who took one Java class.对不起,如果我听起来“笨手笨脚”,我是一名机械工程师学生,他参加了一个 Java 课程。

It may be possible to compile the C/C++ code from the Arduino on the BeagleBone but it wouldn't work the same way.可以在 BeagleBone 上从 Arduino 编译 C/C++ 代码,但它不会以相同的方式工作。 The I/O ports are not going to be addressed the same way and there are likely many other issues. I/O 端口不会以相同的方式解决,可能还有许多其他问题。 On the Arduino your program is pretty much the only thing running.在 Arduino 上,您的程序几乎是唯一运行的东西。 On a BeagleBone you've got a full fledged Unix O/S running and your code is one of many processes.在 BeagleBone 上,您有一个完整的 Unix O/S 运行,并且您的代码是许多进程之一。

If you know Java the C/C++ code shouldn't be too hard to read.如果您了解 Java,那么 C/C++ 代码应该不会太难阅读。 Reading the ports and controlling what I would guess would be servos is certainly possible on the BeagleBone.在 BeagleBone 上读取端口并控制我猜测的伺服系统当然是可能的。 If you've got some Auduino shields though that could be an issue.如果您有一些 Auduino 防护罩,那可能是一个问题。 They may talk SPI or I2C but they may instead use something lower level - maybe just a PWM signal.他们可能会说 SPI 或 I2C,但他们可能会使用较低级别的东西——也许只是一个 PWM 信号。

This isn't going to be a trivial project but my opinion is that you're heading the right way.这不会是一个微不足道的项目,但我认为您正朝着正确的方向前进。 I'd take one subsystem at a time and re-write that code for the BeagleBone.我会一次采用一个子系统,然后为 BeagleBone 重新编写该代码。 Something like this cape can drive steppers or servos.像这样的斗篷可以驱动步进器或伺服器。 However, that brings up another problem - the supplied library is in Python - yet some more porting to be done.然而,这带来了另一个问题——提供的是用 Python 编写的——还有更多的移植工作要做。

So cross-compilation won't help - the code is theoretically portable but not really.所以交叉编译无济于事 - 代码理论上是可移植的,但实际上并非如此。 It's going to take a rewrite.这将需要重写。

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

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