zoukankan      html  css  js  c++  java
  • Neptune 开发板w800 鸿蒙系统harmonyOS_hello world程序编程测试

    Neptune w800开发版ubuntu linux环境编译通过——如何搭建开发环境

    windows写代码,linux编译

    Utunbu安装Samba服务并映射目录到windows:

    https://www.cnblogs.com/txwtech/p/15087136.html

    安装VS code

    https://device.harmonyos.com/cn/docs/ide/user-guides/install_windows-0000001050164976

    启动VScode打开工程,并找到通过Z驱动映射的

    Neptune-HarmonyOS-IOT-master的目录

    会有几个选项,对应填入,framework选hb

    插入Neptune开发板,并查看com口

    点开工程-配置工程

    记得右上角的保存

    打开工程

    配置文件路径:以下目录供参考,请更改对应的路径

      "F:/utils/native/lite/include",
                    "F:/domains/iot/link/libbuild",
                    "F:/base/iot_hardware/peripheral/interfaces/kits",
                    "F:/third_party/cmsis/CMSIS/RTOS2/Include",
                    "F:/Neptune-HarmonyOS-IOT-master/base/iot_hardware/interfaces/kits/wifiiot_lite",
     

    右键app文件夹--创建文件夹--比如hello1

     

    右键Hello1,创建文件, hello1.c   与BUILD.gn

    hello1.c
    #include <stdio.h>
    
    #include <unistd.h>
    
    #include "cmsis_os2.h"
    #include "ohos_init.h"
    #include "wifiiot_gpio.h"
    #include "wifiiot_gpio_ex.h"
    #include "wifiiot_gpio_w800.h"
    
    static void* GpioTask(const char* arg)
    {
       (void) arg;
    
       for(int i=1;i<=10;i++)
       {
           /* code */
           printf("hello world!= %d
    ",i);
       }
       
       
    
    
    }
    
    static void hello1(void)
    {
        osThreadAttr_t attr={0};
        attr.name="GpioTask";
        attr.stack_size=4096;
        attr.priority=osPriorityNormal;
        if (osThreadNew((osThreadFunc_t)GpioTask, NULL, &attr) == NULL) {
            printf("[GpioExample] Falied to create GpioTask!
    ");
        }
    }
    SYS_RUN(hello1);

    BUILD.gn

    # Copyright (c) 2020 Huawei Device Co., Ltd.
    # Licensed under the Apache License, Version 2.0 (the "License");
    # you may not use this file except in compliance with the License.
    # You may obtain a copy of the License at
    #
    #     http://www.apache.org/licenses/LICENSE-2.0
    #
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # See the License for the specific language governing permissions and
    # limitations under the License.
    
    static_library("hello1") {
        sources = [
            "hello1.c"
        ]
    
        include_dirs = [
            "//utils/native/lite/include",
            "//kernel/liteos_m/components/cmsis/2.0",
            "//base/iot_hardware/interfaces/kits/wifiiot_lite",
        ]
    }

    修改app同目录的BUILD.gn

    代码:

    # Copyright (c) 2020 Huawei Device Co., Ltd.
    # Licensed under the Apache License, Version 2.0 (the "License");
    # you may not use this file except in compliance with the License.
    # You may obtain a copy of the License at
    #
    #     http://www.apache.org/licenses/LICENSE-2.0
    #
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # See the License for the specific language governing permissions and
    # limitations under the License.
    
    import("//build/lite/config/component/lite_component.gni")
    
    lite_component("app") {
        features = [
            # "startup",
            #"iothardware:gpio_example",
            # "wifitest:wifi_test",
            #"iothardware:lowpower_example"
            # "uart_sample:uart_demo"
            "Hello1:hello1",
        ]
    }

    添加内容后,都记得CTRL+S保存

    Linux界面的编译方法:

    https://www.cnblogs.com/txwtech/p/15086496.html

    、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、

    windows界面使用putty.exe链接ubuntu,这个windows是远程编译方法。

    参考链接:http://www.pc6.com/softview/SoftView_81789.html

    cd 进入Neptune-HarmonyOS-IOT-master目录,可以看到build.py,
    
    编译源码
     输入:python build.py w800
    
     
    
    
    make[2]: 进入目录“/home/txwtech/Downloads/Neptune-HarmonyOS-IOT-master/vendor/winnermicro/w800/src/app/cJSON”
    make[2]: 离开目录“/home/txwtech/Downloads/Neptune-HarmonyOS-IOT-master/vendor/winnermicro/w800/src/app/cJSON”
    make[1]: 离开目录“/home/txwtech/Downloads/Neptune-HarmonyOS-IOT-master/vendor/winnermicro/w800/src/app”
    libs has been updated.
    LINK     w800.elf
    OBJCOPY  w800.bin
    generate normal image completed.
    compress binary completed.
    generate compressed image completed.
    build finished!
    Build success!
    [170/170] STAMP obj/vendor/winnermicro/w800/build_w800_sdk.stamp
    ohos w800 build success!

    、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、

    上传程序到开发板

    启动串口监视功能,查看串口打印内容,验证是否上传成功:

    欢迎讨论,相互学习。 txwtech@163.com
  • 相关阅读:
    客户端用不用bind的区别
    软件项目开发流程
    很强大的几个网站
    MIS系统的 5个基本模块
    asp.net 生成导出word表单 ,导出excel; dataTable生成xls文件,返回前台下载;asp.net启动excel错误 80070005;excelxls columnName 不能改变; 读写excel的开源利器NPOI; 设置excel Cell的数据类型;
    正则快速入门
    asp.net 服务端调用客户端脚本; asp.net 服务端将文件传给客户端; reponse.ContentType的取值;用OutputStream.Write返回文件,效率是WriteFile的10倍;download link click和OutputStream的比较;
    常用编辑
    数据库流程图设计
    scroll位置控制 window的和div的
  • 原文地址:https://www.cnblogs.com/txwtech/p/15087370.html
Copyright © 2011-2022 走看看