c#实验五 文件与流

2023-05-16

实验五 文件与流

WPF还不太会...抄STZG的,其他自己写的。

一、实验目的

  1. 掌握文件类的使用;
  2. 掌握文件流的操作;
  3. 掌握二进制数据、文本数据的读写;
  4. 继续应用WPF技术进行界面编程。

二、实验内容

  1. 要求用户输入一个目录名。

如果输入的是有效目录,列出该目录下所有文件和目录:对于目录,名字用[]括起来;对于文件,在文件名后用三个数字加一个字母表示其文件大小,如123B, 123K, 123M等。

提示:可使用右移操作符>>。

using System;

using System.IO;

namespace ConsoleApp1

{

    class Program

    {

        static void Main(string[] args)

        {

            string path = Console.ReadLine();///输入的根目录

            if (!Directory.Exists(path))

            {

                Console.WriteLine("当前路径不存在");

                return;

            }

            dfs(path,0);

        }

        static void dfs(string path,int spaces)///当前所在路径

        {

            for(int i = 0; i < spaces; i++)

            {

                Console.Write(" ");

            }

            Console.WriteLine("["+path+"]:");///输出当前目录

            DirectoryInfo root = new DirectoryInfo(path);///当前路径下的所有文件

            FileInfo[] files = root.GetFiles();

           

            foreach(var i in files)

            {

                for (int j = 0; j < spaces+4; j++) Console.Write(" ");

                Console.Write("该目录下文件:"+i);

                Console.WriteLine(" " + CountSize(i.ToString()) );

                ///输出文件大小

            }

            DirectoryInfo[] dics = root.GetDirectories();

            for(int i = 0; i < dics.Length; i++)

            {

                dfs(dics[i].ToString(), spaces + 10);

            }

            return;

        }

        static string CountSize(string sFullName)

        {

            long lSize = 0;

            if (File.Exists(sFullName))

                lSize = new FileInfo(sFullName).Length;

            string m_strSize = "";

            long FactSize = lSize;

            if (FactSize < 1024.00)

                m_strSize = String.Format("{0:N3}", FactSize) + "B";

            else if (FactSize >= 1024.00 && FactSize < 1048576)

                m_strSize = String.Format("{0:N3}", FactSize >> 10) + "K";

            else if (FactSize >= 1048576 && FactSize < 1073741824)

                m_strSize = String.Format("{0:N3}", FactSize >> 20) + "M";

            else if (FactSize >= 1073741824)

                m_strSize = String.Format("{0:N3}", FactSize >> 30) + "G";

            return m_strSize;

        }

    }

}

Update(2021.6.29):奇怪的是之前这么做可以读出来的,现在在dfs里面每次要加上之前路径的前缀...

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string path = "E:\\HB";
            //string path = Console.ReadLine();///输入的根目录
            if (!Directory.Exists(path))
            {
                Console.WriteLine("当前路径不存在");
                return;
            }
            Console.WriteLine(path);
            dfs(path, 0);
            Console.ReadKey();
        }
        static void dfs(string path, int spaces)///当前所在路径
        {
            for (int i = 0; i < spaces; i++)
            {
                Console.Write(" ");
            }
            Console.WriteLine("[" + path + "]:");///输出当前目录

            DirectoryInfo root = new DirectoryInfo(path);///当前路径下的所有文件
            
            
            FileInfo[] files = root.GetFiles();

            foreach (var i in files)
            {
                for (int j = 0; j < spaces + 4; j++) Console.Write(" ");
                Console.Write("该目录下文件:" + i);
                Console.WriteLine(" " + CountSize( (path+"\\"+i).ToString()));/*之前做实验是没写"//"就可以了...现在怎么不加异常了*/
                ///输出文件大小
            }

            DirectoryInfo[] dics = root.GetDirectories();
            for (int i = 0; i < dics.Length; i++)
            {
                dfs((path+"\\"+dics[i]).ToString(), spaces + 10);/*之前做实验是没写"//"就可以了...现在怎么不加异常了*/
            }

            return;
        }
        static string CountSize(string sFullName)
        {
            long lSize = 0;
            if (File.Exists(sFullName))
                lSize = new FileInfo(sFullName).Length;

            string m_strSize = "";
            long FactSize = lSize;
            if (FactSize < 1024.00)
                m_strSize = String.Format("{0:N3}", FactSize) + "B";
            else if (FactSize >= 1024.00 && FactSize < 1048576)
                m_strSize = String.Format("{0:N3}", FactSize >> 10) + "K";
            else if (FactSize >= 1048576 && FactSize < 1073741824)
                m_strSize = String.Format("{0:N3}", FactSize >> 20) + "M";
            else if (FactSize >= 1073741824)
                m_strSize = String.Format("{0:N3}", FactSize >> 30) + "G";
            return m_strSize;
        }

    }
}

  1. 在Code目录下存放着一些文件。遍历该目录,统计其中各个接口的出现次数,分别打印各文件中使用量居前5的接口及次数。现假定接口名称都如IList、ICacheManager

