Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 如何发送十六进制代码_Powershell - Fatal编程技术网

Powershell 如何发送十六进制代码

Powershell 如何发送十六进制代码,powershell,Powershell,我正在尝试通过PowerShell发送命令行,以便通过串行端口打开投影仪。我正在使用NEC投影仪,打开和关闭投影仪的命令如下: 通电:02H 00H 00H 00H 02H 关闭电源:02H 01H 00H 00H 03H 我使用制造商的软件,我确实监控了它发送的内容,并使用以下方法打开它: 打开COM端口 写道: 00 bf 00 00 01 00 c0 00 bf 00 00 01 02 c2 但它不发送十六进制,而是发送: 30 30 20 62 66 20 30 30 20 30 30

我正在尝试通过PowerShell发送命令行,以便通过串行端口打开投影仪。我正在使用NEC投影仪,打开和关闭投影仪的命令如下:

通电:
02H 00H 00H 00H 02H

关闭电源:
02H 01H 00H 00H 03H

我使用制造商的软件,我确实监控了它发送的内容,并使用以下方法打开它:

打开COM端口

写道:

00 bf 00 00 01 00 c0 00 bf 00 00 01 02 c2 但它不发送十六进制,而是发送:

30 30 20 62 66 20 30 30 20 30 30 20 30 31 20 30 00 bf 00 00 01 0 30 20 63 30 0a 0 c0. 30 30 20 62 66 20 30 30 30 30 30 30 30 00 bf 00 00 01 0
30 20 63 30 0a 0 c0。你能张贴一下你用来发送的代码行吗?现在还不清楚您到底想做什么或是怎么出错的。请注意,PowerShell中的十六进制文字是像
0x20 0xbf 0x01等那样编写的。
感谢大家的帮助,我可能没有提供太多信息,我发布的是一个名为串口监视器的软件的转储视图,我想做的是通过powershell发送命令代码。非常感谢!如果我在用python编写代码时遇到问题,可以与您联系吗?又来了!!! 20 bf 01 20 10 02 0f ff ff ff ff 00 00 00 00 00 00 00 00 00 00 1d 02 00 00 00 00 02
$port.WriteLine
30 30 20 62 66 20 30 30 20 30 30 20 30 31 20 30 00 bf 00 00 01 0 30 20 63 30 0a 0 c0.
[Byte[]] $powerOn = 0x02,0x00,0x00,0x00,0x00,0x02
[Byte[]] $powerOff = 0x02,0x01,0x00,0x00,0x00,0x03

# Use your COM port here
$port = new-Object System.IO.Ports.SerialPort COM3,9600,None,8,one
$port.Open()
$port.Write($powerOn, 0, $powerOn.Count)
# ...
$port.Write($powerOff, 0, $powerOff.Count)
$port.Close()