Frankie's blog


  • 首页

  • 归档

我的Visual Studio Code插件介绍

发表于 2021-02-03 | 分类于 工具

Sublime Text Keymap and Settings Importer

Sublime Text

其实这个看跟人爱好,我是从Sublime Text 3过来的,所以保留了以前快捷键的使用习惯。关于这两种编辑器对比,总的来说Sublime Text 3更轻量级,打开文件速度还是很快的。

Better Comments

Better Comments

效果看上图中红框部分,会让你的代码注释更漂亮,看着更舒服

file-icons

file-icons

效果看上图中红框部分,其实就是根据类型在文件前面显示文件图标

psioniq File Header

psioniq File

  • 看上图中红框部分,用处就是在新建文件中插入文件头,快捷键是按两次ctrl+alt+H

  • 动画演示
    psioniq File2

  • 分享一下我的模板,使用方式是去到Settings->User(or Workspace)->Extensions->psioniq File Header->Templates->Edit in settings.json
    然后copy以下代码。其中User和Workspace的区别,就是User是全局设置,Workspace是当前项目工程设置。

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    "psi-header.templates": [
    {
    "language": "*",
    "template": [
    "@file <<filename>>",
    "@version 1.0.0",
    "@date <<filecreated('YYYY-MM-DD')>>",
    "@author FrankieLuo",
    " ",
    "@brief ",
    " ",
    "@note ",
    " ",
    "@copyright Copyright (C) <<year>> HomeIntelligence Co., Ltd. All rights reserved."
    ]
    },
    ],

Doxygen Documentation Generator

