升级外部主板Android应用主板、Android

2023-09-07 09:13:29 作者:幼儿园老大

背景:

我们创建了一个Android应用程序,目前通过蓝牙连接的外部主板通信。板在转发出命令运行以不同的速度的一个或多个马达(多个)。 (该应用程序是专为特定任务在海洋产业)

我们的目标是要提升应用程序,使Android手机用户(在未来)就能发出上通过蓝牙连接的应用程序的命令升级主板的固件。

主板采用所谓的老标准的通信协议 YMODEM 。 http://en.wikipedia.org/wiki/YMODEM 该主板支持此功能,我们目前能够处理使用在Windows平台上的超级终端的固件升级。

主板内部外部接口图解

我的问题是,

是否有可能使用YMODEM协议在Android应用程序进行重新闪光?

如果是,如何?任何帮助将是pciated!感谢您寻找到这个AP $ P $!

解决方案

道歉响应晚,但它可能会有所帮助......是的,这绝对是可能的。我做的正是这种具有的Nexus 7和外部设备的ARM处理器。 Nexus的7时必须启用USB调试根植。我用 wugfresh的承上启下根工具包 - 这是非常容易的。

下一页(守住你的座位),您必须编写你的应用程序使用YMODEM协议。一种选择是使用Android NDK(原生开发包)汇编写在C / C一YMODEM协议++(试行的 Tixy的)。你需要的的cygwin 或的MinGW 的安装NDK之前,如果你正在使用Windows。