1)接口名称的最主要特征:以I字符开头,第二字符大写。要求:不包含<,如IList<string>应只计IList;以“//”开头的注释不参与统计。

2)按照目录à文件à行à单词à字符的层次关系,逐步深入。

目录:目录名、Directory或DirectoryInfo

文件:文件名、File或FileInfo

行:StreamReader.ReadLine()

单词:String的Split()方法

字符:String[0]

3)接口及对应次数可用Dictionary<string, int>保存,其中的string类型的“键”保存接口名称,int类型的“值”保存该接口的次数。

可使用ContainsKey、TryGetValue、Add或索引符来添加、访问和修改键值对。注意:如果用索引符访问不存在的键会抛出异常,所以在访问之前应试探该值是否存在。

4)字典中的值可用Values属性访问,它可转换为List,然后可排序,访问其中的最大值。

using System;

using System.Collections.Generic;

using System.Diagnostics.CodeAnalysis;

using System.IO;

namespace ConsoleApp2

{

    class Program

    {

        static Dictionary<string, int> map1 = new Dictionary<string, int>();

        class P:IComparable<P>

        {

            public string Name { get; set; }

            public int val { get; set; }

            public int CompareTo(P other)

            {

                return other.val.CompareTo(this.val);

            }

        }

        public static void Main(string[] args)

        {

            string path = "E:\\C#代码\\第五次实验\\Code";

            GetDirectory(path);

           

        }

        static void GetDirectory(string path)

        {

            DirectoryInfo root = new DirectoryInfo(path);///当前路径下的所有文件

            Console.WriteLine("当前目录" + root);

            GetFile(root);

        }

        static void GetFile(DirectoryInfo root)

        { 

            FileInfo[] files = root.GetFiles();

            foreach (var i in files)

            {

               

                Console.Write("   ");

                Console.WriteLine("该目录下文件:" + i);

               

                Getline(i.ToString());

             

            }

        }

        static void Getline(string Filename)

        {

            StreamReader sr = new StreamReader(Filename);

            string line;

           

            map1.Clear();

            while ( (line=sr.ReadLine())!=null ){///读文件的每一行

                GetWord(line);

            }

            List<P> list = new List<P>();

            foreach (var j in map1)

            {

                P now = new P();

                now.Name = j.Key; now.val = j.Value;

                list.Add(now);

            }

            list.Sort();

            Console.WriteLine("用到最多的"+Math.Min(5,list.Count)+"个接口");

            for (int j = 0; j < Math.Min(5, list.Count); j++)

            {

                Console.WriteLine(list[j].Name + "    " + list[j].val);

            }

        }

        static void GetWord(string line)

        {

            String[] str = line.Split();///每一行分割成单词

            foreach(var i in str)

            {

                GetByte(i);

            }

           

        }

        static void GetByte(string str)///利用map进行统计

        {

            if (str.Length < 2) return;

            if (str[0] == '/' && str[0] == '/') return;

            if (str[0] != 'I') return;

            if (!(str[1] >= 'A' && str[1] <= 'Z')) return;

                          

            int pre = str.Length; int suf = 0;

            for(int i = 0; i < str.Length; i++)

            {

                if (pre == str.Length&&str[i]=='<')

                {

                    pre = i;

                }

                if (suf == 0 && str[i] == '>')

                {

                    suf = i;

                }

            }

            string temp = "";

            for (int i = 0; i < pre; i++)

            {

                temp += str[i];

            }

            Console.WriteLine(temp);

            if (!map1.ContainsKey(temp))

            {

                map1.Add(temp, 1);

            }

            else

            {

                map1[temp]++;

            }

        }

    }

}

  1. 写一个记事本程序:

