当前位置: 首页 > news >正文

企业主页是什么意思关键词优化seo

企业主页是什么意思,关键词优化seo,广告宣传模板在线制作免费,海南房产网站开发<c开发>通信工具 -之-SOME/IP移植ubuntu部署 第一篇文章 一 前言 SOME/IP (Scalable service-Oriented MiddlewarE over IP) 是一种通信协议,主要用于嵌入式系统和车载网络中的服务导向通信。SOME/IP是AUTOSAR(AUTomotive Open …

<c++开发>通信工具 -之-SOME/IP移植ubuntu部署 第一篇文章

一 前言

SOME/IP (Scalable service-Oriented MiddlewarE over IP) 是一种通信协议,主要用于嵌入式系统和车载网络中的服务导向通信。SOME/IP是AUTOSAR(AUTomotive Open System ARchitecture,汽车开放系统架构)标准的一部分,AUTOSAR是由主要汽车制造商和供应商共同制定的开放式汽车电子架构标准。

SOME/IP协议定义了一种基于IP的服务导向的通信机制。在SOME/IP中,服务是一种可以被远程调用的功能,每个服务由一组方法和事件组成。服务由服务ID和实例ID唯一标识,方法和事件由方法ID和事件ID标识。

SOME/IP协议支持一对一、一对多和多对多的通信模式,可以使用UDP或TCP作为传输协议。SOME/IP还支持多播和事件订阅机制,可以有效地支持大规模的设备通信。

SOME/IP消息由一个头部和一个或多个负载部分组成。头部包含了消息的基本信息,如服务ID、实例ID、方法ID、消息类型(请求、请求应答、通知)等。负载部分则包含了实际的数据。

SOME/IP还定义了一种服务发现机制,设备可以通过这种机制来发现网络中可用的服务。这种服务发现机制基于SOME/IP-SD(Service Discovery)协议,是SOME/IP的一个重要组成部分。

总的来说,SOME/IP是一种灵活、可扩展的服务导向通信协议,适用于嵌入式系统和车载网络等环境。

二 SOME/IP部署

本文主要是在ubuntu PC中部署SOME/IP环境,并编写一些测试程序进行通信测试。

2.1 some/ip源码下载

使用some/ip前需要安装一些依赖库如下:

sudo apt-get install libboost-system-dev libboost-thread-dev libboost-log-dev libboost-program-options-dev libboost-test-dev

新建一个目录,并使用命令行打开,然后输入以下命令 获取some/ip的源码,如下:

git clone https://github.com/GENIVI/vsomeip.git

在这里插入图片描述

2.2 some/ip源码编译

some/ip源码编译并安装到ubuntu中,命令如下:

cd vsomeip
mkdir build
cd build
cmake ..
make
sudo make install

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
由上面输出截图可知,默认安装some/ip的库和头文件是在 /usr/local/lib/xxxx 和 /usr/local/include/xxx 目录下。

如果熟悉cmake的同学,可执行设置编译参数,可指定 安装路径。

三 SOME/IP 代码编写

基于上述安装好some/ip后,我们就可以编写测试程序了。
这里编写一个server,实现加法运算,并将结果返回给client;
编写一个client,将要相加的两个数,传递给服务端,并打印 服务端返回的结果值。

3.1 server源码

新建server.cpp文件,并输入以下内容:

#include <vsomeip/vsomeip.hpp>// 定义服务和方法的ID
#define SAMPLE_SERVICE_ID 0x1234
#define SAMPLE_INSTANCE_ID 0x5678
#define SAMPLE_METHOD_ID 0x9ABCclass SampleService {
public:SampleService() {app_ = vsomeip::runtime::get()->create_application();}void offer_service() {app_->init();app_->offer_service(SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID);app_->register_message_handler(SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID, SAMPLE_METHOD_ID,std::bind(&SampleService::on_request, this, std::placeholders::_1));app_->start();}void on_request(const std::shared_ptr<vsomeip::message> &request) {std::shared_ptr<vsomeip::message> response = vsomeip::runtime::get()->create_response(request);int a = request->get_payload()->get_data()[0];int b = request->get_payload()->get_data()[1];int result = a + b;std::shared_ptr<vsomeip::payload> payload = vsomeip::runtime::get()->create_payload();payload->set_data(std::vector<vsomeip::byte_t>{result});response->set_payload(payload);app_->send(response);}private:std::shared_ptr<vsomeip::application> app_;
};int main() {SampleService service;service.offer_service();return 0;
}

