我正在编写/试验一个python脚本,该脚本需要连接到Windows 10中现有的命名管道。我正在使用Python 3.8
具体来说,我正在尝试连接到名为SendPipe1
的管道,并向其写入14个ascii编码字符
管道是由其他一些软件(驱动程序?)为连接到我的电脑的设备创建的。我连接到它是为了尝试以制造商提供的软件相同的方式与设备交互。制造商提供的软件连接到同一管道并向其发送编码信息,从而命令设备执行某些操作。这就是我想做的
通过运行PipeList实用程序,我知道管道已经存在:
PipeList v1.02 - Lists open named pipes
Copyright (C) 2005-2016 Mark Russinovich
Sysinternals - www.sysinternals.com
Pipe Name Instances Max Instances
--------- --------- -------------
[...]
chrome.blah.foo 1 1
SendPipe1 1 -1
ReceivePipe1 1 -1
chrome.blah.bar 1 1
[...]
以下是我现在拥有的:
ACTIVE_DISP_ID = 1
msg = f'6;16;100;{ACTIVE_DISP_ID};1\r\n'
pipe_path = f'\\\\.\\PIPE\\SendPipe{ACTIVE_DISP_ID}'
try:
f = open(pipe_path, 'wb+', buffering=0)
f.write(msg.encode(encoding='ascii'))
except OSError as e:
raise
这让我
Traceback (most recent call last):
File "C:/Users/Spooqi/PycharmProjects/Spooqi/radiant/pipe-test.py", line 7, in <module>
f = open(pipe_path, 'wb+', buffering=0)
OSError: [Errno 22] Invalid argument: '\\\\.\\PIPE\\SendPipe1'
我相当确定路径'\\\\.\\PIPE\\SendPipe1'
是正确的,因为如果我将其更改为类似'\\\\.\\PIPE\\FooPipeBar'
的内容,我会得到一个不同的异常:
FileNotFoundError: [Errno 2] No such file or directory: '\\\\.\\PIPE\\FooPipeBar'
如果我写入一个相对路径为foobar
的常规文件,它通常只会生成一个包含该消息的文本文件
在这种情况下,errno 22是什么意思?为什么这个论点是无效的?为什么我不能连接到这个管道并写入它
是否有其他流程已连接到管道?我该怎么检查呢?如果有,如何同时使用管道连接到设备
目前没有回答
相关问题 更多 >
编程相关推荐