(1)设计界面,向窗体添加下拉式菜单、文本框、打开文件对话框、保存文件对话框。

(2)依次为“文件”下的“新建”、“打开”、“保存”菜单项的Click事件添加事件处理函数。

(3)实现文本文件的打开、编辑和保存功能;

提示:

(1)    窗口可用DockPanel进行布局,让菜单和工具栏都位于顶部,即:

DockPanel.Dock="Top"。

(2)    文本文件的显示与编辑可以使用TextBox控件。

(3)    使用命令绑定,让菜单项和工具栏同时与一个操作相关联。

在MainWindow.xaml的Window标签下加:

    <Window.CommandBindings>

        <CommandBinding Command="ApplicationCommands.New" Executed="NewCommand_Executed"/>

        <CommandBinding Command="ApplicationCommands.Open" Executed="OpenCommand_Executed"/>

        <CommandBinding Command="ApplicationCommands.Save" Executed="SaveCommand_Executed"/>

    </Window.CommandBindings>

在菜单项添加:

                <MenuItem Header="新建(_N)" Command="New"/>

在工具栏添加:

            <Button Content="新建" Command="New"/>

就可绑定命令。同时Ctrl+O等键盘组合也默认与Open命令相绑定。

(4)    添加bool类型_saved字段,标记当前内容是否已保存。

