问题描述
我知道还有其他一些文章可以解决这个问题,但是我仍然无法找到解决问题的方法。
我收到了来自串行端口的大量数据,其中包含0x1A。我以离散的块形式接收它们(此时以10、18或528的块形式接收,我知道何时期望每种大小)。问题是,每当我收到0x1A时,它似乎就会丢弃该字节。
我尝试过:
I know there are other posts which have addressed this fact but I have still been unable to find a solution to my problem.
I am received massive chunks of data from a serial port which will include 0x1A in them. I receive them in discrete chunks (at this point in chunks of 10, 18 or 528 and I know when to expect each size). The problem is that whenever I receive a 0x1A it would appear to drop this byte.
I have tried:
if (e.EventType == SerialPort.Eof) return;
但出现错误:
System.IO.Ports .SerialPort
不包含'Eof'的定义。
but I get the error:System.IO.Ports.SerialPort
does not contain a definition for 'Eof'.
我想做的就是禁用此Eof功能;
提前谢谢您,如果在其他地方都回答过此问题,对不起,但是我在任何地方都找不到直接的答案... p>
What I would like to do is simply disable this Eof feature; is it possible so that this character is no longer anything special?
Thanks in advance and sorry if this has been answered elsewhere but I haven't been able to find a straight answer anywhere...
推荐答案
当然,发布问题后,我马上就知道了。
Of course immediately after posting a question I figure it out.
我需要使用 SerialData
而不是 SerialPort
。我的错。我希望这对其他人有帮助!
I needed to use SerialData
instead of SerialPort
. My bad. I hope this helps other people out there!
这篇关于使用SerialPort禁用EOF(0x1A)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!