Hello,
I'm developing an application in VB.NET 2005 that communicates with a device
through RS232,
and need to send the following sequence of hexadecimal data to the device:
0xFF, 0x01, 0xC3, 0xE3, 0xFF, 0xFF.
That's the configuration:
SerialPort.PortName = "COM1"
SerialPort.BaudRate = 9600
SerialPort.StopBits = IO.Ports.StopBits.One
SerialPort.DataBits = 8
SerialPort.Parity = IO.Ports.Parity.None
If SerialPort.IsOpen = False Then
SerialPort.Open()
End If
How to send and receive data???
??? SerialPort.Write(??????)
??? TextBox1.Text = SerialPort.ReadExisting
SerialPort.Close()
p.s. according to manual, the responce of device is also in hexadeciaml
format, smt. like 0xFF, 0x01, 0xC3, 0x00, 0x05, 0xFF
Any help would be greatly appreciated,
thanks in advance,
Adriano 3 30818
Dim xmtBuf() as byte = {&HFF,&H1,&HC3,&HE3,&HFF,&HFF}
SerialPort.Write(xmtBuf,0,xmtBuf.Length)
Dim rcvBuf(1024) as byte
SerialPort.Read(rcvBuf,0,rcvBuf.Length) http://msdn2.microsoft.com/en-us/lib...rt(VS.80).aspx
"Adriano" <ad*****@mail.itwrote in message
news:uJ**************@TK2MSFTNGP05.phx.gbl...
Hello,
I'm developing an application in VB.NET 2005 that communicates with a
device through RS232,
and need to send the following sequence of hexadecimal data to the device:
0xFF, 0x01, 0xC3, 0xE3, 0xFF, 0xFF.
That's the configuration:
SerialPort.PortName = "COM1"
SerialPort.BaudRate = 9600
SerialPort.StopBits = IO.Ports.StopBits.One
SerialPort.DataBits = 8
SerialPort.Parity = IO.Ports.Parity.None
If SerialPort.IsOpen = False Then
SerialPort.Open()
End If
How to send and receive data???
??? SerialPort.Write(??????)
??? TextBox1.Text = SerialPort.ReadExisting
SerialPort.Close()
p.s. according to manual, the responce of device is also in hexadeciaml
format, smt. like 0xFF, 0x01, 0xC3, 0x00, 0x05, 0xFF
Any help would be greatly appreciated,
thanks in advance,
Adriano
Hi,
To add to what Terry posted:
Dim Buffer() As Byte = {&HFF, &H01, &HC3, &HE3, &HFF, &HFF)
SerialPort.Write(Buffer, 0, 6) 'for example
--
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.
Thanks Terry,
seems it worked!
Regards,
Adriano
"Terry Olsen" <to******@hotmail.comñîîáùèë/ñîîáùèëà â íîâîñòÿõ ñëåäóþùåå:
news:%2***************@TK2MSFTNGP04.phx.gbl...
Dim xmtBuf() as byte = {&HFF,&H1,&HC3,&HE3,&HFF,&HFF}
SerialPort.Write(xmtBuf,0,xmtBuf.Length)
Dim rcvBuf(1024) as byte
SerialPort.Read(rcvBuf,0,rcvBuf.Length)
http://msdn2.microsoft.com/en-us/lib...rt(VS.80).aspx
"Adriano" <ad*****@mail.itwrote in message
news:uJ**************@TK2MSFTNGP05.phx.gbl...
>Hello,
I'm developing an application in VB.NET 2005 that communicates with a device through RS232, and need to send the following sequence of hexadecimal data to the device:
0xFF, 0x01, 0xC3, 0xE3, 0xFF, 0xFF.
That's the configuration:
SerialPort.PortName = "COM1" SerialPort.BaudRate = 9600 SerialPort.StopBits = IO.Ports.StopBits.One SerialPort.DataBits = 8 SerialPort.Parity = IO.Ports.Parity.None
If SerialPort.IsOpen = False Then SerialPort.Open() End If
How to send and receive data???
??? SerialPort.Write(??????) ??? TextBox1.Text = SerialPort.ReadExisting
SerialPort.Close()
p.s. according to manual, the responce of device is also in hexadeciaml format, smt. like 0xFF, 0x01, 0xC3, 0x00, 0x05, 0xFF
Any help would be greatly appreciated,
thanks in advance, Adriano This discussion thread is closed Replies have been disabled for this discussion. Similar topics
2 posts
views
Thread by UrgeOverkill |
last post: by
|
1 post
views
Thread by Daniel |
last post: by
|
4 posts
views
Thread by David |
last post: by
|
9 posts
views
Thread by MNQ |
last post: by
|
4 posts
views
Thread by yaron |
last post: by
|
reply
views
Thread by vladimir.plotnikov |
last post: by
|
1 post
views
Thread by Charlie |
last post: by
|
3 posts
views
Thread by Mateo |
last post: by
| | | | | | | | | | | |