Serial Port

D

Denis R Charron

Hi
How can I send what I type in a textbox to a serial port has hexadecimal

AA BE 02 80 51 00 00 00 00 00 02 80 08 00 00 00

I want to send the above line to my serial port
 
D

Dick Grier

Hi,

Here is a (long-hand) way:

Dim Buffer (15) As Byte
Buffer (0) = &HAA
Buffer (1) = &HBE
Buffer (2) = &H2
Buffer (3) = &H80
Buffer (4) = &H51
Buffer (5) = 0
Buffer (6) = 0
Buffer (7) = 0
Buffer (8) = 0
Buffer (9) = 0
Buffer (10) = &H2
Buffer (11) = &H80
Buffer (12) = &H80
Buffer (13) = 0
Buffer (14) = 0
Buffer (15) = 0

SerialPort.Write(Buffer, 0, Buffer.Length)

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.
 
D

Dick Grier

BTW, my previous reply assumed VS2005, and System.IO.Ports. If you are
using VisualStudio 2003, you can download DesktopSerialIO from my homepage.
Create a buffer of hex data (Byte array), and do use the Output method:

Serialport.Output(Buffer)

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top