|
-
Jul 29th, 2009, 04:17 AM
#1
Thread Starter
New Member
Need help socket programming!!
So i'm programming a program that collects data from a server and then displays temperature readings into textboxs. But the temp readings always come to 0. please help
Public Shared Sub RunClient()
Dim byte1, byte2, byte3 As Integer
Dim nodeID_raw, temp_raw1, temp_raw2, temp_String As String
Dim nodeID As Integer
Dim Client As TcpClient
Try
Client = New TcpClient()
Client.Connect("192.168.133.1", 9005)
output = Client.GetStream()
reader = New BinaryReader(output)
Try
Dim receieveBytes As Byte() = System.Text.Encoding.ASCII.GetBytes(message)
message = reader.ReadString
byte1 = Mid$(message, 12, 1) 'Node ID
byte2 = Mid$(message, 21, 1) 'Temperature
byte3 = Mid$(message, 22, 1)
nodeID_raw = Asc(byte1)
temp_raw1 = Asc(byte3)
temp_raw2 = Asc(byte2)
nodeID = nodeID_raw
temp_String = temp_raw1 & temp_raw2
temp = CDec("&H" & temp_String)
If ((temp < 500) Or (temp > 1000)) Then Exit Sub 'prevent no temp value
temp = ((1 / (0.00130705 + 0.000214381 * Math.Log((10000 * (1023 - temp)) / temp) + 0.000000093 * (Math.Log((10000 * (1023 - temp)) / temp) ^ 3))) - 273.15)
Catch ex As Exception
End Try
Catch ex As Exception
End Try
End Sub
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
|