Android生成Java AIDL

news2024/9/22 7:21:39

AIDL:Android Interface Definition Language

AIDL是为了实现进程间通信而设计的Android接口语言

Android进程间通信有多种方式,Binder机制是其中最常见的一种

AIDL的本质就是基于对Binder的运用从而实现进程间通信

这篇博文从实战出发,用一个尽可能精简的Demo,实现两个App(也是两个进程:服务端mainapp、客户端otherapp)通过AIDL的跨进程通信

一.创建两个App


按照下列步骤先创建两个App:

(1).新建一个开发文件夹(本Demo中命名为aidl-test)

(2).使用AndroidStudio在aidl-test文件夹下创建第一个Empty Activity的空App:mainapp

为了后续方便起见

创建完成后,把Studio默认创建的MainActivity.java名字改一下,改成MainAppActivty.java

(3).创建第二个Empty Activity的空App:otherapp

两个空App创建完成了:

二.在mainapp中创建一个Service

上一节中新建了两个空App:mainappotherapp

现在就先在mainapp中实现一个service

使用方便又快捷的studio创建MainAppService.java

 

可以看到新建的MainAppService会自动实现一个onBind(Intent intent)方法,这个方法后续我会在其中进行代码实现,它需要在其他进程连接到Service时,返回一个继承了android.os.Binder的对象

先在 MainAppActivity 和 MainAppService 中添加一些必要的生命周期函数代码
再在 MainAppService 中添加:
onBind(Intent intent):被客户端绑定时执行
onUnbind(Intent intent):被客户端解绑时执行

@com/android/mainapp/MainAppActivity.java


package com.android.mainapp;
 
import androidx.appcompat.app.AppCompatActivity;
 
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
 
public class MainAppActivity extends AppCompatActivity {
    private String TAG = "AIDL-MainAppActivity";
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.v(TAG, "onCreate()");
        setContentView(R.layout.activity_main);
    }
 
    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.v(TAG, "onDestroy()");
    }
}
@com/android/mainapp/MainAppService.java 


package com.android.mainapp;
 
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;
 
public class MainAppService extends Service {
    private String TAG = "AIDL-MainAppService";
 
    public MainAppService() {
    }
 
    @Override
    public void onCreate() {
        super.onCreate();
    }
 
    @Override
    public void onStart(Intent intent, int startId) {
        Log.v(TAG, "onStart()");
    }
 
    @Override
    public IBinder onBind(Intent intent) {
        // TODO: Return the communication channel to the service.
        throw new UnsupportedOperationException("Not yet implemented");
    }
 
    @Override
    public boolean onUnbind(Intent intent) {
        Log.v(TAG, "onUnbind()");
        return true;
    }
 
    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.v(TAG, "onDestroy()");
    }
}

三.mainapp中实现AIDL

依然使用方便又快捷的AndroidStudio在mainapp的main目录下创建一个名为IAppAidlInterface.aidl 的AIDL文件

 

AndroidStudio创建 IAppAidlInterface.aidl 会自动实现一个默认的可用于进程间传参通信的void basicTypes(...)函数,其参数是java的几种基础数据类型

除此之外,AIDL还支持多种其他数据类型:byte、short、char、charSequence、 List、 Map等

除了AndroidStudio自动创建的basicTypes(...)函数,我在AIDL文件里面再新增一个setData(..)函数,用于后面跨进程的数据传输,虽然使用AndroidStudio自动生成的basicTypes(...)也是可以的,但是自己创建一个函数会更具有代表性.

在本篇博文最开始就阐述过,AIDL的本质是对Binder的运用,从而实现进程间通信

那么现在Binder在哪呢?

IAppAidlInterface.aidl文件创建之后,build一下工程,AndroidStudio会在build目录下创建一个aidl_source_output_dir文件夹,同时在这个文件夹下创建与IAppAidlInterface.aidl包名、文件名相同的文件夹目录和java文件

IAppAidlInterface.java文件中通过继承android.os.Binder创建一个抽象的代理类stub,这个stub抽象代理类主要做如下几件事:

通过stub自身实例实现进程内部的通信
通过实现一个内部代理类Porxy用于跨进程通信
重写Binder中的onTransact()函数,实现AIDL接口文件中声明的函数进行数据传输
传输的数据必须是序列化的android.os.Parcel类型数据 

 

当然,如果项目需要对AIDL的Binder实现过程进行自定义封装,方便项目中对进程间通信机制进行定制化,那么,完全可以不采用AndroidStudio自动生成的IAppAidlInterface.java,只须要按照自己的需要实现IAppAidlInterface.java中对Binder进程间通信的实现过程就行了