doxygen generator

  • 直接动画演示,输入/**,然后回车
    doxygen generator

koroFileHeader

koroFileHeader

这个是国人做的插件,也可以自动产生文件头和函数头,可玩性也很高

markdownlint

markdownlint

这个就是写markdown文档时候的语法提示

Markdown PDF

Markdown PDF

  • 这个插件的作用就是可以导出pdf, html, png, jpeg等,直接点右键就可以导出
    doxygen generator

Bookmarks

Bookmarks

  • 看代码的时候会在代码中多次跳转,嵌套层数过多肯定晕球,这个插件的作用就是记录浏览代码路径,
    快捷键是ctrl+alt+k
  • 下面动画演示整个过程
    doxygen generator

Todo Tree

Todo Tree

  • 写代码中经常有部分功能以后再写再调,这时候我们会写上TODO标记一下以后再做。
  • 点击左边TODO Tree图标,可以展示整个工程的TODO项
    Todo Tree 2

vscode-pdf

vscode-pdf

这个插件其实就是vscode中直接打开PDF文件

介绍一款简单实用的MacOS下的串口工具COMTool

发表于 2021-02-01 | 分类于 工具

COMTool是一款用python写的跨平台串口调试助手,功能简单实用,界面如下

ComTool Basic

特性

  • 跨平台,但依赖python
  • 可以设置hex或asscii发送和接收
  • 有发送的记录,方便调试

传送门

  • https://github.com/Neutree/COMTool/releases/download/v1.7.9/comtool_v1.7.8.dmg
  • https://github.com/Neutree/COMTool/tags

串口工具Docklight的进阶使用

发表于 2021-01-20 | 分类于 工具

Docklight对分析Uart串口通讯协议非常有帮助,本文讲解一些进阶用法,特别对于通配符?, #的理解。完整工程后的效果图如下

Sequence Basic

Docklight Send/Receive Sequence List

  1. 打开新建的Docklight工程, 点击Edit -> Edit Send Sequence List | Edit Receive Sequence List

    Sequence Basic

  2. 如上图,填写协议命令项的名字,数据格式,协议项完整数据.

  3. 对于可变的数据,用通配符?代替

    Sequence variable data

  4. 对于可变长度,用通配符#代替,可以尽可能多填一些#

    Sequence variable data

    • 复制上面命令数据为(Hex格式):AA 00 ?? 05 ?? ?? ?? ?? ?? ?? ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## 00 ??
    • 以上数据为蓝牙模块通讯协议中的接收到蓝牙Name
    • 数据格式依次为数据头-AA, 数据长度-00 ??, 命令字-05, 蓝牙地址-6bytes, 蓝牙名字-长度可变, 名字结尾字符-00, Checksum-??
    • 对于上面蓝牙名字字段,应为是不固定长度,可以多填#

通配符的一些解释

Two types of wildcards are available in Docklight(两种通配符)

  1. Wildcard ‘?’ : Matches exactly one arbitrary character (any ASCII code between 0 and 255) - 匹配一个ASCII字符(0-255)

  2. Wildcard ‘#’ : Matches zero or one character. This is useful for supporting variable length command arguments (e.g. a status word) in Send / Receive Sequences. See Checking for sequences with random characters or Sending commands with parameters for examples and additional information. - 匹配最多一个或者0个字符,见上面蓝牙接收名字例子

How to install PPTP Service on ubuntu

发表于 2020-12-30 | 分类于 开发

Setup PPTP server

  • Install PPTP Service

    # sudo apt-get install pptpd

  • Configure PPTPD

    # sudo nano /etc/pptpd.conf

    Add server IP and client IP at the end of the file. You can add like below:

    1
    2
    localip 192.168.0.1
    remoteip 192.168.0.100-200
  • DNS configuration

    # sudo nano /etc/ppp/pptpd-options

    Uncomment the ms-dns and add google like below or OpenDNS:

    1
    2
    ms-dns 8.8.8.8
    ms-dns 8.8.4.4
  • User secret configuration

    # sudo nano /etc/ppp/chap-secrets

    The column is username. Second column is server name, you can put “pptpd” in there. Third column is password. The last column is the IP addresses, you can put * to allow all IP.

    1
    2
    # client        server  secret                  IP addresses
    username * myPassword *

Setup IP Forwarding

  • To enable IPv4 forward. Change /etc/sysctl.conf file, add forward rule below.

    # sudo nano /etc/sysctl.conf

  • Uncomment the line

    net.ipv4.ip_forward=1

  • Then reload the configuration

    sudo sysctl -p

  • Add forward rule in iptables

    # sudo nano /etc/rc.local

  • adding to the bottom just before the exit 0

    1
    2
    iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j MASQUERADE
    iptables -A FORWARD -p tcp --syn -s 192.168.0.0/24 -j TCPMSS --set-mss 1356

Create NAT rules in firewall

To make PPTP clients talk to each other, we add the following rules to the firewall.

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Your should replace “eth0” with your ethernet node name.

Restart server

sudo service pptpd restart

Reference

  • https://help.ubuntu.com/community/PPTPServer
  • https://bobcares.com/blog/install-pptp-server-ubuntu/

诗词赏析

发表于 2020-12-03 | 分类于 生活

将进酒

  • 李白〔唐代〕

君不见,黄河之水天上来,奔流到海不复回。

君不见,高堂明镜悲白发,朝如青丝暮成雪。

人生得意须尽欢,莫使金樽空对月。

天生我材必有用,千金散尽还复来。

烹羊宰牛且为乐,会须一饮三百杯。

岑夫子,丹丘生,将进酒,杯莫停。

与君歌一曲,请君为我倾耳听。

钟鼓馔玉不足贵,但愿长醉不愿醒。

古来圣贤皆寂寞,惟有饮者留其名。

陈王昔时宴平乐,斗酒十千恣欢谑。

主人何为言少钱,径须沽取对君酌。

五花马、千金裘,呼儿将出换美酒,与尔同销万古愁。

浣溪沙 · 一曲新词酒一杯

  • 晏殊 [宋代]

一曲新词酒一杯,去年天气旧亭台,夕阳西下几时回?

无可奈何花落去,似曾相时燕归来,小园香径独排徊。

登飞来峰

  • 王安石[宋代]

飞来山上千寻塔,

闻说鸡鸣见日升。

不畏浮云遮望眼,

自缘身在最高层。

鹤冲天 · 梅雨霁

  • 周邦彦[宋代]

梅雨霁,署风和。高柳乱蝉多。

小园台榭远池波,鱼戏动新荷。

薄纱厨,轻羽扇。枕冷簟凉深院。

此时情绪此时天,无事小神仙。

Nordic nRF52x DFU

发表于 2020-11-24 | 分类于 开发

Tools

  • gcc-arm-none-eabi:GCC编译环境

    https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads

    版本对应nRF_SDK目录中(nRF5_SDK_15.3.0_59ac345\components\toolchain\gcc\Makefile.windows)的的版本

    1
    2
    3
    GNU_INSTALL_ROOT := C:/Program Files (x86)/GNU Tools ARM Embedded/7 2018-q2-update/bin/
    GNU_VERSION := 7.3.1
    GNU_PREFIX := arm-none-eabi
  • mingw: win版的Linux命令行工具包

    https://sourceforge.net/projects/mingw/files/latest/download?source

  • micro-ecc-master源码

    https://github.com/kmackay/micro-ecc

    此源码已包含在nRF_SDK中:nRF5_SDK_15.3.0_59ac345\external\micro-ecc

  • python 安装文件

    https://www.python.org/downloads/

    添加环境变量:C:\Python27

  • pc-nrfutil

    https://github.com/NordicSemiconductor/pc-nrfutil/

    可以用python包管理安装:python -m pip install nrfutil

    添加python脚本的环境变量:C:\Python27\Scripts

Compile micro-ecc

  • 运行Mingw: C:\MinGW\msys\1.0\msys.bat

  • 在Mingw窗口中,定位到micro-ecc目录:cd "D:Your-Path/nRF5_SDK_15.3.0_59ac345/external/micro-ecc"

  • 编译:./build_all.sh

Generate DFU Key

  • private key: nrfutil keys generate private.pem

  • public key: nrfutil.exe keys display --key pk --format code private.pem --out_file public_key.c

  • 将public_key.c文件内数组uint8_t pk[64]复制到bootloader工程的相应位置,一般在dfu_public_key.c中

Generate bootloader setting

  • bootloader setting: nrfutil.exe settings generate --family NRF52 --application nrf52832_xxaa.hex --application-version 0 --bootloader-version 0 --bl-settings-version 1 bootloader_settings.hex

Merge Final Production file

  • 合并BootLoader文件和softdevice文件:

    mergehex.exe --merge nrf52832_xxaa_bootloader.hex s132_nrf52_4.0.2_softdevice.hex --output production_final1.hex

  • 将上一个合并文件与app程序合并:

    mergehex.exe --merge production_final1.hex nrf52832_xxaa_app.hex --output production_final2.hex

  • 将上一个合并文件与配置settings 文件合并:
    mergehex.exe --merge production_final2.hex bootloader_settings.hex --output production_final.hex

  • 最后的production_final.hex文件就是我们需要烧录的文件了

Scripts

  • generate_dfu_image.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

@echo off
echo Heat-X OTA CREATER (by Frankie Luo)
echo;

set hex_dir=.\hex\application
set image_dir=.\images
set heat_hex_dir=..\heatx\project_files\ses\Output\Release\Exe\heatx_s132.hex
set key_dir=.\dfu_key\dfu_private_key.pem


goto NEXT


:NEXT
echo Please input the version:
set /p version=
@echo on
set oname=heatx_dfu_fw_%version%
start nrfutil pkg generate --hw-version 52 --application-version 2 --application %heat_hex_dir% --sd-req 0xB7 --key-file %key_dir% .\images\%oname%.zip
COPY /B %heat_hex_dir% %hex_dir%\%oname%.hex
@echo off
  • generate_production_image.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44


@echo off
echo Heat-X PRODUCTION CREATER (by FrankieLuo)
echo;

set secure_bootloader_hex=.\hex\bootloader\secure_bootloader_ble_s132_pca10040.hex
set application_hex=..\heatx\project_files\ses\Output\Release\Exe\heatx_s132.hex
set softdevice_hex=.\hex\softdevice\s132_nrf52_6.1.1_softdevice.hex


goto NEXT


:NEXT
echo Step 1: Create bootloader setting.
set path=C:\Python27\Scripts
::生成bootloader setting文件
nrfutil.exe settings generate --family NRF52 --application %application_hex% --application-version 2 --bootloader-version 0 --bl-settings-version 1 bootloader_settings.hex

echo;
echo Step 2: Merge bootloader and softdevice.
::合并bootloader softdevice
"C:\Program Files (x86)\Nordic Semiconductor\nrf5x\bin\mergehex.exe" --merge %secure_bootloader_hex% %softdevice_hex% --output production_final1.hex

echo;
echo Step 3: Merge with application.
::再合并application
"C:\Program Files (x86)\Nordic Semiconductor\nrf5x\bin\mergehex.exe" --merge production_final1.hex %application_hex% --output production_final2.hex

echo;
echo Step 4: Merge with bootloader setting.
::合并bootloader setting
"C:\Program Files (x86)\Nordic Semiconductor\nrf5x\bin\mergehex.exe" --merge production_final2.hex bootloader_settings.hex --output heatx_production_final.hex

::删除中间文件
del bootloader_settings.hex
del production_final1.hex
del production_final2.hex


::"C:\Program Files (x86)\Nordic Semiconductor\nrf5x\bin\nrfjprog" -f NRF52 --eraseall
::"C:\Program Files (x86)\Nordic Semiconductor\nrf5x\bin\nrfjprog" f NRF52 --program "production_final.hex" --verify
::"C:\Program Files (x86)\Nordic Semiconductor\nrf5x\bin\nrfjprog" -f NRF52 --reset

Reference

  • https://www.cnblogs.com/silencehuan/p/11011716.html
  • https://www.jianshu.com/p/9c6a803c83ac
  • https://devzone.nordicsemi.com/nordic/short-range-guides/b/software-development-kit/posts/getting-started-with-nordics-secure-dfu-bootloader

编辑器中有用的快捷键

发表于 2020-08-04 | 分类于 开发

如何选中相同的内容

  • VSCode/Sublime: Ctrl + D
  • Android Studio: Alt + j
  • Xcode: N/A

快速打开文件

  • VSCode/Sublime: Ctrl + P
  • Android Studio: Double Shift
  • Xcode: CMD + Shift + O

利用J-Flash Lite烧录

发表于 2020-08-04 | 分类于 开发

首先到J-Link驱动程序中找到J-Flash Lite

其次选择芯片类型

最后选择要收录的firmware(Hex, bin格式都可以),先擦除,然后再program

Linux(Android)性能调试基本命令一

发表于 2020-08-03 | 分类于 开发

CPU Loading

  • uptime  # 查看CPU 1Min, 5Min, 15Min Loading值
  • lscpu or cat /proc/cpuinfo  # 查看cpu信息,核心数
  • top or htop  # 查看CPU实时Loading情况和相关进程占用率

CPU当前运行频率:

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq # 800382

CPU当前功耗策略

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor  # interactive conservative userspace powersave ondemand performance

CPU当前温度:

  • cat /sys/devices/virtual/thermal/thermal_zone0/temp  # 27800
  • 或安装lm-sensors并利用sensors查看
  • cat /sys/devices/virtual/thermal/thermal_zone0/trip_point_0_temp  # 查看CPU critical降频温度

Memory usage:

free -h

Android利用 adb screencap 命令截屏

adb shell screencap -p /sdcard/screenshot.png && adb pull /sdcard/screenshot.png .

解决无法安装NET Framework,严重错误并回滚问题

发表于 2020-08-03 | 分类于 开发

首先安装时右击安装文件,并已管理员身份打开。安装错误时会弹出安装未成功对话框:

点击“日志文件”,并用Windows自带浏览器(IE)打开,移动到文件最后,会看到红色提示信息:

根据提示信息,是由于我们没有相关文件的操作权限(“C:\Windows\system32\msvcr100_clr0400.dll”),在C:\Windows中搜索”msvcr100”会看这两个文件

右击文件->属性->安全->高级->所有者,将所有者更改为“Administrators (xxx\Administrators)”

再次右击文件->属性->安全->编辑->”Administrators (xxx\Administrators)”,点选完全控制并确认

不过在安装过程中会多次提示并回滚,每次记得直接更改”System32”和”SysWOW64”中对应的两个文件,并注意文件名“细小差别”,笔者更改了6个文件,分别为:

1
2
3
4
5
6
7
8
C:\Windows\System32\msvcr100_clr0400.dll
C:\Windows\SysWOW64\msvcr100_clr0400.dll

C:\Windows\System32\msvcr110_clr0400.dll
C:\Windows\SysWOW64\msvcr110_clr0400.dll

C:\Windows\System32\msvcp110_clr0400.dll
C:\Windows\SysWOW64\msvcp110_clr0400.dll
<123>

24 日志
3 分类
22 标签
© 2025 John Doe
由 Hexo 强力驱动
|
主题 — NexT.Pisces v5.1.4