System.IO.Ports.SerialPort - 可以配置 IOCTL_SERIAL_SET_WAIT_MASK 吗?
我一直在尝试通过编写一个小型 Windows 窗体应用程序来收集调用者显示数据来了解 .Net (3.5) 如何通过 System.IO.Ports.SerialPorts 类与串行端口交互。来自旧的外部调制解调器。
我测试过调制解调器支持来电显示; 使用 Putty 或超级终端,我可以配置调制解调器来收集呼叫者显示数据(使用命令 AT#CID=1
,我发现该命令此处),当电话铃声响起时,就会显示数据。 在终端窗口中,它看起来像这样:
RING
DATE = 0308
TIME = 2045
NMBR = 01234567890
RING
我的 C# 应用程序似乎已成功配置调制解调器并显示 RING
电话铃声响起时发送消息; 但是,它从不显示来电显示数据。
为了理解其中的原因,我使用 Sysinternals
主要区别在于连接配置; 我的 C# 应用程序包含以下行,而 Putty 和超级终端则没有;
0.00000307 callerID.exe IOCTL_SERIAL_SET_WAIT_MASK Serial0 SUCCESS Mask: RXCHAR RXFLAG CTS DSR RLSD BRK ERR RING
据我了解,IOCTL_SERIAL_SET_WAIT_MASK
是要过滤的消息类型的包含列表。
那么,三个问题:
来电显示信息是否可能被 IOCTL_SERIAL_SET_WAIT_MASK 抑制?
如果是这样,我该如何配置它以显示来电显示信息? 它似乎无法从类属性访问。
如果我无法配置它,我唯一的选择是解决这个问题,将我自己的包装器写入控制串行端口的较低级别系统功能吗?
我对串行端口通信的理解非常基础,所以我希望我的诊断还很遥远。 非常感谢任何指导。
I've been trying to learn a bit about how .Net (3.5) interacts with the Serial port through the System.IO.Ports.SerialPorts
class by writing a small Windows Forms application to gather caller display data from an old external modem.
I've tested that the modem supports caller display; using Putty or Hyperterminal I can configure the modem to collect caller display data (using the command AT#CID=1
, which I found here), and when the phone rings, the data is displayed. In the terminal window, it looks like this:
RING
DATE = 0308
TIME = 2045
NMBR = 01234567890
RING
My C# application appears to successfully configure the modem and displays a RING
message when the phone rings; however, it never displays the caller ID data.
In an effort to understand why this is, I compared the actions taken by the different clients using Sysinternals Portmon.
The primary difference appears in the connection configuration; my C# application includes the following line, which Putty and Hyperterminal do not;
0.00000307 callerID.exe IOCTL_SERIAL_SET_WAIT_MASK Serial0 SUCCESS Mask: RXCHAR RXFLAG CTS DSR RLSD BRK ERR RING
As I understand it, IOCTL_SERIAL_SET_WAIT_MASK
is an inclusive list of message types to filter for.
So, three questions:
Is it possible that the caller ID information is being suppressed by IOCTL_SERIAL_SET_WAIT_MASK
?
If so, how can I configure it to show the caller ID info? It doesn't appear to be accessible from the class properties.
If I can't configure it, is my only option to get around this to write my own wrapper to the lower-level system functions controlling the serial port?
My understanding of serial port communications is very basic, so I expect I'm way off in my diagnosis. Any guidance gratefully received.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我的诊断结果还差得很远。
看来
WriteLine
方法不会终止它使用调制解调器所期望的行终止符发送的命令。我所需要做的就是在我发送的命令中添加一个回车符,并使用
Write
方法发送它们。为浪费任何人的时间而道歉。
I was way off with my diagnosis.
It seems that the
WriteLine
method doesn't terminate the commands it sends with the line terminator my modem is expecting.All I needed to do was add a carriage return to the commands I am sending, and send them using the
Write
method.Apologies for wasting anybody's time.
我在 MSDN 上找到了这个,它看起来像是一个很好的示例,说明了如何通过系统 dll 上的 P/Invoke 访问串行端口。
我仍然想知道是否可以解决 .Net 类的问题。
I found this on MSDN which looks like a decent example of how to access the serial port via P/Invoke on the system dll's.
I'd still like to know if I can get around my issues with the .Net class.