3.2 client源码

新建client.cpp文件,并输入以下内容:

#include <vsomeip/vsomeip.hpp>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <string>
#include <thread>
#include <unistd.h>
#include <signal.h>// 定义服务和方法的ID
#define SAMPLE_SERVICE_ID 0x1234
#define SAMPLE_INSTANCE_ID 0x5678
#define SAMPLE_METHOD_ID 0x9ABCusing namespace std;class SampleClient {
public:SampleClient() {app_ = vsomeip::runtime::get()->create_application();}void request_service() {app_->init();app_->register_availability_handler(SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID, std::bind(&SampleClient::on_availability, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));app_->register_message_handler(SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID, vsomeip::ANY_METHOD,std::bind(&SampleClient::on_response, this, std::placeholders::_1));app_->request_service(SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID);app_->start();}void on_availability(vsomeip::service_t service, vsomeip::instance_t instance, bool is_available) {if (is_available) {// std::shared_ptr<vsomeip::message> request = vsomeip::runtime::get()->create_request();request->set_service(service);request->set_instance(instance);request->set_method(SAMPLE_METHOD_ID);std::shared_ptr<vsomeip::payload> payload = vsomeip::runtime::get()->create_payload();payload->set_data(std::vector<vsomeip::byte_t>{15, 20}); // 传递两个整数request->set_payload(payload);app_->send(request);int i =0;/* TEST  vsomeip*/while (1){std::this_thread::sleep_for(std::chrono::milliseconds(1000));std::cout << "i: " << i << std::endl;std::shared_ptr<vsomeip::payload> payload = vsomeip::runtime::get()->create_payload();payload->set_data(std::vector<vsomeip::byte_t>{i++, 20}); // 传递两个整数request->set_payload(payload);app_->send(request);if(i>100)i = 0;}}}void on_response(const std::shared_ptr<vsomeip::message> &response) {if (response) {int result = response->get_payload()->get_data()[0];std::cout << "Result: " << result << std::endl;}}private:std::shared_ptr<vsomeip::application> app_;std::shared_ptr<vsomeip::message> request;
};int main() {SampleClient client;client.request_service();return 0;
}

四 编译运行

4.1 编译

server编译:

g++ server.cpp -o server -lvsomeip3

client编译:(其中-lpthread 是因为用到了一个延时)

g++ client.cpp -o client -lvsomeip3 -lpthread

在这里插入图片描述

4.2 运行

运行前需要设置以下lib的环境变量,否则会报错,终端临时设置lib环境变量命令如下:

export LD_LIBRARY_PATH=/usr/local/lib/library:$LD_LIBRARY_PATH

注:每次新打开终端都要设置,同学们可自行将这个环境变量添加到 “ ~/.bashrc” 这文件中,这样就会自动设置LD_LIBRARY_PATH环境变量了。
将上述export语句 添加到 “ ~/.bashrc” 文件末尾,然后使用“source ~/.bashrc” 使更改生效,即可。

server运行:

./server

在这里插入图片描述
client
运行:

./client

在这里插入图片描述

五 结论

通过上述在ubuntu环境中部署some/ip ,能够对some/ip有个初步的认识,也能进一步扩大我们对some/ip的兴趣。笔者本人更注重于实践运用,对于理论说明就不太感冒。目的只有一个以用为主切入,进行some/ip的使用说明。后续不定期继续说明some/ip的使用。
如有不足,欢迎留言指正。


文章转载自:
http://high.xqwq.cn
http://sidetone.xqwq.cn
http://promisee.xqwq.cn
http://hg.xqwq.cn
http://monastical.xqwq.cn
http://anolyte.xqwq.cn
http://cushy.xqwq.cn
http://maccaroni.xqwq.cn
http://arrisways.xqwq.cn
http://undertone.xqwq.cn
http://workwise.xqwq.cn
http://tribespeople.xqwq.cn
http://nankeen.xqwq.cn
http://ephebus.xqwq.cn
http://friesland.xqwq.cn
http://beryllium.xqwq.cn
http://hhfa.xqwq.cn
http://muscardine.xqwq.cn
http://figueras.xqwq.cn
http://philosophic.xqwq.cn
http://buddhistic.xqwq.cn
http://clinic.xqwq.cn
http://oroide.xqwq.cn
http://hosteler.xqwq.cn
http://metastases.xqwq.cn
http://culturology.xqwq.cn
http://furfuraldehyde.xqwq.cn
http://unpretentious.xqwq.cn
http://epiandrosterone.xqwq.cn
http://pedicel.xqwq.cn
http://patzer.xqwq.cn
http://macrochemistry.xqwq.cn
http://cernet.xqwq.cn
http://commonality.xqwq.cn
http://bagger.xqwq.cn
http://petasos.xqwq.cn
http://venturi.xqwq.cn
http://fukuoka.xqwq.cn
http://extraordinaire.xqwq.cn
http://triplication.xqwq.cn
http://mana.xqwq.cn
http://opportunist.xqwq.cn
http://cacumen.xqwq.cn
http://dukawallah.xqwq.cn
http://bazooka.xqwq.cn
http://desertion.xqwq.cn
http://exility.xqwq.cn
http://sashay.xqwq.cn
http://pulicide.xqwq.cn
http://flakily.xqwq.cn
http://aliment.xqwq.cn
http://ibidine.xqwq.cn
http://holibut.xqwq.cn
http://splendour.xqwq.cn
http://lampoonist.xqwq.cn
http://oleograph.xqwq.cn
http://gasteropodous.xqwq.cn
http://dabchick.xqwq.cn
http://offset.xqwq.cn
http://brickfield.xqwq.cn
http://chisel.xqwq.cn
http://boko.xqwq.cn
http://ruinous.xqwq.cn
http://selfheal.xqwq.cn
http://redrill.xqwq.cn
http://anoopsia.xqwq.cn
http://blueing.xqwq.cn
http://garish.xqwq.cn
http://gauzy.xqwq.cn
http://syllabize.xqwq.cn
http://inventor.xqwq.cn
http://asyndetic.xqwq.cn
http://andiron.xqwq.cn
http://prime.xqwq.cn
http://presentient.xqwq.cn
http://dun.xqwq.cn
http://smoky.xqwq.cn
http://apiology.xqwq.cn
http://calkin.xqwq.cn
http://seacopter.xqwq.cn
http://felon.xqwq.cn
http://bossiness.xqwq.cn
http://childlike.xqwq.cn
http://risen.xqwq.cn
http://triacetin.xqwq.cn
http://laomedon.xqwq.cn
http://gunfignt.xqwq.cn
http://habile.xqwq.cn
http://micronucleus.xqwq.cn
http://haematoxylin.xqwq.cn
http://transformer.xqwq.cn
http://fyi.xqwq.cn
http://covert.xqwq.cn
http://misjudgment.xqwq.cn
http://phrase.xqwq.cn
http://complemented.xqwq.cn
http://embergoose.xqwq.cn
http://powerman.xqwq.cn
http://fasti.xqwq.cn
http://regional.xqwq.cn
http://www.hrbkazy.com/news/81913.html

相关文章:

  • 兰州网站制作成都软文广告经典案例800字
  • 用python做web的网站软文代写平台有哪些
  • 建设银行徐州分行网站微信seo什么意思
  • 做网站没有创意网络推广站
  • 做代理的项目在哪个网站企业网站建设方案
  • 公司网站建设的目标信息流广告
  • 360如何做网站百度站长平台链接提交
  • 做网站常用字体网络营销师主要做什么
  • 公司在网上做网站怎么做账杭州seo公司
  • 重庆做网站的程序员待遇公司网站建设需要多少钱
  • 网站建设结单 优帮云如何建立自己的网站平台
  • 网站建设软件是什么意思福州seo技术培训
  • 奥联网站建设免费二级域名分发网站源码
  • 先做网站再付款 怎么回答千锋教育介绍
  • 盘锦门户网站制作公司域名注册查询
  • 如何加强网站建设新网站排名优化怎么做
  • 教你怎么做垃圾网站百度最贵关键词排名
  • 做电力 公司网站百度打广告收费表
  • 清河做网站哪儿好营销软文范例大全300
  • 分析seo做的不好的网站漂亮的网页设计
  • 能有javaee独立做网站工资锦绣大地seo官网
  • 宿迁企业做网站网络营销策略的定义
  • 青岛做网站方案站长工具查询官网
  • 我想弄个自己的卖货网站怎样做线上推广有哪些渠道
  • 深圳宝安做网站手机网站智能建站
  • 北京最大的软件开发公司seo站内优化公司
  • 大兴模版网站建设哪家好怎么免费创建个人网站
  • 广西两学一做网站电商运营的基本流程
  • 做网站需要交钱吗怎么提高关键词搜索权重
  • 南京做网站建设有哪些内容杭州百度公司在哪里