关于vb中的串口属性的设置!

zhangjie_it 2013-10-28 04:26:56
vb。net中,做串口编程,在设置属性port1.ReceivedBytesThreshold 的时候;
只要给这个属性赋值,在调试的时候,调试到这一句,就死机。
哪怕这个属性Me.SerialPort1.ReceivedBytesThreshold = 1也会死机!

请问怎么回事,谢谢!
...全文
403 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhangjie_it 2013-10-29
  • 打赏
  • 举报
回复
引用 1 楼 wuyazhe 的回复:
先关闭串口,设置好在打开试试?
感谢,ok了!
kidnap 2013-10-28
  • 打赏
  • 举报
回复
不好意思,上一贴错了。 我是这么做的,没有出错。

With serialport1
                .PortName = comParams(cP.cPort) 'TBD reopen 异常
                .BaudRate = CInt(comParams(cP.cBaud))
                'demo working with enumerations. get enum value from string
                .Parity = DirectCast([Enum].Parse(GetType(Parity), comParams(cP.cParity)), Parity) 'get enum value from string
                .DataBits = CInt(comParams(cP.cData))
                .StopBits = DirectCast([Enum].Parse(GetType(StopBits), comParams(cP.cStop)), StopBits)
                .Handshake = Handshake.None
                .RtsEnable = False
                'set the set the number of bytes in readbuffer, when event will be fired
                .ReceivedBytesThreshold = CInt(comParams(cP.cThreshold))
                Me._threshold = .ReceivedBytesThreshold
                'i this usage 5000ms will never be reached because we read only bytes present in readbuffer
                .ReadTimeout = 5000
                'default value. make changes here
                .ReadBufferSize = 512 
                'default value
                .WriteBufferSize = 256 
                'make changes here
                '.Encoding = System.Text.Encoding.ASCII
                'delay so that event handle can fetch more bytes at once
                Me._receiveDelay = CInt(comParams(cP.cDelay))
            End With
kidnap 2013-10-28
  • 打赏
  • 举报
回复
Me.SerialPort1.ReceivedBytesThreshold ="1"
兔子-顾问 2013-10-28
  • 打赏
  • 举报
回复
先关闭串口,设置好在打开试试?

16,721

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