(5)    打开文件时,弹出打开文件对话框,操作代码如下:

            OpenFileDialog dlg = new OpenFileDialog();

            dlg.DefaultExt = "*.txt";

            dlg.Filter = "Text Files (*.txt)|*.txt";

            bool? result = dlg.ShowDialog();

            if (result == true)

            {

                string fileName = dlg.FileName;

自此可对该文件名进行操作。

(6)    保存文件时,实际可实现“另存为”功能。弹出保存文件对话框,操作代码如下:

            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter = "文本文件|*.txt|所有文件|*.*";

            saveFileDialog.FilterIndex = 0;

            bool? result = saveFileDialog.ShowDialog();

            if (result == true)

            {

                string strFile = saveFileDialog.FileName;

自此可对该文件名进行操作。

<Window x:Class="WpfApp1.MainWindow"

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

        xmlns:local="clr-namespace:WpfApp1"

        mc:Ignorable="d"

        Title="记事本" Height="450" Width="800">

    <Window.CommandBindings>

        <CommandBinding Command="ApplicationCommands.New" Executed="NewCommand_Executed"/>

        <CommandBinding Command="ApplicationCommands.Open" Executed="OpenCommand_Executed"/>

        <CommandBinding Command="ApplicationCommands.Save" Executed="SaveCommand_Executed"/>

        <CommandBinding Command="ApplicationCommands.Print" Executed="PrintCommand_Executed"/>

    </Window.CommandBindings>

    <DockPanel>

        <DockPanel.Resources>

            <Style TargetType="{x:Type Button}" x:Key="formatTextStyle">

                <Setter Property="FontFamily" Value="Palatino Linotype"></Setter>

                <Setter Property="Width" Value="30"></Setter>

                <Setter Property="FontSize" Value ="14"></Setter>

                <Setter Property="CommandTarget" Value="{Binding ElementName=MainTextBox}"></Setter>

            </Style>

            <Style TargetType="{x:Type Button}" x:Key="formatImageStyle">

                <Setter Property="Width" Value="30"></Setter>

                <Setter Property="CommandTarget" Value="{Binding ElementName=MainTextBox}"></Setter>

            </Style>

        </DockPanel.Resources>

        <Menu x:Name="MainMenu" DockPanel.Dock="Top">

            <MenuItem Header="文件">

                <MenuItem Header="新建(_N)" Command="New"/>

                <MenuItem Header="打开(_O)" Command="Open"/>

                <MenuItem Header="保存(_S)" Command="Save"/>

                <MenuItem Header="打印(_P)" Command="Print"/>

            </MenuItem>

            <MenuItem Header="格式">

                <MenuItem Header="自动换行(_W)"/>

                <MenuItem Header="字体(_F)"/>

            </MenuItem>

        </Menu>

        <RichTextBox x:Name="MainTextBox" DockPanel.Dock="Top" Height="300" TextChanged="MainTextBox_TextChanged"  AcceptsTab="True">

            <FlowDocument>

                <Paragraph>

                    <Run></Run>

                </Paragraph>

            </FlowDocument>

        </RichTextBox>

        <StatusBar DockPanel.Dock="Bottom">

            <TextBlock x:Name="MainStatusBar"></TextBlock>

        </StatusBar>

    </DockPanel>

</Window>

using System;

using System.Collections.Generic;

using System.IO;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Data;

using System.Windows.Documents;

using System.Windows.Input;

using System.Windows.Media;

using System.Windows.Media.Imaging;

using System.Windows.Navigation;

using System.Windows.Shapes;

using Microsoft.Win32;

namespace WpfApp1 {

public partial class MainWindow : Window

{

    private bool _saved;

    private string title

    {

        set { Title = value; }

        get { return Title; }

    }

    public MainWindow()

    {

        InitializeComponent();

    }

    private void NewCommand_Executed(object sender, ExecutedRoutedEventArgs e)

    {

        _saved = false;

        TextRange range;

        range = new TextRange(MainTextBox.Document.ContentStart, MainTextBox.Document.ContentEnd);

        range.Text = "";

    }

    private void OpenCommand_Executed(object sender, ExecutedRoutedEventArgs e)

    {

        OpenFileDialog dlg = new OpenFileDialog();

        dlg.DefaultExt = "*.txt";

        dlg.Filter = "Text Files (*.txt)|*.txt";

        bool? result = dlg.ShowDialog();

        string str = null;

        if (result == true)

        {

            string _fileName = dlg.FileName;

            TextRange range;

            FileStream fStream;

            if (File.Exists(_fileName))

            {

                title = _fileName;

                range = new TextRange(MainTextBox.Document.ContentStart, MainTextBox.Document.ContentEnd);

                fStream = new FileStream(_fileName, FileMode.OpenOrCreate);

                range.Load(fStream, DataFormats.XamlPackage);

                fStream.Close();

            }

        }

    }

    private void SaveCommand_Executed(object sender, ExecutedRoutedEventArgs e)

    {

        if (_saved)

        {

            return;

        }

        SaveFileDialog saveFileDialog = new SaveFileDialog();

        saveFileDialog.Filter = "文本文件|*.txt|所有文件|*.*";

        saveFileDialog.FilterIndex = 0;

        bool? result = saveFileDialog.ShowDialog();

        if (result == true)

        {

            string strFile = saveFileDialog.FileName;

            TextRange range;

            FileStream fStream;

            range = new TextRange(MainTextBox.Document.ContentStart, MainTextBox.Document.ContentEnd);

            fStream = new FileStream(strFile, FileMode.Create);

            range.Save(fStream, DataFormats.XamlPackage);

            fStream.Close();

            _saved = true;

            MainStatusBar.Text = "保存到" + strFile;

        }

    }

    private void PrintCommand_Executed(object sender, ExecutedRoutedEventArgs e)

    {

        PrintDialog pd = new PrintDialog();

        if ((pd.ShowDialog() == true))

        {

            //use either one of the below

            pd.PrintVisual(MainTextBox as Visual, "printing as visual");

            pd.PrintDocument((((IDocumentPaginatorSource)MainTextBox.Document).DocumentPaginator), "printing as paginator");

        }

    }

    private void MainTextBox_TextChanged(object sender, TextChangedEventArgs e)

    {

        _saved = false;

    }

    private void LineCommand_Executed(object sender, ExecutedRoutedEventArgs e)

    {

    }

    private void FontSelectCommand_Executed(object sender, ExecutedRoutedEventArgs e)

    {

    }

}

}

  1. 附加:如果还没有选定期末大作业,可使用下面这一题目:(本次实验可不上交,会在超星上新建一个大作业上交,有时间的同学可尝试这个练习)

运用WPF技术,模仿Windows 10系统中计算机器(Calculator)程序,开发一个类似程序。

至少完成:

1)可执行四则运算;

2)数值和运算符按钮采用不同的样式;

加分项:

1)计算机器功能的完整性,如暂存功能、算式列表等;

2)是否使用了数据绑定、模板、样式、依赖项属性等特性;

3)注释和文档;

4)其它功能上的创新。

三、实验心得与体会

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