因为归根结底,AIDL实现进程间通信的基础就是Binder机制,只要使用Binder实现AIDL进程间通信的目的就可以了

IAppAidlInterface.java就先讨论到这里,这篇博文主要是对AIDL的使用进行研究,其对Binder机制的实现与封装不在此做深入探讨

后续会专门开一篇博文讲解AIDL对Binder机制的内部实现,以及用户如何自定义封装

四.otherapp中也实现AIDL


上一节中,作为服务端的mainapp里创建了一个AIDL文件,客户端的otherapp中也需要实现一份相同的AIDL,要不然客户端就无法引用到了对应的函数和stub等了

很简单,把mainapp中的AIDL文件整个包名目录直接拷贝到otherapp中即可,然后再build一下工程

 

接下来,需要添加一些代码,实现客户端otherapp与服务端mainapp的相连

五.mainapp中添加代码


前文中已经展示过,MainAppService会随着MainAppActivity的onCreate()和onDestroy()生命周期startService()和stopService()

mainapp中要添加的代码在MainAppService.java中,需要在MainAppService中做下面一些事情:

  • 使用匿名内部类实现IAppAidlInterface.Stub抽象类,用于实现IAppAidlInterface.aidl中的接口函数和onBinder()时返回匿名内部类实例
  • onBinder()中启动一个线程,每1秒轮循接收客户端发送过来的数据

 这里提到个题外的知识点,Service中除了onBinder()函数外还有个onRebind()函数

      如果同一客户端每次unBindService()之后再bindService()并且发送的Intent也一样,那么onBind()就只会在服务端第一次被这个客户端连接时才执行,后续重连时都不会再执行了。

     而onRebind()在服务端第一次被连接时不会被执行,但是之后每次重连都会执行,不论Intent是否一样。

    如果想要onBind()在同一客户端连接时都能执行,客户端在每次bindService()时,改变发送Intent的type或其他成员变量就行了

定义一个string变量用于接收客户端传过来的字符串,定义一个boolean变量用于控制线程

AndroidMainfest.xml中为MainAppService添加Service标签

六.otherapp中添加代码

otherapp里面主要需要做如下几件事:

  • 新建一个Intent,用于连接服务端mainapp
    IntentComponent设置为Sevice的包名和类名
  • 新建两个button,用于控制bindService()绑定和unbindService()解绑
  • 重写Service连接和断开的两个基础函数onServiceConnected()onServiceDisconnected()
  • AndroidMainfest.xml中添加查询包名权限,以便otherapp可以查询到mainapp,或者直接指定查询mainapp的包名

 

七.运行、验证 

到此,一个最基础的使用AIDL实现两个App(服务端mainapp、客户端otherapp)之间通信的demo代码就完成了,下面我们来验证一下。

编译、安装apk:

项目build Apk后会生成两个apk,两个都install上

 

运行验证:

注:本demo中代码的所有日志TAG都加上了AIDL前缀,方便日志打印验证

先启动一下mainapp,MainAppService不会被启动但是会被注册到系统,因为在mainapp的AndroidMainfest.xml中对MainAppService进行了Service标签添加。

 

退出mainapp后,再打开otherapp:

现在执行几次"Bind Service"和"Unbind Service",就会看到如下日志打印:

好,通过这个精简Demo,初步实现了两个App通过AIDL的跨进程通信 

 

八.源代码

接下来逐一展示实现的源码

mainapp源码:

D:\Codes\aidl-test\app\src\main\aidl\com\android\mainapp\IAppAidlInterface.aidl

// IAppAidlInterface.aidl
package com.android.mainapp;
 
// Declare any non-default types here with import statements
 
interface IAppAidlInterface {
    /**
     * Demonstrates some basic types that you can use as parameters
     * and return values in AIDL.
     */
    void basicTypes(int anInt, long aLong, boolean aBoolean, float aFloat,
            double aDouble, String aString);
 
    void setStringData(String strData);
}

 

D:\Codes\aidl-test\app\src\main\java\com\android\mainapp\MainAppActivity.java

package com.android.mainapp;
 
import androidx.appcompat.app.AppCompatActivity;
 
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
 
public class MainAppActivity extends AppCompatActivity {
    private String TAG = "AIDL-MainAppActivity";
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.v(TAG, "onCreate()");
        setContentView(R.layout.activity_main);
    }
 
    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.v(TAG, "onDestroy()");
    }
}

