小编Bil*_*ore的帖子

在现代C++中是否可以将字符串文字作为参数传递给C++模板?

是否可以在"现代C++"(C++ 17或更高版本)中将字符串文字作为参数传递给C++模板?

我意识到你可以用构造函数参数做到这一点; 我只是认为将它作为模板参数更方便,而不是深埋在cpp文件中.如果这可能是现代C++的一个新功能,我很好奇.请参阅下面的伪代码我正在尝试做的事情:

伪代码示例:

// Header File /////////////////////////
template<constexpr string Name>
class ModuleBase {
public:
    ModuleBase();
    string name;
};

class xyz : ModuleBase<"xyz"> {
public:
    xyz();
};

// Cpp File //////////////////////////
template<string_literal Name>
ModuleBase<Name>::ModuleBase() {
    name = Name;
}

xyz::xyz() : ModuleBase() {

}
Run Code Online (Sandbox Code Playgroud)

c++ c++17 c++20

50
推荐指数
1
解决办法
3468
查看次数

像过去那样使用 COM 端口通过“空调制解调器”将 2 个 USB 端口连接在一起?

我很好奇是否有人知道通过 USB 线将两台不同的计算机连接在一起的方法以及存在哪些 API 来对该接口进行编程。

对于串行端口,通常购买一个“空调制解调器”适配器来跨越 UART 的发送和接收线,以便计算机可以一起通话。然后你会像普通的 Windows 文件一样在名为“COM1”、“COM2”等的特殊系统文件上读写它们。

我想知道是否有某种适配器可以模拟除本机 USB 协议之外的相同行为。我意识到他们有 USB-to-UART 适配器。这并不是我真正感兴趣的,因为 UART 的波特率非常慢。我一直在寻找具有 USB 速度的东西,以便从一台计算机传输到另一台不通过以太网或 wifi 等网络链接的计算机。

这就是我所拥有的: COMPUTER A<-->USB<-->UART<-->NULL_MODEM<-->UART<--->USB<-->COMPUTER B Speed 110,000 Baud,无论如何......传输文件......文本确定......

这就是我要的:

计算机 A<-->USB<-->Crossover_Adapter<--->USB<-->计算机 B 速度 480 兆比特每秒

假设这个野兽存在,您如何对其进行编程以及在哪里购买?

usb serial-port

6
推荐指数
1
解决办法
5476
查看次数

如何在 UWP/C# 中使用 svg 文件资源设置 AppBarButton 图标

Microsoft 文档指出您可以使用 SVG 矢量图形文件设置图标:https : //docs.microsoft.com/en-us/windows/uwp/design/style/icons

但是,当我尝试使用 svg 文件设置图标时,它只显示空白:

<AppBarButton Label="BitmapIcon">
    <AppBarButton.Icon>
        <BitmapIcon UriSource="ms-appx:///Svg/MyButton.svg"/>
    </AppBarButton.Icon>
</AppBarButton>
Run Code Online (Sandbox Code Playgroud)

这就是我将 Svg 文件添加到我的项目的方式:在项目下我创建了一个目录“Svg”,在 Svg 文件夹中我添加了文件“MyButton.svg”。此 svg 资源文件的属性设置为:

构建操作:内容

复制到输出目录:不复制

自定义工具:

自定义工具命名空间:

c# xaml uwp

6
推荐指数
1
解决办法
3916
查看次数

USB 转 GPIO/SPI/I2C/UART 适用于常规 Windows 10 PC?类似于 Raspberry Pi 40 针接头

有谁知道有一家公司销售适用于普通非物联网 Windows 10 PC 的 USB 电缆,该电缆可以将 USB 转换为 40 针 Raspberry pi 接头上的所有以下总线?示例:USB->GPIO、I2C、SPI、UART 等。

我能找到的最接近的是:

Digilentinc.com 的数字发现逻辑分析仪

这可以将 PC USB 转换为 GPIO/I2C/SPI 等...除了我正在寻找更小、电线更少的东西...只有 40 针接头或更少...类似于树莓派 40 针接头,除了被驱动从连接到 PC 的 USB 改为...有人见过这种类型的待售产品,它可以通过所有列出的总线从 PC-USB 转换为 40 针接头吗?

另外,我希望能够使用“Windows.Devices”Api 而不是专有驱动程序 DLL API 通过Windows UWP对该 USB 转换设备进行编程...还没有真正找到...示例:

// C# Program GPIO connected to USB dongle of regular PC...
using Windows.Devices.GPIO;
...
private void InitGPIO()
{
    var gpio_ctrl = GpioController.GetDefault();
    // Check GPIO state
    if (gpio_ctrl == null)
    {
        this.pin = null; …
Run Code Online (Sandbox Code Playgroud)

c# windows spi i2c gpio

5
推荐指数
1
解决办法
9578
查看次数

将轴线添加到 matplotlib 图

我正在使用“ipython jupyter notebook”。我的问题是:

如何将轴线添加到图中,即。y=0 和 x=0:

%matplotlib inline
from numpy import *
from matplotlib.pyplot import *
nil=seterr(divide='ignore', invalid='ignore')

t = arange(-2, 2, 0.1)
y1 = exp(t)
y2 = exp(-t)

subplot(121)
title('y=exp(t)')
ylabel('y')
xlabel('t')
grid()
plot(t, y1, '-')

subplot(122)
title('y=exp(-t)')
ylabel('y')
xlabel('t')
grid()
plot(t, y2, '-')
show()
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

python matplotlib ipython jupyter

5
推荐指数
1
解决办法
5281
查看次数

如何在另一个 powershell 脚本中包含另一个 powershell 脚本文件?

假设我有一个 powershell 脚本,它在我当前路径的相对路径中包含一个 Powershell 哈希。让我们称之为“name.ps1”,它包含:

$names = @{
   "bob" = "bobby"
   "john" = "jones"
   "danial" = "davis"
}
Run Code Online (Sandbox Code Playgroud)

等等...

现在,我有另一个名为“dosomething.ps1”的 powershell 脚本,它想将此文件“../db/names.ps1”导入当前的 powerscript 文件中,就像旧式 c 语言包含一样,如下所示:

#include "../db/names.ps1"

write-host ("BOB: {0}" -f $names.bob)
write-host ("JOHN: {0}" -f $names.john)
Run Code Online (Sandbox Code Playgroud)

我怎样才能在powershell中完成这个?

powershell

5
推荐指数
1
解决办法
831
查看次数

如何查看RegexOptions枚举中可用的选项?

如何使用powershell脚本中的此函数来使用-cmatch运算符执行不区分大小写的匹配:

static System.Text.RegularExpressions.Match Match(
     string input, 
     string pattern,
     System.Text.RegularExpressions.RegexOptions options)
Run Code Online (Sandbox Code Playgroud)

我在想它是这样的:

PS>  $input = "one two three"

PS>  $m = [regex]::Match($input, "one", ????)
Run Code Online (Sandbox Code Playgroud)

我有一个问题的部分是????上面的.

您如何看待System.Text.RegularExpressions.RegexOptionsPowerShell提示中提供的内容以及在上面的代码中使用它的语法是什么?

regex powershell enums

4
推荐指数
1
解决办法
318
查看次数

Powershell IDE:如何在不离开 Powershell ISE 的情况下重新启动交互式 shell 以清除所有变量?

假设我已经使用 Powershell ISE 一段时间了,我的环境空间开始变脏,我需要重新启动交互式 shell...我不想关闭编辑器并重新打开它。如何重新启动 powershell ISE 交互式 shell 以清除所有变量,而无需关闭并重新打开 Powershell ISE?

在此输入图像描述

powershell powershell-ise

3
推荐指数
1
解决办法
2808
查看次数

powershell相当于linux"mkdir -p"?

如何让powershell"mkdir"命令完全像Linux的mkdir -p命令一样?

在Linux下,mkdir -p将创建嵌套目录,但前提是它们不存在.例如,假设您有一个/foo具有写权限的目录.mkdir -p /foo/bar/baz在现有的酒吧内创建酒吧和酒吧/foo.您再次运行相同的命令,您将不会收到错误,但不会创建任何内容.

powershell

2
推荐指数
3
解决办法
2847
查看次数

在 VHDL-2008 中,如何在 c 语言中格式化类似于“%f”的“real”,例如:sprintf(str, "%9.6f", myreal)

我正在使用 VHDL-2008,我想很好地格式化实数是类似于这个 c 语言函数的字符串:

    sprintf(str, "%9.6f", myreal);
Run Code Online (Sandbox Code Playgroud)

目前,我正在以这种方式格式化我的实数:

architecture sim of testbench is
    constant myreal :real := 3343.2342;
begin

process
begin
   report real'image(real_number);
   wait;
end process

end architecture;
Run Code Online (Sandbox Code Playgroud)

这不允许对 VHDL 中实数的格式进行足够的控制。我想要的是控制 vhdl 格式,更像是 c 语言“%n.mf”格式器。

基本上,GHDL模拟器中的VHDL默认值总是以科学记数法打印实数,小数点左边一位,分数和指数,这很烦人。

vhdl

2
推荐指数
1
解决办法
756
查看次数

标签 统计

powershell ×4

c# ×2

c++ ×1

c++17 ×1

c++20 ×1

enums ×1

gpio ×1

i2c ×1

ipython ×1

jupyter ×1

matplotlib ×1

powershell-ise ×1

python ×1

regex ×1

serial-port ×1

spi ×1

usb ×1

uwp ×1

vhdl ×1

windows ×1

xaml ×1