c#实验五 文件与流 的相关文章

  • HP-SOCKET学习笔记(一)

    介绍 HP Socket是一套通用的高性能TCP UDP HTTP 通信框架 xff0c 包含服务端组件 客户端组件和Agent组件 xff0c 广泛适用于各种不同应用场景的TCP UDP HTTP通信系统 xff0c 提供C C 43 4
  • curl断点续载

    curl断点续传 xff0c 下载过程中关闭控制台 xff0c 然后重新启动 xff0c 又会接着下载 include 34 stdafx h 34 include lt io h gt include 34 curl curl h 34
  • curl多线程下载实现

    其实libcurl自带一个应用 xff0c 很高大上 xff0c 但是作为范例参考怎么使用libcurl觉得不大适合 xff01 还是写一些helloworl的程序的 xff0c 一目了然 include 34 stdafx h 34 in
  • arduino实现tts

    淘宝上查了一下 xff0c 目前的几款tts模块貌似指令格式类似 Blink Turns on an LED on for one second then off for one second repeatedly This example
  • openwrt编译error: ext4_allocate_best_fit_partial: failed to allocate 13 blocks, out of space?

    编译openwrt时候报如下错误 xff1a Creating filesystem with parameters Size 50331648 Block size 4096 Blocks per group 32768 Inodes p
  • 在mac上创建鼠标双击可执行的shell脚本

    总是觉得mac权限管理好严格 xff0c 要创建向在window上执行bat那样的脚本需要如下操作 首先创建测试脚本 touch clickexe sh open e clickexe sh 在脚本中输入内容 echo 34 hello w
  • rm: cannot remove Permission denied 问题解决方法

    今天编译openwrt系统的时候 xff0c 碰到这样的问题 rm cannot remove xxx Permission denied 但是又不允许用root用户执行 xff0c 所以就要用root用户去修改权限 chmod 777 如
  • Arduino 舵机驱动板编程

    需要下载Adafruit的arduino库 xff0c 这个网上搜索一下很多 我的驱动板是16路基于I2C接口通信 xff0c 这个arduino库底层都做好了 xff0c 精度是12位 xff08 4096 xff09 设置非常简单 xf
  • 3d图形引擎结构

    其实3d引擎结构基本上都是类似的 xff0c 差别也只是细节的上的差别 xff0c 如jme引擎的结构如下 xff1a 首先是viewport xff0c 这个就像2d图层一样 xff0c 每个viewport开始渲染的时候都可以清除缓冲区
  • 树莓派开机启动frpc

    直接在 rc local里启动frpc失败 xff0c 原因是网络好像连接失败 所以写了个shell脚本 xff0c 通过sleep延时一下 xff0c 就启动成功了 首先建立startfrp sh bin bash cd home pi
  • esp32 arduino psram使用

    esp32 arduino固件是已经支持psram了的 xff0c 是模式2 xff0c 所以要使用heap caps malloc来分配 注意选择wrover modelus xff0c 其他的可能驱动不支持 示例代码 xff1a inc
  • 事件驱动框架(二)——状态机

    事件驱动框架 xff08 二 xff09 说明 本篇接上一篇事件驱动框架之后 xff0c 介绍状态机的原理相关的 xff0c 以及事件驱动框架下事件处理状态机的实现 因为代码大多还是参照QP源码 xff0c 所以仅供学习使用 有限状态机介绍
  • 小米10如何安装google play商店

    查了一下网上说可以安装gmail 小米商店就会自动安装google play的 xff0c 但是发现gmail在小米商店已经提示说 因为软件本身问题不能给安装 34 xff0c 查了一无果 xff0c 于是用之前华为安装google的apk
  • php 上传目录权限问题导致无法上传

    php除了有大小严格限制导致失败 xff0c 还有就是上传目录权限问题导致失败 xff0c 如果权限问题执行以下命令即可 sudo chown R www data www data Users George Desktop uploads
  • KeilC STM32添加.c .h文件的方法

    嵌入式初学者添加 c h文件是可能会出现 h头文件无法生效的问题 xff0c 在此将本人经历总结如下 xff0c 供大家参考 1 xff0c 把所需添加的文件 xff0c 放到这个文件夹下 项目名称 Core Src 2 xff0c 右击此
  • 传感器——ATGM332D 北斗定位模块

    NO 8 模型用GPS测速仪 xff08 已完成 xff09 xff08 更新第二版本 xff09 这个是用显示屏显示的 定位精度2 5m GPS模块VCC Arduino的5v GPS模块GND Arduino的GND GPS模块TXD
  • stm32f10--- 学习日志2021-07-10

    不知道标题是啥 xff0c 学到什么记录什么 寄存器占四个字节 偏移地址 xff1a 0x04 基地址 xff1a 0x4001 1000叫做GPIOC的基地址 APB2外设时钟使能寄存器 0x4002 1018 单片机认为它只是一个数值
  • 【unp】unix网络编程卷1-->环境搭建(ubuntu14.04)

    学习unp网络编程 xff0c 树上的例子均存在 include 34 unp h 34 xff0c 故需要对环境进行配置 1 到资源页下载unpv13e 2 解压并将unpv13e 移动到相应的文件夹下 3 编译 gt cd unpv13
  • 北醒激光雷达模组 资料汇总

    目录 1 文档说明1 1 北醒单点系列雷达激光模组相关资料1 2 北醒面阵系列雷达激光模组相关资料1 2 1 产品基本介绍1 2 2 Benewake 北醒 短距 TF LC02 2m资料整理1 2 3 Benewake 北醒 短距 TF
  • TFmini Plus在开源飞控PX4上的应用

    TFmini Plus在开源飞控PX4上的应用 PX4有着自己独特的优势 xff0c 受到广大爱好者的喜爱 TFmini Plus是北醒公司推出的性价比极高的激光雷达 xff0c 受到广大爱好者的追捧 本文介绍TFmini Plus和PX4