D:\Codes\aidl-test\app\src\main\java\com\android\mainapp\MainAppService.java

package com.android.mainapp;
 
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
 
public class MainAppService extends Service {
    private String TAG = "AIDL-MainAppService";
 
    private String mStrData;
    private boolean mSetServiceRunning = true;
 
    public MainAppService() {
    }
 
    @Override
    public void onCreate() {
        super.onCreate();
        Log.v(TAG, "onStart()");
    }
 
    @Override
    public void onStart(Intent intent, int startId) {
        Log.v(TAG, "onStart()");
    }
 
    IAppAidlInterface.Stub mStub = new IAppAidlInterface.Stub() {
        @Override
        public void basicTypes(int anInt, long aLong, boolean aBoolean, float aFloat, double aDouble, String aString) throws RemoteException {
 
        }
 
        @Override
        public void setStringData(String strData) {
            mStrData = strData;
        }
    };
 
    @Override
    public IBinder onBind(Intent intent) {
        Log.v(TAG, "onBind()");
        mSetServiceRunning = true;
 
        new Thread() {
            @Override
            public void run() {
                super.run();
                while (mSetServiceRunning) {
                    try {
                        Thread.sleep(1000);
                        Log.v(TAG, "mStrData:"+mStrData);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }.start();
 
        return mStub;
    }
 
    @Override
    public boolean onUnbind(Intent intent) {
        Log.v(TAG, "onUnbind()");
        mSetServiceRunning = false;
        return true;
    }
 
    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.v(TAG, "onDestroy()");
    }
}

D:\Codes\aidl-test\app\src\main\AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">
 
    <application
        android:allowBackup="true"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:fullBackupContent="@xml/backup_rules"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.Mainapp"
        tools:targetApi="31">
        <service
            android:name=".MainAppService"
            android:enabled="true"
            android:exported="true">
        </service>
 
        <activity
            android:name=".MainAppActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
 
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
 
            <meta-data
                android:name="android.app.lib_name"
                android:value="" />
        </activity>
    </application>
 
</manifest>

 

otherapp源码: 

D:\Codes\aidl-test\otherapp\src\main\aidl\com\android\mainapp\IAppAidlInterface.aidl

// IAppAidlInterface.aidl
package com.android.mainapp;
 
// Declare any non-default types here with import statements
 
interface IAppAidlInterface {
    /**
     * Demonstrates some basic types that you can use as parameters
     * and return values in AIDL.
     */
    void basicTypes(int anInt, long aLong, boolean aBoolean, float aFloat,
            double aDouble, String aString);
 
    void setStringData(String strData);
}

D:\Codes\aidl-test\otherapp\src\main\java\com\android\otherapp\OtherAppMainActivity.java

package com.android.otherapp;
 
import androidx.appcompat.app.AppCompatActivity;
 
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
import android.view.View;
 
import com.android.mainapp.IAppAidlInterface;
 
public class OtherAppMainActivity extends AppCompatActivity implements View.OnClickListener, ServiceConnection {
    private String TAG = "AIDL-OtherAppActivity";
 
    private int mICount = 0;
    private Intent mServiceIntent;
    private IAppAidlInterface mBinder;
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_other_app_main);
 
        mServiceIntent = new Intent();
        mServiceIntent.setComponent(new ComponentName("com.android.mainapp", "com.android.mainapp.MainAppService"));
 
        findViewById(R.id.btnBindMainAppService).setOnClickListener(this);
        findViewById(R.id.btnUnBindMainAppService).setOnClickListener(this);
    }
 
    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.btnBindMainAppService: {
                Log.v(TAG, "onClick():btnBindMainAppService");
                bindService(mServiceIntent, this, Context.BIND_AUTO_CREATE);
            }
            break;
 
            case R.id.btnUnBindMainAppService: {
                Log.v(TAG, "onClick():btnUnBindMainAppService");
                unbindService(this);
                mBinder = null;
            }
            break;
        }
    }
 
    @Override
    public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
        if (mBinder == null) {
            mBinder = IAppAidlInterface.Stub.asInterface(iBinder);
            mICount++;
            Log.v(TAG, "onServiceConnected() 第 " + mICount + " 次");
            try {
                String strData = "第" + mICount + "次连接Service成功!";
                mBinder.setStringData(strData);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        }
    }
 
    @Override
    public void onServiceDisconnected(ComponentName componentName) {
        Log.v(TAG, "onServiceDisconnected");
    }
}

 

