将Chr(255)发送到串行端口 [英] Sending Chr(255) to Serial Port

查看:177
本文介绍了将Chr(255)发送到串行端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我需要将chr(255)发送到串口。当我发送它时,通过

comm.write(chr(255))它发送一个chr(63)...在十六进制中,我写chr(& FF)然后它

实际发送chr(& 3F)...为什么会发生这种情况,我该如何发送呢

对吧?


我'我正在使用带有框架2.0的vb.net 2005快递


感谢你的回复...


迈克

Hi

I need to send a chr(255) to a serial port. When I send it, through
comm.write (chr(255)) it sends a chr(63) ... in Hex, I write chr(&FF) and it
actually sends chr(&3F) ... why does this happen, and how can I send it
right ?

I''m using vb.net 2005 express with framework 2.0

Thanks for an answear ...

Mike

推荐答案




你不能发送作为一个角色,你必须像这样发送(或者一些

变体;有几个,一些具有更紧凑的语法 - 我拼写了

它以便清楚地说明需要什么):


Dim My255()As Byte

My255(0)= 255

SerialPort.Write(My255,0,1)


看看Write方法的重载。


Dick


-

Richard Grier ,MVP

Hard&软件

Visual Basic程序员串行通信指南的作者,第四版

版,

ISBN 1-890422-28-2( 391页,包括CD-ROM)。 2004年7月,修订3月

2006.

www.hardandsoftware.net 了解详情和联系方式。
Hi,

You cannot send is as a character, you must send it like this (or some
variation; there are several, some with more compact syntax -- I''ve spelled
it out to make it clear what is needed):

Dim My255 () As Byte
My255(0) = 255
SerialPort.Write(My255, 0, 1)

Take a look at the overloads for the Write method.

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer''s Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.


嗯,实际上你可以把它作为一个角色发送,只要你设置

流编码为ASCII


Dick Grier写道:
Well, actually you can send it as a character, as long as you set the
stream encoding to ASCII

Dick Grier wrote:



你不能发送作为一个角色,你必须像这样发送(或一些

变种;有几个,一些具有更紧凑的语法 - 我已拼写

它是为了清楚说明需要什么):


Dim My255()As Byte

My255(0)= 255

SerialPort.Write(My255,0,1)


看一下Write方法的重载。


迪克


-

Richard Grier,MVP

Hard&软件

Visual Basic程序员串行通信指南的作者,第四版

版,

ISBN 1-890422-28-2( 391页,包括CD-ROM)。 2004年7月,修订3月

2006.

www.hardandsoftware.net 了解详情和联系信息。
Hi,

You cannot send is as a character, you must send it like this (or some
variation; there are several, some with more compact syntax -- I''ve spelled
it out to make it clear what is needed):

Dim My255 () As Byte
My255(0) = 255
SerialPort.Write(My255, 0, 1)

Take a look at the overloads for the Write method.

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer''s Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.


有趣。你真的试过这个吗?您建议使用什么语法?

写不接受Stream,所以我很困惑。


Dick


-

Richard Grier,MVP

Hard&软件

Visual Basic程序员串行通信指南的作者,第四版

版,

ISBN 1-890422-28-2( 391页,包括CD-ROM)。 2004年7月,修订3月

2006.

www.hardandsoftware.net 了解详情和联系信息。
Interesting. Have you actually tried this? What syntax do you suggest?
Write does not accept a Stream, so I''m puzzled.

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer''s Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.


这篇关于将Chr(255)发送到串行端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