473,545 Members | 2,663 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Port Name = "COM1"
SerialPort.Baud Rate = 9600
SerialPort.Stop Bits = IO.Ports.StopBi ts.One
SerialPort.Data Bits = 8
SerialPort.Pari ty = IO.Ports.Parity .None

If SerialPort.IsOp en = False Then
SerialPort.Open ()
End If

How to send and receive data???

??? SerialPort.Writ e(??????)
??? TextBox1.Text = SerialPort.Read Existing

SerialPort.Clos e()

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 31240
Dim xmtBuf() as byte = {&HFF,&H1,&HC3, &HE3,&HFF,&H FF}
SerialPort.Writ e(xmtBuf,0,xmtB uf.Length)

Dim rcvBuf(1024) as byte
SerialPort.Read (rcvBuf,0,rcvBu f.Length)

http://msdn2.microsoft.com/en-us/lib...rt(VS.80).aspx
"Adriano" <ad*****@mail.i twrote in message
news:uJ******** ******@TK2MSFTN GP05.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.Port Name = "COM1"
SerialPort.Baud Rate = 9600
SerialPort.Stop Bits = IO.Ports.StopBi ts.One
SerialPort.Data Bits = 8
SerialPort.Pari ty = IO.Ports.Parity .None

If SerialPort.IsOp en = False Then
SerialPort.Open ()
End If

How to send and receive data???

??? SerialPort.Writ e(??????)
??? TextBox1.Text = SerialPort.Read Existing

SerialPort.Clos e()

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.Writ e(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******@hotma il.comñîîáùèë/ñîîáùèëà â íîâîñòÿõ ñëåäóþùåå:
news:%2******** *******@TK2MSFT NGP04.phx.gbl.. .
Dim xmtBuf() as byte = {&HFF,&H1,&HC3, &HE3,&HFF,&H FF}
SerialPort.Writ e(xmtBuf,0,xmtB uf.Length)

Dim rcvBuf(1024) as byte
SerialPort.Read (rcvBuf,0,rcvBu f.Length)

http://msdn2.microsoft.com/en-us/lib...rt(VS.80).aspx
"Adriano" <ad*****@mail.i twrote in message
news:uJ******** ******@TK2MSFTN GP05.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.Port Name = "COM1"
SerialPort.Baud Rate = 9600
SerialPort.Stop Bits = IO.Ports.StopBi ts.One
SerialPort.Data Bits = 8
SerialPort.Pari ty = IO.Ports.Parity .None

If SerialPort.IsOp en = False Then
SerialPort.Open ()
End If

How to send and receive data???

??? SerialPort.Writ e(??????)
??? TextBox1.Text = SerialPort.Read Existing

SerialPort.Clos e()

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
3499
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 accross the internet... I've tested this with multiple connections. If I run the same server and client, connect them locally I don't have a...
1
3776
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 after i send data into it? I simply want to open socket, send data, close socket and have the server just handle one client thread to recieve...
4
3559
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 printer port. I've tried to help myself with this one but searching in the "Python Library Reference" that installed with my version, yielded nothing...
9
8424
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 port ie to send data and to read the state of the parallel port including the control lines. Can anyone help/point me in the correct direction? I...
4
8193
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 TcpClient, NetworkStream and StreamWriter classes. but with low level socket it doesn't work (When using the Socket class Send method).
0
1781
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 3-5 minutes. I tested with PHP 5.2, PHP 4.4, PHP 4.2.3 - with same results. I switched from MySQL 4.2.18 to 4.2.21 and 4.2.22 with same result.
1
1658
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 to? Any other suggestions? Also, what port do Http responses target on client machine before being rendered in browser? Thanks,
3
6627
by: Mateo | last post by:
(As.Net 1.1 framework!) Hi! So, I have problem as described in subject. Here is source code:
3
2636
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 can be sent? For example could a program be tunnelled through from the host to the client - like the way netcat allows programs to be executed after a...
0
7490
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7935
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7780
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5351
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5069
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3479
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3465
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
734
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.