D:\Codes\aidl-test\otherapp\src\main\res\layout\activity_other_app_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".OtherAppActivity">
 
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAllCaps="false"
        android:text="OtherApp"/>
 
    <Button
        android:id="@+id/btnBindMainAppService"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAllCaps="false"
        android:text="Bind  Service" />
 
    <Button
        android:id="@+id/btnUnBindMainAppService"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAllCaps="false"
        android:text="UnBind Service" />
 
</LinearLayout>

D:\Codes\aidl-test\otherapp\src\main\AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
 
    <!--<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>-->
    <queries>
        <package android:name="com.android.mainapp"/>
    </queries>
 
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.Mainapp">
        <activity
            android:name=".OtherAppMainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
 
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
 
            <meta-data
                android:name="android.app.lib_name"
                android:value="" />
        </activity>
    </application>
 
</manifest>

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2127359.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

openssl的使用

1、编译 Github下载&#xff1a;https://github.com/openssl/openssl 官网下载&#xff1a;https://openssl-library.org/source/index.html 官网历史版本&#xff1a;https://www.openssl.org/source/old/ 1.1 Windows下编译 我的文章&#xff1a;OPC UA使用 Openssl库编译…

Golang | Leetcode Golang题解之第398题随机数索引

题目&#xff1a; 题解&#xff1a; type Solution []intfunc Constructor(nums []int) Solution {return nums }func (nums Solution) Pick(target int) (ans int) {cnt : 0for i, num : range nums {if num target {cnt // 第 cnt 次遇到 targetif rand.Intn(cnt) 0 {ans …

移动跨平台框架Flutter详细介绍和学习线路分享

Flutter是一款移动应用程序SDK&#xff0c;一份代码可以同时生成iOS和Android两个高性能、高保真的应用程序。 Flutter目标是使开发人员能够交付在不同平台上都感觉自然流畅的高性能应用程序。我们兼容滚动行为、排版、图标等方面的差异。 在全世界&#xff0c;Flutter正在被越…

基于SpringBoot+Vue+MySQL的滑雪场管理系统

系统展示 用户前台界面 管理员后台界面 系统背景 在快速发展的冰雪运动热潮下&#xff0c;为了提升滑雪场的管理效率与顾客体验&#xff0c;我们设计并实现了一套基于SpringBoot后端框架、Vue前端框架以及MySQL数据库的滑雪场管理系统。该系统旨在通过数字化手段&#xff0c;优…

(pandas读取DataFrame列报错)raise KeyError(key) from err KeyError: (‘name‘, ‘age‘)

&#xff08;pandas读取DataFrame列报错&#xff09;raise KeyError(key) from err KeyError: (‘name‘, ‘age‘) 欢迎来到英杰社区https://bbs.csdn.net/topics/617804998 欢迎来到我的主页&#xff0c;我是博主英杰&#xff0c;211科班出身&#xff0c;就职于医疗科技公司&…

瑞吉外卖—读写分离

文章目录 1. 概述2. MySQL主从复制2.1 介绍2.1 配置2.1.1 前置条件2.1.2 主库Master2.1.3 从库Slave 3. 读写分离案例3.1 背景3.2 Sharding-JDBC介绍3.3 入门案例 1. 概述 读写分离、主从复制。就是dml操作在主库、query操作在备份的从库。分担压力&#xff0c;减轻单点故障。…

标准库标头 <barrier>(C++20)学习

此头文件是线程支持库的一部分。 类模板 std::barrier 提供一种线程协调机制&#xff0c;阻塞已知大小的线程组直至该组中的所有线程到达该屏障。不同于 std::latch&#xff0c;屏障是可重用的&#xff1a;一旦到达的线程组被解除阻塞&#xff0c;即可重用同一屏障。与 std::l…

django自用教程

编程软件: pycharm django介绍:django是Pythonweb的一个框架&#xff0c;是用来构建网站的工具。 要想使用django&#xff0c;首先需要下载django模块&#xff0c;通过使用以下代码实现: pip install django 安装完成后&#xff0c;在django的目录下有一个文件django-admin&am…

Docker启动Mysql镜像报错问题?

docker中启动mysql镜像报错如下&#xff1a;ls: cannot access /docker-entrypoint-initdb.d/: Operation not permitted 百度上查到了很多解决方案&#xff0c;也咨询了很多大佬&#xff0c;加权限&#xff0c;改用户&#xff0c;均无果。最终在阿里巴巴上找到了解决方案&…

【有啥问啥】深入理解数据结构 Merkle 树:数据完整性保障的基石

