473,287 Members | 1,643 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

Help sending hex data through SerialPort

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
Jul 19 '07 #1
3 31174
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

Jul 19 '07 #2
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.
Jul 19 '07 #3
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


Jul 20 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: UrgeOverkill | last post by:
I'm having a problem sending data from a socket server. The server side reports that it has sent 4845 bytes but the client reports only 1448 bytes received. The kicker is that this ONLY happens...
1
by: Daniel | last post by:
after opening socket, sending data then closing socket 3000 times i get "Only one usage of each socket address" what am i doing wrong? is there some thing else i need to do to free up the socket...
4
by: David | last post by:
I'm wondering if python is capable of fairly precise timing and also sending data out the parallel port. For example ; making a 7.5 KHz square wave come out of one of the data pins on the...
9
by: MNQ | last post by:
Hi All I want to use my parallel port of my PC to control some external devices. I am writing a program in ANSI C using the PacificC compiler. What I need to know is how to access the parallel...
4
by: yaron | last post by:
Hi, I have a problem when sending data over TCP socket from c# client to java server. the connection established ok, but i can't send data from c# client to java server. it's work ok with...
0
by: vladimir.plotnikov | last post by:
Hello! I have problem: I have IPB forum installed. After search in IPB (search takes about 3-4 seconds for post table about 300 000 records) mysql shows "Sending Data" status and takes about...
1
by: Charlie | last post by:
Hi: I need a way to test my TcpListner, but not sure what applications are sending data to tcp ports. How about Email or Instant Messenger? If they are tcp, what ports are they sending data...
3
by: Mateo | last post by:
(As.Net 1.1 framework!) Hi! So, I have problem as described in subject. Here is source code:
3
WhiteRider
by: WhiteRider | last post by:
I have some basic knowledge of socket programming in Python. Up to now all I have been able to do when establishing a socket is sending a string to a client, what I would like to know is what else...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.