This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

*/

Franca 설치 가이드

Franca 설치 가이드
설치 환경
OS : Windows 10, 64bit

참고 : https://github.com/franca/franca/wiki/Franca-Quick-Install-Guide
설치 순서

  1. 이클립스 인스톨러를 사용하여 Eclipase Oxygen 2의 Eclipse DSL 도구 에디션을 설치한다.
    •   Franca는 JAVA 8에서 가장 잘 동작한다.
    • 설치시 JAVA 머신이 설치되어 있지 않으면다음과 같은 메세지 박스가 출력된다.
    • 아니요 선택시 Eclipse site에서 Java 1.8.0선택시 Oracle site로 포워딩후 JDK 다운로드한다.
    • JDK 설치후 다시 인스톨 진행한다. DSL Tools를 선택하고, VM위치와 작업디렉토리를 결정한다.
    • JDK 설치후 다시 인스톨한다. DSL Tools를 선택하고, VM위치와 작업디렉토리를 결정한다.
  2. eclipse.exe를 실행
  3. Franca extention을 위해 추가적으로 Eclipse plugin package들을 설치
  4. 구글드라이브에서 최신버젼을 다운로드 한다. Release 폴더에서 최신버젼(0.13.1 2018년 7월 23일)
  5. Help > Install New Software ...에서 Add 클릭하고 Archive.... 선택해서 위에서 다운로드 받은 zip파일을 Open하고 모든 것을 선택하여 설치한다.
  6. 설치완료.. empty 프로젝트를 생성하여 확장자 fidl파일을 추가 하여 Franca IDL Editor로 편집한다.
설치
Eclipse : https://www.eclipse.org/downloads/

관련링크 :
CommonAPI Stub? Proxy?
SOME/IP 헤더 구조와 fdepl파일 관계
CommonAPI Generator로 생성되는 file
Franca 설치 가이드
Linux Xubuntu에 CommonAPI C/C++ 개발환경 구축하기

CommonAPI C++ with SOME/IP Example

순서

  1. CommonAPI C++런타임 라이브러리 작성 
  2. 런타임라이브러리 작성
  3. Franca파일 작성 및 코드 생성
  4. 클아이언트 및 서비스 응용 프로그램 작성
  5. 빌드 및 실행
Dependencies
  • A C++11 enabled compiler like gcc >= 4.8 is needed.
  • vsomeip uses CMake as buildsystem.
  • vsomeip uses Boost >= 1.55:
  • JAVA JRE Runtime(Oracle JRE 참고)
Test Version
  • CommonAPI runtime : 3.1.12.6
  • SOME/IP runtime : 3.1.12.9
  • vsomeip : 2.14.16
  • libboost : 1.58
