I've been playing with my new "CrowPi" from Elecrow. It's a great Raspberrry Pi STEM kit that is entirely self-contained in a small case. It includes a touch screen and a TON of sensors, LCDs, matrix display, sensors, buzzers, breadboard, etc.
我一直在玩Elecrow的新“ CrowPi”。 这是一个很棒的Raspberrry Pi STEM套件,在一个小盒子里完全是独立的。 它包括触摸屏和大量的传感器,LCD,矩阵显示器,传感器,蜂鸣器,面包板等。
NOTE: I talked to the #CrowPi people and they gave me an Amazon COUPON that's ~$70 off! The coupon is 8EMCVI56 and will work until Jan 31, add it during checkout. The Advanced Kit is at https://amzn.to/2SVtXl2
#ref and includes everything, touchscreen, keyboard, mouse, power, SNES controllers, motors, etc. I will be doing a full review soon. Short review is, it's amazing.注意:我与#CrowPi交谈人,他们给了我一个亚马逊优惠券,可享受约70美元的优惠! 优惠券为8EMCVI56,有效期至1月31日,请在结帐时添加。 高级套件是https://amzn.to/2SVtXl2
#ref和包括一切,触摸屏,键盘,鼠标,电源,SNES控制器,电机,等我将很快做了全面审查。 简短的评论是,这太神奇了。
I was checking out daily builds of the new open source .NET Core System.Device.Gpio that lets me use C# to talk to the General Purpose Input/Output pins (GPIO) on the Raspberry Pi. However, my "developer's inner loop" was somewhat manual. The developer's inner loop is that "write code, run code, change code" loop that we all do. If you find yourself typing repetitive commands that deploy or test your code but don't write new code, you'll want to try to optimize that inner loop and get it down to one keystroke (or zero in the case of automatic test).
我正在检查新的开源.NET Core System.Device.Gpio的每日版本,该版本使我可以使用C#与Raspberry Pi上的通用输入/输出引脚(GPIO)进行通信。 但是,我的“开发人员的内部循环”有点手工。 开发人员的内部循环是我们所有人都遵循的“编写代码,运行代码,更改代码”循环。 如果您发现自己输入了重复的命令来部署或测试代码,但没有编写新代码,则需要尝试优化该内部循环,并将其降低到一次击键(在自动测试的情况下为零)。
In my example, I was writing my code in Visual Studio Code on my Windows machine, building the code locally, then running a "publish.bat" that would scp (secure copy) the resulting binaries over to the Raspberry Pi. Then in another command prompt that was ssh'ed into the Pi, I would chmod the resulting binary and run it. This was tedious and annoying, however as programmers sometimes we stop noticing it and just put up with the repetitive motion.
在我的示例中,我在Windows机器上的Visual Studio Code中编写代码,在本地构建代码,然后运行“ publish.bat”,它将生成的二进制文件scp(安全复制)到Raspberry Pi。 然后在ssh插入Pi的另一个命令提示符中,我将对生成的二进制文件进行chmod并运行它。 这是乏味和烦人的,但是随着程序员有时我们不再注意到它,而只是忍受重复的动作。
A good (kind of a joke, but not really) programmer rule of thumb is - if you do something twice, automate it.
好的(有点笑话,但不是真的)是程序员的经验法则-如果您做两次,请使其自动化。
I wanted to be able not only to make the deployment automatic, but also ideally I'd be able to interactively debug my C#/.NET Core code remotely. That means I'm writing C# in Visual Studio Code on my Windows machine, I hit "F5" to start a debug session and my app is compiled, published, run, and I attached to a remote debugger running on the Raspberry Pi, AND I'm dropped into a debugging session with a breakpoint set. All with one keystroke. This is common practice with local apps, but for remote apps - and ones that span two CPU architectures - it can take a smidge of setup.
我不仅希望能够使部署自动化,而且理想情况下还希望能够以交互方式远程调试C#/。NET Core代码。 这意味着我正在Windows机器上用Visual Studio Code编写C#,单击“ F5”开始调试会话,并且编译,发布,运行我的应用程序,并附加到在Raspberry Pi上运行的远程调试器上,并且我进入了带有断点设置的调试会话。 一键操作。 这是本地应用程序的常见做法,但是对于远程应用程序(以及跨越两个CPU架构的应用程序),可能需要进行一些设置。
Starting with instructions here: https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes and here: https://github.com/OmniSharp/omnisharp-vscode/wiki/Remote-Debugging-On-Linux-Arm and a little help from Jose Perez Rodriguez at work, here's what I came up with.
从此处的说明开始: https : //github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes以及此处: https : //github.com/OmniSharp/omnisharp-vscode/wiki/Remote-Debugging -On-Linux-Arm和Jose Perez Rodriguez在工作中提供的一些帮助,这就是我想出的。
设置从Windows上的Visual Code到运行C#和.NET Core的Raspberry Pi的远程调试 (Setting up Remote Debugging from Visual Code on Windows to a Raspberry Pi running C# and .NET Core)
First, I'm assuming you've got .NET Core on both your Windows machine and Raspberry Pi. You've also installed Visual Studio Code on you Windows machine and you've installed the C# extension.
首先,我假设您在Windows计算机和Raspberry Pi上都安装了.NET Core 。 您还已经在Windows计算机上安装了Visual Studio Code ,并且已经安装了C#扩展名。
在Raspberry Pi上 (On the Raspberry Pi)
I'm ssh'ing into my Pi from Windows 10. Windows 10 includes ssh out of the box now, but you can also ssh from WSL (Windows Subsystem for Linux).
我正在从Windows 10进入我的Pi。Windows10现在包含了现成的ssh,但是您也可以从WSL(Linux的Windows子系统)进行ssh。
Install the VS remote debugger on your Pi by running this command:
通过运行以下命令在您的Pi上安装VS远程调试器:
Install the VS remote debugger on your Pi by running this command: curl -sSL https://aka.ms/getvsdbgsh | /bin/sh /dev/stdin -v latest -l ~/vsdbg
通过运行以下命令在您的Pi上安装VS远程调试器: curl -sSL https://aka.ms/getvsdbgsh | / bin / sh / dev / stdin -v最新-l〜/ vsdbg
To debug you will need to run the program as root, so we'll need to be able to remote launch the program as root as well. For this, we need to first set a password for the root user in your pi, which you can do by running:
要调试,您将需要以root用户身份运行该程序,因此我们还需要能够以root用户身份远程启动该程序。 为此,我们需要首先为您的pi中的root用户设置一个密码,您可以通过运行以下命令来执行此操作:
To debug you will need to run the program as root, so we'll need to be able to remote launch the program as root as well. For this, we need to first set a password for the root user in your pi, which you can do by running: sudo passwd root
的要调试的季交一一,我们都将以root身份运行程序。 为此,我们需要首先为您的pi中的root用户设置密码,您可以通过运行以下命令来执行此操作: sudo passwd root
Then we need to enable ssh connections using root, by running :
然后,我们需要通过运行以下命令使用root启用ssh连接:
Then we need to enable ssh connections using root, by running : sudo nano /etc/ssh/sshd_config
然后,我们需要通过运行以下命令来使用root启用ssh连接: sudo nano / etc / ssh / sshd_config
and adding a line that reads:
并添加一行内容为:
PermitRootLogin yes
PermitRootLogin是
reboot the pi: sudo reboot
重新启动pi: sudo重新启动
VSDbg looks like this getting installed:
VSDbg看起来像这样安装:
pi@crowpi:~/Desktop/rpitest$ curl -sSL https://aka.ms/getvsdbgsh | /bin/sh /dev/stdin -v latest -l ~/vsdbg
Info: Creating install directory
Using arguments
Version : 'latest'
Location : '/home/pi/vsdbg'
SkipDownloads : 'false'
LaunchVsDbgAfter : 'false'
RemoveExistingOnUpgrade : 'false'
Info: Using vsdbg version '16.0.11220.2'
Info: Previous installation at '/home/pi/vsdbg' not found
Info: Using Runtime ID 'linux-arm'
Downloading https://vsdebugger.azureedge.net/vsdbg-16-0-11220-2/vsdbg-linux-arm.zip
Info: Successfully installed vsdbg at '/home/pi/vsdbg'
At this point I've got vsdbg installed. You can go read about the MI Debug Engine here. "The Visual Studio MI Debug Engine ("MIEngine") provides an open-source Visual Studio Debugger extension that works with MI-enabled debuggers such as gdb, lldb, and clrdbg."
至此,我已经安装了vsdbg。 您可以在此处阅读有关MI调试引擎的信息。 “ Visual Studio MI调试引擎(“ MIEngine”)提供了开放源代码的Visual Studio调试器扩展,可与启用了MI的调试器(例如gdb,lldb和clrdbg)一起使用。”
在Windows计算机上 (On the Windows Machine)
Note that there are a half dozen ways to do this. Since I had a publish.bat already that looked like this, after installing putty with "choco install putty" on my Windows machine. I'm a big fan of pushd and popd and I'll tell you this, they aren't used or known enough.
请注意,有六种方法可以做到这一点。 由于我已经有一个看起来像publish.bat的东西,因此在Windows计算机上安装了带有“ choco install putty ”的腻子后。 我是push和popd的忠实拥护者,我会告诉您,它们还没有被广泛使用或了解。
dotnet publish -r linux-arm /p:ShowLinkerSizeComparison=true
pushd .\bin\Debug\netcoreapp2.1\linux-arm\publish
pscp -pw raspberry -v -r .\* pi@crowpi.lan:/home/pi/Desktop/rpitest
popd
On Windows, I want to add two things to my .vscode folder. I'll need a launch.json that has my "Launch target" and I'll need some tasks in my tasks.json to support that. I added the "publish" task myself. My publish task calls out to publish.bat. It could also do the stuff above if I wanted. Note that I made publish "dependsOn" build, and I removed/cleared problemMatcher. If you wanted, you could write a regEx that would detect if the publish failed.
在Windows上,我想在.vscode文件夹中添加两件事。 我需要一个带有“启动目标”的launch.json,并且我的task.json中需要一些任务来支持它。 我自己添加了“发布”任务。 我的发布任务调出了publish.bat。 如果我愿意,它也可以做上面的事情。 请注意,我进行了发布“ dependsOn”的构建,并且删除/清除了problemMatcher。 如果需要,您可以编写一个regEx来检测发布是否失败。
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/rpitest.csproj"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"type": "shell",
"dependsOn": "build",
"presentation": {
"reveal": "always",
"panel": "new"
},
"options": {
"cwd": "${workspaceFolder}"
},
"windows": {
"command": "${cwd}\\publish.bat"
},
"problemMatcher": []
}
]
}
Then in my launch.json, I have this to launch the remote console. This can be a little confusing because it's mixing paths that are local to Windows with paths that are local to the Raspberry Pi. For example, pipeProgram is using the Chocolatey installation of Putty's Plink. But program and args and cwd are all remote (or local to) the Raspberry Pi.
然后在我的launch.json中,使用它来启动远程控制台。 这可能会有些混乱,因为它将Windows本地路径与Raspberry Pi本地路径混合在一起。 例如,pipeProgram使用的是Putty's Plink的Chocolatey安装。 但是program和args和cwd都位于Raspberry Pi的远程(或本地)。
"configurations": [
{
"name": ".NET Core Launch (remote console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "/home/pi/dotnet/dotnet",
"args": ["/home/pi/Desktop/rpitest/rpitest.dll"],
"cwd": "/home/pi/Desktop/rpitest",
"stopAtEntry": false,
"console": "internalConsole",
"pipeTransport": {
"pipeCwd": "${workspaceFolder}",
"pipeProgram": "${env:ChocolateyInstall}\\bin\\PLINK.EXE",
"pipeArgs": [
"-pw",
"raspberry",
"root@crowpi.lan"
],
"debuggerPath": "/home/pi/vsdbg/vsdbg"
}
}
Note the debugger path lines up with the location above that we installed vsdbg.
请注意,调试器路径与上面安装了vsdbg的位置对齐。
It's worth pointing out that while I'm doing this for C# it's not C# specific. You could setup remote debugging with VS Code using these building blocks with any environment.
值得指出的是,尽管我为C#执行此操作,但它并非特定于C#。 您可以在任何环境下使用这些构件来使用VS Code设置远程调试。
The result here is that my developer's inner loop is now just pressing F5! What improvements would YOU make?
结果是我的开发人员的内部循环现在只按F5键! 您将进行哪些改进?
Sponsor: Preview the latest JetBrains Rider with its Assembly Explorer, Git Submodules, SQL language injections, integrated performance profiler and more advanced Unity support.
赞助商:预览最新的JetBrains Rider,包括其Assembly Explorer,Git子模块,SQL语言注入,集成的性能分析器以及更高级的Unity支持。
本文介绍如何在Windows上的VS Code中实现对Raspberry Pi上运行的C#和.NET Core应用的远程调试。通过安装必要的组件和配置VS Code,作者成功地实现了只需按下F5键即可完成代码构建、发布及调试的过程。



被折叠的 条评论
为什么被折叠?



