#21363 - 09/19/09 04:45 PM
How to read data from leopard in VB 2008 Express
|
tom21
newbie
Registered: 08/18/07
Posts: 17
|
Hi below is a script use in visual basic 2008 express. Its job is to change timer 2 to a value of 1. This works well and label 7 returns a value of 3 and i recieve in a message box: 06-00-06-00-00.
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Dim byteBuffer(8) As Byte byteBuffer(0) = 200 byteBuffer(1) = 41 byteBuffer(2) = 2 byteBuffer(3) = 1 byteBuffer(4) = 0 byteBuffer(5) = 1 byteBuffer(6) = 0 byteBuffer(7) = 245 SerialPort1.Open() SerialPort1.Write(byteBuffer, 0, 8)
Label7.Text = SerialPort1.BytesToRead()
Dim result(4) As Byte Dim bytesRead As Integer = SerialPort1.Read(result, 0, result.Length)
MessageBox.Show(BitConverter.ToString(result)) SerialPort1.Close()
End Sub
Now using a simalar script to above i have tried create a script to read the timer values.
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Dim byteBuffer(8) As Byte byteBuffer(0) = 42 byteBuffer(1) = 0 byteBuffer(2) = 0 byteBuffer(3) = 143 byteBuffer(4) = 169 byteBuffer(5) = 0 byteBuffer(6) = 13 byteBuffer(7) = 151 SerialPort1.Open() SerialPort1.Write(byteBuffer, 0, 8)
Label7.Text = SerialPort1.BytesToRead()
Dim result(256) As Byte Dim bytesRead As Integer = SerialPort1.Read(result, 0, result.Length)
MessageBox.Show(BitConverter.ToString(result)) SerialPort1.Close()
This returns a value in label 7 of 0 and the message box says: 2A-00-00-8F-A9-00-00-00-00-00-00-00-00-00-00-00-0A-0C-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-.............ETC.
This is not the result i was expecting and the SerialPort1.BytesToRead() should, i would think not returning a value of 0 but 256 the number of bytes to read. Can anyone see a problem
Thanks
tom
|
|
Top
|
|
|
|
#21367 - 09/20/09 02:51 AM
Re: How to read data from leopard in VB 2008 Express
[Re: Guy Lavoie]
|
tom21
newbie
Registered: 08/18/07
Posts: 17
|
Sorry Guy I did mean to say read variables not timers. However I have tried to read timers and get similar results. I don’t think the information received is correct because, apart from the first few bytes received the rest are 00 and I know the first 50 variables are of some value other than 0 on my controller.
|
|
Top
|
|
|
|
#21370 - 09/20/09 03:47 PM
Re: How to read data from leopard in VB 2008 Express
[Re: tom21]
|
tom21
newbie
Registered: 08/18/07
Posts: 17
|
Hi
some more infomation about my problem
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click Dim byteBuffer(8) As Byte byteBuffer(0) = 42 byteBuffer(1) = 0 byteBuffer(2) = 0 byteBuffer(3) = 1 byteBuffer(4) = 176 byteBuffer(5) = 0 byteBuffer(6) = 148 byteBuffer(7) = 39 SerialPort1.Open() SerialPort1.Write(byteBuffer, 0, 8) Label7.Text = SerialPort1.BytesToRead() Dim result(256) As Byte Dim bytesRead As Integer = SerialPort1.Read(result, 0, result.Length) RichTextBox1.Text = (BitConverter.ToString(result)) SerialPort1.Close() End Sub
When the script above is run below is what is returned. It all seems good because there is the 6 byte header followed by the Hex values, FE, 05,0b, 0D, 05, FE, FE which in Dec are 254, 11, 13, 05, 254, 254. Mod#1 on my Leopard is not connected at the moment hence the value 254 (I think) but Mod#2 is a Bobcat T, Mod#3 is a SECU-16, Mod#4 is a RLY08 and Mod#5 another Bobcat T so according to “Serial Protocol Information” the received data is correct and the above script is good. Although I am wondering why the “FE” values start becoming “00” values
2A-00-00-01-B0-00-FE-05-0B-0D-05-FE-FE-FE-FE-FE-FE-FE-FE-FE-FE-FE-FE-FE-FE-FE-FE-FE-FE-FE-FE-FE-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
When this script below is run, which is the same as above apart from the Byte values being sent to the Leopard, it returns the values shown below the script. I think this should return my variable values but the majority of the values returned are 00 so I can tell straight away that it’s not a list of my variables. Any help on what I am doing wrong would be much appreciated.
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click Dim byteBuffer(8) As Byte byteBuffer(0) = 42 byteBuffer(1) = 0 byteBuffer(2) = 0 byteBuffer(3) = 143 byteBuffer(4) = 169 byteBuffer(5) = 0 byteBuffer(6) = 13 byteBuffer(7) = 151 SerialPort1.Open() SerialPort1.Write(byteBuffer, 0, 8) Label7.Text = SerialPort1.BytesToRead() Dim result(256) As Byte Dim bytesRead As Integer = SerialPort1.Read(result, 0, result.Length) RichTextBox1.Text = (BitConverter.ToString(result)) SerialPort1.Close() End Sub
2A-00-00-8F-A9-00-00-00-00-00-00-00-00-00-00-00-0A-0C-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
Thanks
Edited by tom21 (09/20/09 03:49 PM)
|
|
Top
|
|
|
|
#21376 - 09/21/09 01:06 PM
Re: How to read data from leopard in VB 2008 Express
[Re: Guy Lavoie]
|
tom21
newbie
Registered: 08/18/07
Posts: 17
|
These are the variables listed and straight after I read these I ran the read variable script and got the reply below.
Var 1= 24 Var 2= 24 Var 3= 0 Var 4= 21 Var 5= 20 Var 6= 2 Var 7= 3 Var 8= 0 Var 9= 0 Var 10= 1 Var 11= 0 Var 12= 199 Var 13= 6 Var 14= 30 Var 15= 0 Var 16= 95 Var 17= 0 Var 18= 65436
2A-00-00-8F-A9-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
This is the script (Below) I ran straight after reading the variables to get the reply above
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click Dim byteBuffer(8) As Byte byteBuffer(0) = 42 byteBuffer(1) = 0 byteBuffer(2) = 0 byteBuffer(3) = 143 byteBuffer(4) = 169 byteBuffer(5) = 0 byteBuffer(6) = 13 byteBuffer(7) = 151 SerialPort1.Open() SerialPort1.Write(byteBuffer, 0, 8)
Label7.Text = SerialPort1.BytesToRead() Dim result(256) As Byte Dim bytesRead As Integer = SerialPort1.Read(result, 0, result.Length) RichTextBox1.Text = (BitConverter.ToString(result)) SerialPort1.Close() End Sub
|
|
Top
|
|
|
|
#21377 - 09/21/09 03:04 PM
Re: How to read data from leopard in VB 2008 Express
[Re: tom21]
|
tom21
newbie
Registered: 08/18/07
Posts: 17
|
I have a “sort of” result. I have changed the script to two separate commands, one to send and one to receive. So my new script below is to ask for the variable values.
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click Dim byteBuffer(8) As Byte byteBuffer(0) = 42 byteBuffer(1) = 0 byteBuffer(2) = 0 byteBuffer(3) = 143 byteBuffer(4) = 169 byteBuffer(5) = 0 byteBuffer(6) = 13 byteBuffer(7) = 151 SerialPort1.Open() SerialPort1.Write(byteBuffer, 0, 8)
End Sub
This is sent to the controller and shortly after i run a second script.
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Label7.Text = SerialPort1.BytesToRead() Dim result(265) As Byte Dim bytesRead As String = SerialPort1.Read(result, 0, 265) RichTextBox1.Text = (BitConverter.ToString(result)) SerialPort1.Close()
End Sub
I now receive a “bytes to read” value of “264” instead of the “0” I was getting before and the reply is
2A-00-00-8F-A9-00-00-00-00-00-00-00-00-00-00-00-0A-0C-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-5F-00-C7-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-38-01-00-00-00-00-00-00-00-00-00-00-00-00-00-00-07-01-72-FE-00-00-00-00-00-00-00-00-00-00-00-00-9A-FF-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-12-7D-00-00
I notice every time I ask for a reply the values in red where changing, so after converting to decimal I could see the value 72-FE = 114-254 which would convert to 65138, approx the same as one of my timers. So I set timer#0 going from 100 and timer#63 from 200 then the values in bold (Black) now changed from 00-00 and started to change every time I ran the above script. The 12-7D seems a bit strange though but even more strange is when I ask for the variables I get the timers. So the next thing to do was ask for the timers, but I didn’t receive anything that made sense to me. See below
2A-00-00-0F-A9-00-7E-7E-7E-7E-7E-7E-7E-7E-7E-7E-7E-7E-7E-7E-7E-7E-7E-16-00-32-09-15-00-00-01-09-5A-05-08-01-4D-0F-30-39-2F-32-31-2F-30-39-20-31-30-3A-35-30-20-50-4D-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-31-00-00-04-01-04-07-01-00-FF-00-A0-04-12-80-86-00-3D-00-3D-00-FF-00-67-01-43-04-03-03-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-0A-0C-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-5F-00-C7-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-0C-5F-00-00
Something to add is the variables listed on my previous post are still the variables I should be receiving and some of the values above change every time I ask.
Edited by tom21 (09/21/09 03:05 PM)
|
|
Top
|
|
|
|
Moderator: Dan Smith, Monte G, ADI Tech Support, Guy Lavoie
|
2747 Members
19 Forums
3837 Topics
22713 Posts
Max Online: 67 @ 08/16/11 03:08 PM
|
|
|
|
|
|
1
|
2
|
3
|
4
|
|
5
|
6
|
7
|
8
|
9
|
10
|
11
|
|
12
|
13
|
14
|
15
|
16
|
17
|
18
|
|
19
|
20
|
21
|
22
|
23
|
24
|
25
|
|
26
|
27
|
28
|
29
|
|
|
|
|
|