随机推荐

  • Benewake TFmini-S\TFmimi Plus\TFluna\TF02-Pro 串口版本雷达在STM32的例程

    目录 文档说明北醒串口标准通讯协议硬件接线Lidar通讯代码1 初始化USART1 2 开启USART1的空闲中断 3 USART2 IRQHandler增加中断判断4 中断处理函数 xff0c 用于接收雷达数据 协议处理注 xff1a 换
  • 使用CH341 I2C连接北醒TF系列I2C模式 Python例程

    目录 硬件接线 xff1a 源码结果输出 本文介绍了北醒单点系列雷达IIC模式下使用CH341芯片转接板读取雷达数据的例程 例程下载 xff1a 链接 https pan baidu com s 1KVJ fINxUgKZny2Gdi8T2
  • 蓝牙nrf51822程序的分析(一)

    蓝牙nrf51822程序的分析 一 最近继续用NRF51822开发一个东西 无奈之前没接触过蓝牙 连蓝牙串口模块也没有 所以对蓝牙的基础知识不够 xff0c 后面看了之后接着补充 花了2天时间把提供的NRF51822的程序大致看明白了 xf
  • 常用Arduino板介绍

    目录 NANO板介绍烧录说明 UNO板介绍烧录说明 Pro mini板介绍烧录说明 DUE板介绍烧录说明 NANO板介绍 概述 xff1a Arduino Nano是一款基于ATMega328P xff08 Arduino Nano 3 x
  • Modbus设备在Modbus scan上面的使用方法

    操作教程 参数 xff1a DeviceID xff1a 485从站 寄存器地址 xff1a 查询设备地址表 北醒雷达Dist在0x0000开始 读取寄存器长度 xff1a 雷达数据长度值 格式 xff1a MODBUS RTU 串口协议
  • Raspberry Pi Pico C/C++语言在Windows环境下开发环境搭建 Raspberry Pi Pico C/C++ SDK

    目录 前言Raspberry Pi Pico介绍需要支持的软件软件安装配置及注意事项ARM GCC compiler的安装CMake的安装Git 安装Visual Studio 2019的安装Visual Studio Code的配置Pyt
  • 【LoRa32U4II】介绍以及基于Arduino IDE编译环境搭建及测试

    目录 LoRa 模块LoRa32u4 II介绍LoRa32u4 II 资料下载LoRa32u4 II 规格介绍LoRa32u4 II 脚位说明 编译环境介绍电脑系统编译软件Arduino需求库 编译环境搭建及测试LoRa32u4 II 测试
  • 【Benewake(北醒) 】短距 TF-LC02 2m资料整理

    目录 1 TF LC02简要说明1 1 性能参数1 2产品图片及尺寸 2 运用2 1 在开源板Arduino上的运用2 2 在Python上的应用 1 TF LC02简要说明 1 1 性能参数 1 2产品图片及尺寸 2 运用 2 1 在开源
  • 【Arduino】Benewake(北醒) TF-LC02(TTL)基于Arduino 开发板运用说明

    目录 前言Benewake 北醒 TF LC02产品简要说明Arduino开发板介绍Benewake 北醒 TF LC02 接口及通讯协议说明接口定义串口协议说明通讯协议说明功能码说明 接线示意图例程说明配置软硬串口定义获取TOF数据的结构
  • 【Benewake(北醒) 】中距 TF02-i 40m工业版本CAN/485介绍以及资料整理

    目录 1 前言2 产品介绍3 产品快速测试3 1 产品规格书及使用说明书3 2 通用指令串口助手使用说明3 3 产品快速测试说明 4 基于开源硬件的运用整理4 1 在开源飞控上的运用 5 基于其他的运用整理5 1 在PLC上的运用说明5 2
  • 【ESP32 DEVKIT_V1】基于Arduino IDE环境搭建

    目录 一 前言二 板子介绍三 环境搭建1 Arduino IDE的安装2 在Arduino IDE上添加外包链接3 添加好外包链接后就可以下载对应的板子库文件 测试1 先把开发板接到电脑 xff0c 并在Arduino IDE上选择对应的开
  • 【ESP32 DEVKIT_V1】北醒TF系列雷达在ESP32 DEVKIT_V1开发板上的运用

    目录 前言一 硬件准备二 硬件接线说明串口接线示意图 xff1a I2C接先示意图 三 软件搭建及测试1 使用Arduino IDE编译教程2 使用vsCode 43 Arduino教程2 1 在vsCode上使用Arduino的环境搭建2
  • 【vsCode + Arduino】在Visual Studio Code编译Arduino项目

    目录 前言一 参考文档二 操作步骤2 1 安装Arduino IDE2 2 在vsCode里安装Arduino插件2 3 配置arduino的安装路径2 4 配置好后打开一个Arduino的项目文件夹进行相应的配置 三 目前已知问题 前言
  • 蓝牙:GATT,属性,特性,服务

    接着上一篇 通用属性配置文件 xff08 Generic Attribute Profile xff09 1 GATT简介 通用属性配置文件Generic Attribute Profile简称GATT GATT定义了属性类型并规定了如何使
  • RS232 RS422 RS485详细介绍

    1 RS 232 C RS 232 C是美国电子工业协会EIA xff08 Electronic Industry Association xff09 制定的一种串行物理接口标准 RS是英文 推荐标准 的缩写 xff0c 232为标识号 x
  • stm32串口使用以及串口中断接收不定长度字符串

    开始使用cubemx配置PA9 PA10分别为TX RX端 xff0c 在使能串口中断 之后其余值直接使用默认的就可以了 点击生成代码即可 span class token class name uint8 t span rx buff s
  • STM32-串口通信printf重定向

    前言 xff1a 平时我们进行c语言编程的时候会经常用到printf函数进行打印输出 xff0c 来调试代码 可是这个printf函数C库已经帮我们实现好了 xff0c 通常只需要直接调用即可 xff0c 但是如果在一个新的开发平台 xff
  • FMCW毫米波雷达原理

    Radar系列文章 传感器融合是将多个传感器采集的数据进行融合处理 xff0c 以更好感知周围环境 xff1b 这里首先介绍毫米波雷达的相关内容 xff0c 包括毫米波雷达基本介绍 xff0c 毫米波雷达数据处理方法 xff08 测距测速测
  • VMware虚拟机安装ubuntu16.04系统教程

    对于没有接触过Ubuntu系统的小伙伴来说 xff0c 直接在物理机上安装Ubuntu单系统或者windows Ubuntu双系统一件比较刺激的事情 xff0c 因为一不小心可能就会把电脑整崩溃 xff0c 或者出现各种问题 xff0c 所
  • c#实验五 文件与流

    实验五 文件与流 WPF还不太会 抄STZG的 xff0c 其他自己写的 一 实验目的 掌握文件类的使用 xff1b 掌握文件流的操作 xff1b 掌握二进制数据 文本数据的读写 xff1b 继续应用WPF技术进行界面编程 二 实验内容 要