시작하기 전에 개발환경구축했는지 확인하고 하자..

    1.CommonAPI C++런타임 라이브러리

    • COMMONAPI 다운로드                           
    $ git clone https://github.com/GENIVI/capicxx-core-runtime.git

    $ cd capicxx-core-runtime
    capicxx-core-runtime$ mkdir build
    capicxx-core-runtime$ cd build
    capicxx-core-runtime/build$ cmake ..


    capicxx-core-runtime/build$ make

    capicxx-core-runtime/build$ mkdir ../../COMMONAPI 
    capicxx-core-runtime/build$ cp -d lib* ../../COMMONAPI 
    capicxx-core-runtime/build$ cd ../..

    2. CommonAPI SOME/IP 런타임 라이브러리 작성

    • SOME/IP
    $ git clone https://github.com/GENIVI/capicxx-someip-runtime.git


    • Boost Install
    $ sudo apt-get install libboost-system1.55-dev libboost-thread1.55-dev libboost-log1.55-dev

    :

    ** Package가 없다고 메세지가 나올때 "sudo apt search libboost" 명령어로 버젼을 확인후 해당버전을 인스톨한다.

    $ git clone http://github.com/GENIVI/vSomeIP.git

    ** SOME/IP는 코어 네트워크 펑션을 사용하기 위해 표준 크로스플랫폼 C++라이브러리 Boost.Asio를 사용함으로 vsomeip라이브러리를 사용하기 전에 Boost를 시스템에 인스톨해야한다.
    ** vsomeip를 빌드하기 전에 2.xx 버전에서 실행한다.  vsomeip의 버젼이 3.xx버전일 경우 2.xx버젼에서 수행 하도록 한다.
    • Build vsomeip
    $ cd vSomeIP
    vSomeIP$ mkdir build
    vSomeIP$ cd build
    vSomeIP/build$ cmake ..


    vSomeIP/build$ make


    vSomeIP/build$ cp -d lib* ../../COMMONAPI
    vSomeIP/build$ cd ../..
    • Build CommonAPI C++ SOME/IP
    $ cd capicxx-someip-runtime/
    capicxx-someip-runtime$ mkdir build
    capicxx-someip-runtime$ cd build
    capicxx-someip-runtime/build$ cmake -DUSE_INSTALLED_COMMONAPI=OFF ..

          ** cmake시 vsomeip관련 오류 발생시 vsomeip의 버전 체크 필요.
          ** vsomeip의 버젼이 3.xx버전일 경우 2.xx버젼에서 수행

    capicxx-someip-runtime/build$ make

    capicxx-someip-runtime/build$ cp -d lib* ../../COMMONAPI
    capicxx-someip-runtime/build$ cd ../..

    3. Franca파일 작성 및 코드 생성

    프로젝트 디렉토리 생성하고  디렉토리의 하위에 fidl 디렉토리생성 및 해당 디렉토리상에 아래의 deployment specification를 작성
    • HelloWorld.fdepl
    import "platform:/plugin/org.genivi.commonapi.someip/deployment/CommonAPI-SOMEIP_deployment_spec.fdepl"
    import "HelloWorld.fidl"
    define org.genivi.commonapi.someip.deployment for interface commonapi.HelloWorld {
      SomeIpServiceID = 4660 method sayHello {
         SomeIpMethodID = 31000
      }
    }
    define org.genivi.commonapi.someip.deployment for provider MyService {
      instance commonapi.HelloWorld {
         InstanceId = "test"
         SomeIpInstanceID = 22136
      }
    }
    • HelloWorld.fidl
    package commonapi
    interface HelloWorld {
       version {major 1 minor 0}
       method sayHello {
          in {
             String name
          }
          out {
             String message
          }
       } 
    }
    • Get CommonAPI, SOME/IP Code Generator
    $ wget https://github.com/GENIVI/capicxx-core-tools/releases/download/3.1.12.4/commonapi-generator.zip

    $ wget https://github.com/GENIVI/capicxx-someip-tools/releases/download/3.1.12.2/commonapi_someip_generator.zip
    $ unzip commonapi-generator.zip -d ~/commonapi-generator
    $ unzip commonapi_someip_generator.zip -d ~/commonapi_someip_generator
    $ chmod +x ~/commonapi-generator/commonapi-generator-linux-x86
        * OS가 64bit일경우 commonapi-generator-linux-x86_64 파일에 적용
    $  chmod +x ~/commonapi_someip_generator/commonapi-someip-generator-linux-x86
        * OS가 64bit일경우 commonapi-someip-generator-linux-x86_64 파일에 적용
    • Generate SOME/IP Code
    $ mkdir hello
    $ cd hello
    hello$ ~/commonapi-generator/commonapi-generator/commonapi-generator-linux-x86 -sk ./fidl/HelloWorld.fidl
    hello$ ~/commonapi_someip_generator/commonapi-someip-generator-linux-x86 -ll verbose /fidl/HelloWorld.fdepl

    hello$ cd src-gen/v1/commonapi
    hello/src-gen/v1/commonapi$ ls -la

    ** generator는 JAVA 머신상에서 돌아감으로 JRE가 설치되어 있어야 동작함.. 설치방법 참조

    4.클라이언트 및 서비스 응용프로그램 작성

    • Create src and build directories
    hello$ mkdir src
    hello$ mkdir build
    hello$ ls
    >>> build  cgen  fidl  src  src-gen
    hello$ cd src
    src 디렉토리에 아래의 4개화일을 생성한다.
    • HelloWorldClient.cpp
    #include <iostream>
    #include <string>
    #include <unistd.h>
    #include </CommonAPI.hpp>
    #include <v1/commonapi/HelloWorldProxy.hpp>
      
    using namespace v1_0::commonapi;
      
    int main() {
        std::shared_ptr <CommonAPI::Runtime> runtime = CommonAPI::Runtime::get();
        std::shared_ptr<HelloWorldProxy<>> myProxy = runtime->buildProxy<HelloWorldProxy>("local", "test");
    
      
        std::cout << "Checking availability!" << std::endl;
        while (!myProxy->isAvailable())
            usleep(10);
        std::cout << "Available..." << std::endl;
      
        CommonAPI::CallStatus callStatus;
        std::string returnMessage;
        myProxy->sayHello("Bob", callStatus, returnMessage);
        std::cout << "Got message: '" << returnMessage << "'\n";
    
        return 0;
    } 
    • HelloWorldService.cpp
    #include <iostream>
    #include <thread>
    #include <CommonAPI/CommonAPI.hpp>
    #include "HelloWorldStubImpl.hpp"
    
    using namespace std;
    
    int main() {
         std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get();
         std::shared_ptr<HelloWorldStubImpl> myService = std::make_shared<HelloWorldStubImpl>();
         runtime->registerService("local", "test", myService);
         std::cout << "Successfully Registered Service!" << std::endl;
      
         while (true) {
             std::cout << "Waiting for calls... (Abort with CTRL+C)" << std::endl;
             std::this_thread::sleep_for(std::chrono::seconds(30));
         }
       
         return 0;
      }
    • HelloWorldStubImpl.hpp
    #ifndef HELLOWORLDSTUBIMPL_H_
    
    #define HELLOWORLDSTUBIMPL_H_
       
    
    #include <CommonAPI/CommonAPI.hpp>
    
    #include <v1/commonapi/HelloWorldStubDefault.hpp>
       
    
    class HelloWorldStubImpl: public v1_0::commonapi::HelloWorldStubDefault {
    
    public:
         HelloWorldStubImpl();
         virtual ~HelloWorldStubImpl();
         virtual void sayHello(const std::shared_ptr<CommonAPI::ClientId> _client, std::string _name, sayHelloReply_t _return);
    
    };
      
    
    #endif /* HELLOWORLDSTUBIMPL_H_ */

    • HelloWorldStubImpl.cpp
    #include "HelloWorldStubImpl.hpp"
    HelloWorldStubImpl::HelloWorldStubImpl() { }
    HelloWorldStubImpl::~HelloWorldStubImpl() { }
    void HelloWorldStubImpl::sayHello(const std::shared_ptr<CommonAPI::ClientId> _client, std::string _name, sayHelloReply_t _reply) {
        std::stringstream messageStream;
        messageStream << "Hello " << _name << "!";
        std::cout << "sayHello('" << _name << "'): '" << messageStream.str() << "'\n";
        _reply(messageStream.str());
    };

    5.빌드및 실행

    프로젝트 디렉토리(hello)에 아래 파일을 생성한다.
    • CMakeLists.txt

    cmake_minimum_required(VERSION 2.8)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -std=c++0x")
    include_directories(
        src-gen
        ~/work2/capicxx-core-runtime/include
        ~/work2/capicxx-someip-runtime/include
        ~/work2/vSomeIP/interface
    )
    link_directories(
        ~/work2/COMMONAPI
    )
    add_executable(HelloWorldClient
        src/HelloWorldClient.cpp
        src-gen/v1/commonapi/HelloWorldSomeIPProxy.cpp
        src-gen/v1/commonapi/HelloWorldSomeIPDeployment.cpp
    )
    target_link_libraries(HelloWorldClient CommonAPI CommonAPI-SomeIP vsomeip)
    add_executable(HelloWorldService
        src/HelloWorldService.cpp
        src/HelloWorldStubImpl.cpp
        src-gen/v1/commonapi/HelloWorldSomeIPStubAdapter.cpp
        src-gen/v1/commonapi/HelloWorldStubDefault.cpp
        src-gen/v1/commonapi/HelloWorldSomeIPDeployment.cpp
    )
    target_link_libraries(HelloWorldService CommonAPI CommonAPI-SomeIP vsomeip)

    • Build
    hello$ cd build
    hello/build$ cmake ..
    hello/build$ make




    Reference
    1. GENIVI Git hub : https://github.com/GENIVI
    2. CommonAPI C++ SOME/IP in 10 minutes( https://at.projects.genivi.org/wiki/pages/viewpage.action?pageId=5472320 )

    Orange Pi Lite 2 O/S 설치하기

    Orange Pi Lite 2의 O/S 이미지와 설치 파일 위치 ( http://www.orangepi.org/downloadresources/) 에서 필요한 파일들을 다운로드 받는다.


    기본적으로 메뉴얼 및 단말에 설치하고자 하는 이미지를 선택한다. 예를 들어 데비안을 선택하면 아래와 같이 나오고 구글드라이브나 메가크라우드, 바이두 크라우드에서 다운 받을수 있는 화면이 나온다.

    마음에 드는곳에서 다운받고, 화면 제일 하단에서 Win32DiskImager-0.9.5-binary 를 다운받아 압축을 해제하고 실행시킨다.

    위에서 다운받은 이미지(압축해제한)를 선택하고, 준비된 8GByte이상의 SD카드를 PC에 넣고 ‘Write”시킨다.

    Write가 끝나면 SD를 OrangePi에 넣고  전원을 넣으면 HDMI로 로그인 화면을 볼수 있다.
    ID와 PW는 O/S 이미지 다운받을때 적혀있던 root/orangepi를 사용한다.




    Ubuntu에서 어떤 종류의 package가 있는지 검사하는 방법

    리눅스에서 어떤 프로그램(package)가 있는지 검사할때 아래와 같이 apt-cache 명령을 쓴다
    $apt-cache search <key word>

    예를 들어 crossbuild-essential-armhf는 아는데 다른 종류의 크로스빌드툴은 어떤게 있는지 확인하고자 할때 다음과 같이 검색할 수 있다.
    @ubuntu:~$ apt-cache search build-essential
    
    build-essential - Informational list of build-essential packages
    crossbuild-essential-arm64 - Informational list of cross-build-essential packages
    crossbuild-essential-armhf - Informational list of cross-build-essential packages
    crossbuild-essential-powerpc - Informational list of cross-build-essential packages
    crossbuild-essential-ppc64el - Informational list of cross-build-essential packages
    devscripts - scripts to make the life of a Debian Package maintainer easier
    crossbuild-essential-armel - Informational list of cross-build-essential packages
    crossbuild-essential-s390x - Informational list of cross-build-essential packages
    dh-buildinfo - Debhelper addon to track package versions used to build a package
    sbuild - Tool for building Debian binary packages from Debian sources

    Ubuntu 사용중 Could not get lock /var/lib/dpkg/lock 오류 발생할 때

    E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
    
    E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

    우분투 사용중 위와 같은 오류가 발생하는 경우가 있다. 이경우는 /var/lib/dpkg/lock파일이 존재할때 생기는 문제로 아래와 같이 해당 파일을 지워주면 해결된다
    sudo rm /var/lib/apt/lists/lock
    
    sudo rm /var/cache/apt/archives/lock
    
    sudo rm /var/lib/dpkg/lock
    
    sudo dpkg --configure –a

    Linux 명령어

    ls 디렉토리의 내용을 보는 명령어
    lsusb 단말(컴퓨터)에 장착된 USB 디바이스의 목록을 보여준다. 부팅시 드라이버 오류등을 확인할 수 있다.
    modprobe 적재가능커널모듈(LKM)을 커널에 추가하거나 제거하는데 사용
    lsmod 리눅스 커널에있는 모듈들의 정보를 보여준다. 모듈명에서 확장자(.o, .so)는 표출하지 않는다
    insmod 커널의 모듈을 적재할 때 사용
    rmmod 커널에 적재되어있는 모듈을 내릴 때 사용
    dmesg 시스템 부팅메세지를 보여준다.
    uname 시스템의 정보를 출력
    passwd사용자의 패스워드를 재설정함

    Orange Pi - ssh로 로그인하기

    HDMI 연결할 상황이 안될 때 vnc나 ssh remote로 로그인할 수 있다.

    SSH 설치

    앞서 설치한 OS(ubuntu_lxde)에 이미 ssh가 깔려 있고, 위 명령을 입력했을때 몇개을 업그레이드하고 새로 몇개를 설치할꺼냐고 질의(Default Y)하면 그냥 Enter키를 치고 진행한다.
     $ apt-get install ssh
    설치가 끝나면 Orange Pi의 IP주소를 확인한다.
     $ ifconfig 

    위에서 나온 IP로 PC에서 접속할 수 있다. 여기에서는 PuTTy로 접속할 경우 아래와 같이 Host Name에 위에서 얻은 IP를 적고 Connection type에 SSH를 선택학고 열기를 누르면된다.

    처음 접속할 때 아래와 같이 SSH 호스트에 대한 신뢰성을 묻는 다이얼로그가 나온다 처음 한번만 나오며 다음 접속시 부터는 나오지 않으니 걱정말고 Y 클릭한다.

    로그인 아이디와 패스워드는 처음 설치한 이후로 바꾸지 않았을 경우 orangepi/orangepi이다.

    접속하는  sshd의 설정화일(/etc/ssh/sshd_config)을  수정 하려면 다음과 같이  /etc/ssh/sshd_config화일을 열어 파일을 수정한다.
     $ sudo nano /etc/ssh/sshd_config