This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

z-stack linux gateway 中更新protobuf-c的问题

Other Parts Discussed in Thread: Z-STACK

我下载了z-stack linux gateway 然后尝试编译到PC机去执行,按照流程,我下载了 protobuf2.6.1版本。protobuf-c1.2.1版本,并且在ubuntu上也安装成功了,使用protoc-c编译了 nwkmgr.proto 文件

开始编译代码,遇到

nwkmgr.pb-c.h:12:3: error: #error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers.
 # error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers.

然后按照指示,更新了 代码目录中的google/protobuc-c/下面的protobuf-c.h头文件。可以又遇到以下问题

/zstackpb/zstack.pb-c.h:11:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘typedef’
 typedef struct _AFAddr AFAddr;

zstackpb/zstack.pb-c.h:498:3: error: unknown type name ‘AFAddr’
   AFAddr *dstaddr;

还有一个问题,就是为什么源代码目录中没有zstack.pb-c.c的 zstack.proto和server.pb-c.c的server.proto文件??

  • 怀疑是版本问题,建议参考帖子中的版本再测试: e2e.ti.com/.../2150897
  • 看看这篇文章有没有帮助

    http://sunmaysky.blogspot.hk/2017/03/build-ti-z-stack-linux-home-gateway.html

    Build TI Z-Stack Linux Home Gateway reference design for x86 Linux

    The following steps show you hot to build TI Z-Stack Linux Home Gateway reference design for x86 Linux.

    1. Download Z-Stack_Linux_Gateway-1.0.1-src-linux-installer.run from www.ti.com/.../z-stack-archive.

    2. Setup a 32 bit Ubuntu and run Z-Stack_Linux_Gateway-1.0.1-src-linux-installer.run to extract Z-Stack Linux Gateway source code to your Linux Home folder\Z-Stack_Linux_Gateway-1.0.1-src

    3. Revise the build script package_builder_bbb (in red) under “your Linux Home folder\Z-Stack_Linux_Gateway-1.0.1-src\Source\scripts\”

    ...
    #Target platform:
        #export TARGET_PLATFORM="BEAGLEBONE_BLACK"
        export TARGET_PLATFORM="x86"
    ...
        cd $NPI_SOURCE/Projects/tools/LinuxHost
        make clean
        make create_output
        #make arch-all-armBeagleBone CC_armBeagleBone=$COMPILER |& tee -a $MAKE_LOG_FILE
        make $BUILD_TYPE |& tee -a $MAKE_LOG_FILE
    ...
    # *** Copy resources ***********************************************************************************

    #cp $NPI_SOURCE/Projects/tools/LinuxHost/out/NPI_lnx_armBeagleBone_server $BINARIES_SERVERS_DIR/NPI_lnx_${PLATFORM_SUBSTRING}_server
    cp $NPI_SOURCE/Projects/tools/LinuxHost/out/NPI_lnx_${PLATFORM_SUBSTRING}_server $BINARIES_SERVERS_DIR/NPI_lnx_${PLATFORM_SUBSTRING}_server

    4.a Install protobuf by doing the following two apt-get install

           sudo apt-get install protobuf-c-compiler
           sudo apt-get install protobuf-compiler

    4.b Create a new folder "tools" and export TCLIB to it using the following lines:
      
           cd ~ 
           mkdir tools 
           export TCLIB=~/tools/

    5. Switch to your Linux Home folder\Z-Stack_Linux_Gateway-1.0.1-src\Source\ and run ./build_all

    6. The output will be at "your Linux Home folder\Z-Stack_Linux_Gateway-1.0.1-src\Source\ERROR_out\z-stack_linux_gateway_x86_binaries.tar". The build error is due to the lack of comparison file but the output binaries still work on x86 environment.

    7. Copy and untar “z-stack_linux_gateway_x86_binaries.tar” to your working directory on x86 (called <target_install>). Please follow the (Z-Stack Linux Gateway User Guide.pdf, Chap 6.3) to start the application. Please note you have to specify x86 when you run zigbeeHAgw like "sudo ./zigbeeHAgw x86"

    8. If you run it successfully, you will see the results like the following screen shot.
  • 并不是这个问题,现在是ztack.pb-c.h ztack.pb-c.c 这两文件无法在 protobuf-c 1.2.1中编译,其他的都有proto文件,可以使用新版的protobuf-c编译下,但是这个没有提供 proto文件。。。坑爹的TI
  • 不知道你遇到什么编译问题,这两个protobuf生成的文件,我之前是可以编译过去的,虽然没有*.proto我们没办法再次生成这两个文件,但是一般使用是足够了。
  • 先谢谢回复
    我这边是这样的情况,protobuf 使用的是 2.6版本 protobuf-c是1.2.1版本
    然后我这边编译为x86架构,默认不改任何代码,可以编译生成固件,并没有任何问题

    后面我给nwkmgr.proto添加新内容,就加了一个message。然后重新使用protoc-c --c_out=./ nwkmgr.proto 重新生成了 nwkmgr.pb-c.c和h文件,然后扔在目录里面再次编译,这边编译出现错误,提示我这边使用的是新版本的protobuf-c编译的,让我更新一下protobuf-c的头文件,也就是我帖子一开始的问题,然后按照指示,我更换了代码目录里的protobuf-c的头文件,再次编译,然后又开始报错,这次是 zstack.pb-c.c文件 报错内容
    /zstackpb/zstack.pb-c.h:11:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘typedef’
    typedef struct _AFAddr AFAddr;
  • 更新 头文件的时候。lib文件我也一并更新了,然后旧版本的 zstac.pb-c文件就开始报错了
  • 据我了解,目前protobuf-c并不是google官方支持的,而是第三方的一个实现,不过做的也挺不错的,标准的protobuf只有C++、java等的实现,并没有c的实现。

    所以显然protobuf几个版本之间兼容性出了一些问题,TI zigbee linux gateway释放的时间是在2014年,那时protobuf-c版本显然不是1.2.1版本,还可能更早。

    protobuf目的是为了传输数据,其实同一个进程里面,这个性能并不是很大,从TI的代码来看,并非同一个团队开发的,有好几个风格的代码,所以可能是为了团队之间合作才决定使用的protobuf来交换数据。

    所以建议你还是自己写个结构体,直接传参数好了,没必要用他的*.proto外加再生成.c和.h文件,再进一步的编译。

    题外话:
    我们当初准备在zigbee linux gateway上做的开发,评估分析了代码之后,还是放弃了,这里面过于复杂,冗余的实现很多,多个进程之间相互作用,还要依赖脚本跟踪进程的生命周期,一旦一个崩溃了,整个gateway都得退出,问题很多。

    后来就还了znp-host-framework,简单好用,只是功能很多有缺少,不过不是难事,诸如OTA,诸如ZCL,诸如指令seqNumber跟踪,后来都给加上了,目前用起来比较稳定。
  • 嗯,之前了解过znp-host-framework,但是底层固件使用了ZHA的现成ZCL,而znp-host-framework却没有 ZCL,要去移植过来,由于开发人员太少,所以直接用了gateway的,自己删除了部分其他平台不用的 ,主要坑爹的是手机端已经实现了三个Server的链接和数据交换了,现在没退路了,只能硬着搞了,对的 这个gateway的代码确实调来调去的很复杂,但是不得不说的是,部分代码的逻辑写的很好,就当学习了,而且现在也被精简的差不多了,现在就增加新功能的时候却来这出。。。不服啊 笑哭
  • 问题已解决,尽快结贴!
  • Z-Stack™Linux Ubuntu Gateway 会再出新版本吗.现在这个是2014年的啊....还会更新吗.