因此​​,让我们说你使用的是Windows,你必须安装在 NDK的C:\\ Android的NDK-R8B-WINDOWS \\ Android的NDK-R8B 。您可以使用Eclipse安装ADT插件,并假设该项目的新的工作区是c:\\ Android的工作空间。您可以使用批处理文件来执行NDK从您的项目做( C:\\ Android的工作区\\ batch.bat

  C:\\ Android的NDK-R8B-WINDOWS \\ Android的NDK-R8B \\ NDK-build.cmd暂停 

只要确保你导出的C / C ++函数,使他们可以通过您的Java Android应用程序中使用。

Interface.cpp:

 的#include<&string.h中GT;#包括LT&;&jni.h GT;#包括LT&;&dirent.h GT;#包括LT&;&stdio.h中GT;#包括LT&; SYS / types.h中>#包括LT&; SYS / stat.h>#包括LT&;&fcntl.h GT;#包括ymodem_tx.h#包括ymodem_main.h为externC{JNIEXPORT INT JNICALL Java_com_example_ymupload_MainActivity_ymodemSent(JNIEnv的* ENV,jobject OBJ,INT端口号,的jstring文件名){    INT状态= 0;    如果(端口号> = 0)    {        为const char *输入= env-> GetStringUTFChars(文件名,0);        状态= ymodem_sentFile(端口号,输入);        env-> ReleaseStringUTFChars(文件名,输入);    }    其他    {        状态= 0xFF的;    }    返回状态;}JNIEXPORT INT JNICALL Java_com_example_ymupload_MainActivity_YmodemGetTotalSize(JNIEnv的* ENV,jobject OBJ){    返回ymodem_getTotalSize();}JNIEXPORT INT JNICALL Java_com_example_ymupload_MainActivity_YmodemGetTransferredSize(JNIEnv的* ENV,jobject OBJ){    返回ymodem_getTransferredSize();}JNIEXPORT布尔JNICALL Java_com_example_ymupload_MainActivity_YmodemIsSending(JNIEnv的* ENV,jobject OBJ){    返回ymodem_bIsSending();}JNIEXPORT INT JNICALL Java_com_example_ymupload_MainActivity_YmodemGetStatus(JNIEnv的* ENV,jobject OBJ){返回ymodem_uGetStatus();}JNIEXPORT的jstring JNICALL Java_com_example_ymupload_MainActivity_YmodemGetFileName(JNIEnv的* ENV,jobject OBJ){    返回env-> NewStringUTF(ymodem_pGetFileName());}} 

另外,还要确保你把文件和其他 .C 的.cpp .H JNI 文件夹的文件在项目文件夹,例如: C:\\ Android的工作区\\ PROG名\\ JNI ,与 Android.mk 文件一起(有很多约 Android.mk 其他堆栈问题的文件)。

您可以把您想要的文件夹中闪烁的二进制文件/ SD卡/ 。下载一个文件浏览器,看到他们。

Background:

We created an Android app that currently communicates with an external mother board via Bluetooth connection. The board in-turn issues commands to run one or more motor(s) at different speeds. (This application was built for a specific task in the marine industry)

Our goal is to enhance the application so that android mobile users (in the future) will be able to upgrade the motherboard's firmware by issuing a command on the application connected via Bluetooth.

The motherboard uses an old standard communications protocol called YMODEM. http://en.wikipedia.org/wiki/YMODEM The mother board supports this function and we are currently able to handle the firmware upgrade using hyper terminal on a windows platform.

My question is:

Is it possible to use the YMODEM protocol in an android application to perform a re-flash?

If yes, how? Any help would be appreciated!!Thanks for looking into this!

解决方案

Apologies for the late response, but it might be helpful... Yes, it is definitely possible. I have done exactly this with a nexus 7 and an external device with an ARM processor. The nexus 7 must be rooted with USB debugging enabled. I used wugfresh's nexus root toolkit -- it was very easy.

Next (hold onto your seats), you must write your application to use the YModem protocol. One option is to use the android NDK (Native development kit) to compile a YModem protocol written in C/C++ (Try Tixy's). You'll need cygwin or mingw before you install the NDK if you're working with Windows.

So let's say your using windows and you have the NDK installed in c:\android-ndk-r8b-windows\android-ndk-r8b. You can use Eclipse with the adt plugin installed, and let's say your new workspace for the project is c:\android-workspace. You can use a batch file to execute NDK make from your project (c:\android-workspace\batch.bat):

C:\android-ndk-r8b-windows\android-ndk-r8b\ndk-build.cmd 
PAUSE

Just make sure you export the C/C++ functions so that they can be used by your JAVA android application.

Interface.cpp:

#include <string.h>
#include <jni.h>
#include <dirent.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#include "ymodem_tx.h"
#include "ymodem_main.h"

extern "C" {

JNIEXPORT int JNICALL Java_com_example_ymupload_MainActivity_ymodemSent( JNIEnv* env, jobject obj, int portNumber, jstring fileName)
{
    int status = 0;
    if (portNumber >= 0)
    {
        const char* input = env->GetStringUTFChars(fileName, 0);

        status = ymodem_sentFile(portNumber, input);

        env->ReleaseStringUTFChars(fileName, input);
    }
    else
    {
        status = 0xFF;
    }

    return status;
}


JNIEXPORT int JNICALL Java_com_example_ymupload_MainActivity_YmodemGetTotalSize( JNIEnv* env, jobject obj)
{
    return ymodem_getTotalSize();
}


JNIEXPORT int JNICALL Java_com_example_ymupload_MainActivity_YmodemGetTransferredSize( JNIEnv* env, jobject obj)
{
    return ymodem_getTransferredSize();
}



JNIEXPORT bool JNICALL Java_com_example_ymupload_MainActivity_YmodemIsSending( JNIEnv* env, jobject obj)
{
    return ymodem_bIsSending();
}

JNIEXPORT int JNICALL Java_com_example_ymupload_MainActivity_YmodemGetStatus( JNIEnv* env, jobject obj)
{
return ymodem_uGetStatus();
}


JNIEXPORT jstring JNICALL Java_com_example_ymupload_MainActivity_YmodemGetFileName( JNIEnv* env, jobject obj)
{
    return env->NewStringUTF(ymodem_pGetFileName());
}


}

Also make sure you put that file and other .c, .cpp, .h files in the jni folder in your project folder, e.g. c:\android-workspace\prog-name\jni, along with an Android.mk file (there are plenty of other stack questions about Android.mk files).

You can put the binaries that you want to flash in a folder on the /sdcard/. Download a file browser to see them.

 
精彩推荐
图片推荐