Network

CommonAPI(2) - fidl / fdepl

hunger626 2025. 5. 27. 14:24

Overview

CommonAPI를 사용하기 위해서는 CommonAPI Generator를 통해서 fidl 파일을 통해 proxy와 stub 코드를 생성해야 한다.

fidl 파일은 자체 문법으로 작성되기 때문에 COVESA에서 제공하는 Sample을 토대로 작성하면 규칙성을 찾을 수 있을것이다.

마찬가지로 fdepl도 사용해야 하는데 이는 네트워크 바인딩 설정을 위한 파일로 사용되기 때문에 fidl파일과 필수로 사용해야 한다.

 

 

FIDL

Sample

아래는 COVESA에서 제공하는 Sample 중 하나인 HelloWorld 예제의 fidl 파일의 내용이다.

출처 : capicxx-core-tools/CommonAPI-Examples/E01HelloWorld/fidl/E01HelloWorld.fidl at master · COVESA/capicxx-core-tools · GitHub

 

capicxx-core-tools/CommonAPI-Examples/E01HelloWorld/fidl/E01HelloWorld.fidl at master · COVESA/capicxx-core-tools

Common API C++ core tools. Contribute to COVESA/capicxx-core-tools development by creating an account on GitHub.

github.com

/* Copyright (C) 2015 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package commonapi.examples

interface E01HelloWorld {
    version { major 0 minor 1 }

    method sayHello {
        in {
            String name
        }
        out {
            String message
        }
    }
}

 

method는 C++에서는 Function 명이 되고 in 값은 송수신 할 데이터 포멧이 된다. out은 송신 성공시 return 받을 데이터(응답)가 된다.

 

 

응용

Sample fidl 파일을 응용하여 메시지를 송수신 가능한 프로그램을 만들기 위해 직접 fidl파일을 작성해보겠다.

package commonapi

interface TestMessage {

version {major 1 minor 0}
    
    struct Message {
    	UInt16 shortMsg
        UInt32 intMsg
        UInt64 longMsg
        String strMsg
    }
    
    method sendMessage {
    	in {
        	Message msg
        }
        out {
        	Boolean success
        }
   }
}

 

송신 할 데이터를 Struct로 구성하여 in에서 해당 구조체만 전송하면 되도록 구성,

송신 성공 시 bool 값을 return 하여 송신하는 쪽에서 true/false로 확인 가능하도록 구성하였다.

 

 

 

FDEPL

Sample

fidl 파일과 마찬가지로 fdepl도 Sample에서 제공하고 있다.

출처 : capicxx-core-tools/CommonAPI-Examples/E01HelloWorld/fidl/E01HelloWorld-SomeIP.fdepl at master · COVESA/capicxx-core-tools · GitHub

 

capicxx-core-tools/CommonAPI-Examples/E01HelloWorld/fidl/E01HelloWorld-SomeIP.fdepl at master · COVESA/capicxx-core-tools

Common API C++ core tools. Contribute to COVESA/capicxx-core-tools development by creating an account on GitHub.

github.com

/* Copyright (C) 2015 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
import "platform:/plugin/org.genivi.commonapi.someip/deployment/CommonAPI-4-SOMEIP_deployment_spec.fdepl"
import "E01HelloWorld.fidl"

define org.genivi.commonapi.someip.deployment for interface commonapi.examples.E01HelloWorld {
    SomeIpServiceID = 4660

    method sayHello {
        SomeIpMethodID = 30000
        SomeIpReliable = true
        
        in {
            name {
                SomeIpStringEncoding = utf16le
            }
        }
    }
}

define org.genivi.commonapi.someip.deployment for provider as Service {
    instance commonapi.examples.E01HelloWorld {
        InstanceId = "commonapi.examples.HelloWorld"
        
        SomeIpInstanceID = 22136
    
        SomeIpUnicastAddress = "192.168.0.2"
        SomeIpReliableUnicastPort = 30499
        SomeIpUnreliableUnicastPort = 30499
    }
}

vsomeip 기반이기 때문에 MethodID와 InstanceID를 설정 해 주는것을 볼 수 있다.

 

응용

직접 작성한 fidl파일을 기반으로 한 fdepl도 작성해보겠다.

import "platform:/plugin/org.genivi.commonapi.someip/deployment/CommonAPI-SOMEIP_deployment_spec.fdepl"
import "TestMessage.fidl"

define org.genivi.commonapi.someip.deployment for interface commonapi.TestMessage {
	SomeIpServiceID = 100
    method sendMessage {
    	SomeIpMethodID = 10000
    }
}

define org.genivi.commonapi.someip.deployment for provider as Service {
	instance commonapi.TestMessage {
    	InstanceId = "commonapi.TestMessage"
        SomeIpInstanceID = 100
    }
}

바인딩에 필요한 ID들을 임의로 지정해서 할당하였고, method 명은 fidl파일을 참고하여 동일하게 설정 해 주었다.

'Network' 카테고리의 다른 글

Netfilter  (7) 2025.07.16
VLAN (Virtual LAN)  (0) 2025.06.09
CommonAPI(4) - Service / Client  (0) 2025.05.27
CommonAPI(3) - commonapi generator  (0) 2025.05.27
CommonAPI(1) - 준비  (0) 2025.05.27