深入理解 Merkle 树&#xff1a;数据完整性保障的基石 在当今的分布式系统和区块链应用中&#xff0c;数据的完整性验证变得至关重要。随着区块链技术、分布式存储系统&#xff08;如 IPFS&#xff09;、以及版本控制系统&#xff08;如 Git&#xff09;的大规模应用&#xff…

【Linux】文件权限与类型全解:你的文件安全指南

欢迎来到 CILMY23 的博客 &#x1f3c6;本篇主题为&#xff1a;文件权限与类型全解&#xff1a;你的文件安全指南 &#x1f3c6;个人主页&#xff1a;CILMY23-CSDN博客 &#x1f3c6;系列专栏&#xff1a;Python | C | C语言 | 数据结构与算法 | 贪心算法 | Linux | 算法专题…

kubectl 命令介绍以及使用

文章目录 kubectl 基本命令查看集群信息管理命名空间操作节点 操作 Pods查看 Pods 状态创建和删除 Pods调试 Pods 操作 Deployments创建 Deployment更新 Deployment回滚 Deployment 操作 Services暴露服务查看服务状态 更多 kubectl 命令资源描述资源过滤日志查看配置上下文和切…

热门语音转文字工具大比拼

现在工作、生活的节奏越来越快&#xff0c;很多时候会议上并没有充足的时间来记录会议内容&#xff0c;最快捷的方式就是用录音来记录每一个观点。录音文件后期转化为文字需要花费大力气吗&#xff1f;并不是&#xff0c;现在有着讯飞语音转文字这类高速高效的转换工具可以轻松…

PMP–一、二、三模–分类–13.干系人管理--技巧--1、干系人分析

文章目录 二模13.干系人管理--干系人分析--题干关键词 “干系人信息&#xff08;权力、角色、利益、关系、态度、影响……&#xff09;、识别完干系人、某干系人抵制项目”。5、 [单选] 一家公司启动了一个与开发新服务相关的项目&#xff0c;而该公司并不具有此类专业知识。项…

分布式集群下如何做到唯一序列号

优质博文&#xff1a;IT-BLOG-CN 分布式架构下&#xff0c;生成唯一序列号是设计系统常常会遇到的一个问题。例如&#xff0c;数据库使用分库分表的时候&#xff0c;当分成若干个sharding表后&#xff0c;如何能够快速拿到一个唯一序列号&#xff0c;是经常遇到的问题。实现思…

【AI赋能医学】基于深度学习和HRV特征的多类别心电图分类

一、数据集简介 论文中使用了来自三类不同心电图记录的162条数据&#xff0c;这些数据来自三个公开的数据库&#xff1a; MIT-BIH 心律失常数据库 (ARR) 96条记录&#xff0c;主要包含不同类型的心律失常样本。 MIT-BIH 正常窦性心律数据库 (NSR) 36条记录&#xff0c;包含健…

【springboot】简易模块化开发项目整合MyBatis-plus

接父子工程项目搭建&#xff0c;继续扩展项目 重新调整模块结构 1.删除子模块fast-demo-web中所有无用内容 2.右键fast-demo-web名称->新建&#xff08;news&#xff09;->模块&#xff08;Module&#xff09;&#xff0c;创建新的子模块 3.选择新建Maven工程 4.新建模…

STMCubeMX文件下载后会出现其他项目无法下载的问题

一、问题 二、解决方法 ①、对箭头所指处画√ ②、按住复位键不要松开&#xff0c;你点击下载&#xff0c;1s左右松开即可发现可以重新下载了

计算机毕业设计 教务管理系统 Java+SpringBoot+Vue 前后端分离 文档报告 代码讲解 安装调试

&#x1f34a;作者&#xff1a;计算机编程-吉哥 &#x1f34a;简介&#xff1a;专业从事JavaWeb程序开发&#xff0c;微信小程序开发&#xff0c;定制化项目、 源码、代码讲解、文档撰写、ppt制作。做自己喜欢的事&#xff0c;生活就是快乐的。 &#x1f34a;心愿&#xff1a;点…

GD32F4开发 -- JLink使用

之前写过 STM32开发 – Jlink常用命令 &#xff0c;今天遇到需要SEGGER RTT 配置&#xff0c;就再写一下吧。 一、下载并安装JLink 下载&#xff1a; J-Link / J-Trace Downloads 可选择需要的版本下载&#xff1a; 二、SEGGER RTT 包含文件 得到 SEGGER_RTT_V794m.zip …