|
-
Dec 16th, 2008, 09:48 PM
#1
Thread Starter
New Member
read from serial port
Hi,i am using serial communication to read from a plc.The plc will send a string :&H3A as a header byte then C(which is a variable that contains data)I want to read and mask out the header byte.I use the following code but cannot read anything.Any suggestions?
Private Sub btnread_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnread.Click
Msg = SerialPort1.ReadExisting
count = Val(Mid(Msg, 3, 2))
Lblno.Text = count
End Sub
-
Dec 17th, 2008, 10:20 AM
#2
Re: read from serial port
what version of vb are you using? are you saying the device sends (in hex) this
3AC
-
Dec 17th, 2008, 10:55 AM
#3
Thread Starter
New Member
Re: read from serial port
I am using vb.net 2005
The header byte &H3A is supposed to be ":"
and then it sends C which means i think it sends ":C"
-
Dec 17th, 2008, 01:56 PM
#4
Re: read from serial port
what does "The header byte &H3A... " mean? does the device send on a periodic basis?
-
Dec 17th, 2008, 08:28 PM
#5
Thread Starter
New Member
Re: read from serial port
Sorry but i am also not very sure about that but i think that the plc must send the header byte as to inform when the string starts.&H3A is like a short code for the simbol ":" And also if the plc does not send continuosly does it mean i must change the plc program to constantly send the string in order for my vb program to work?
-
Dec 18th, 2008, 08:40 AM
#6
Re: read from serial port
you really need to know the protocol of the PLC device. if you need to interrogate the device or not, when it sends, what it sends, what it means, etc.
ascii codes
Last edited by dbasnett; Dec 18th, 2008 at 08:44 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|