943,147 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 1846
  • VB.NET RSS
Jan 18th, 2010
0

VB.NET 2008 serial port Issue

Expand Post »
Hi i am trying to write-read data from serial port but it don't work
my code look like this

VB.NET Syntax (Toggle Plain Text)
  1. Private comPort As New SerialPort
  2.  
  3. comPort.PortName = cboCom.Text
  4. comPort.Parity = Parity.None
  5. comPort.DataBits = 8
  6. comPort.StopBits = StopBits.One
  7. comPort.BaudRate = CInt(cboSpeed.Text)
  8. comPort.Handshake = Handshake.None
  9.  
  10. comPort.Open()
  11. 'Write GPS command
  12. comPort.WriteLine("$PSRF103,00,00,01,01*25")
and the result is my device don't listen and i dont know WHY!!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
iamai is offline Offline
17 posts
since Oct 2009
Jan 18th, 2010
0
Re: VB.NET 2008 serial port Issue
Click to Expand / Collapse  Quote originally posted by iamai ...
Hi i am trying to write-read data from serial port but it don't work
my code look like this

VB.NET Syntax (Toggle Plain Text)
  1. Private comPort As New SerialPort
  2.  
  3. comPort.PortName = cboCom.Text
  4. comPort.Parity = Parity.None
  5. comPort.DataBits = 8
  6. comPort.StopBits = StopBits.One
  7. comPort.BaudRate = CInt(cboSpeed.Text)
  8. comPort.Handshake = Handshake.None
  9.  
  10. comPort.Open()
  11. 'Write GPS command
  12. comPort.WriteLine("$PSRF103,00,00,01,01*25")
and the result is my device don't listen and i dont know WHY!!

I find it!
the problem was on the line
comPort.Writeline("fdsfsdfsdfa")
and the correct is
comPort.Write("fsdfsdfsda" + vbCrLf)
thanks anyway
Reputation Points: 10
Solved Threads: 0
Newbie Poster
iamai is offline Offline
17 posts
since Oct 2009
Jan 18th, 2010
0
Re: VB.NET 2008 serial port Issue
Ok but my program is very slow now
it take too much time to display the serial data to the listbox
is any better method to do this?
please advice me


VB.NET Syntax (Toggle Plain Text)
  1.  
  2. Private comPort As New SerialPort
  3. comPort.PortName = cboCom.Text
  4. comPort.Parity = Parity.None
  5. comPort.DataBits = 8
  6. comPort.StopBits = StopBits.One
  7. comPort.BaudRate = CInt(cboSpeed.Text)
  8. comPort.Handshake = Handshake.None
  9. comPort.ReadTimeout = 1000
  10. comPort.WriteTimeout = 1000
  11. comPort.Open()
  12.  
  13.  
  14. Private Sub query_GGA()
  15. comPort.Write("$PSRF103,00,01,00,01*25" + vbCrLf)
  16. gga_string = comPort.ReadLine
  17. ListGPS.Items.Add(gga_string)
  18. End Sub
  19.  
  20. Private Sub query_GLL()
  21. comPort.Write("$PSRF103,01,01,00,01*24" + vbCrLf)
  22. gll_string = comPort.ReadLine
  23. ListGPS.Items.Add(gll_string)
  24. End Sub
  25. Private Sub query_GSA()
  26. comPort.Write("$PSRF103,02,01,00,01*27" + vbCrLf)
  27. gsa_string = comPort.ReadLine
  28. ListGPS.Items.Add(gsa_string)
  29. End Sub
  30. Private Sub query_GSV()
  31. comPort.Write("$PSRF103,03,01,00,01*26" + vbCrLf)
  32. gsv_string(0) = comPort.ReadLine
  33. gsv_string(1) = comPort.ReadLine
  34. gsv_string(2) = comPort.ReadLine
  35. ListGPS.Items.Add(gsv_string(0))
  36. ListGPS.Items.Add(gsv_string(1))
  37. ListGPS.Items.Add(gsv_string(2))
  38. End Sub
  39. Private Sub query_RMC()
  40. comPort.Write("$PSRF103,04,01,00,01*21" + vbCrLf)
  41. rmc_string = comPort.ReadLine
  42. ListGPS.Items.Add(rmc_string)
  43. End Sub
  44. Private Sub query_VTG()
  45. comPort.Write("$PSRF103,05,01,00,01*20" + vbCrLf)
  46. vtg_string = comPort.ReadLine
  47. ListGPS.Items.Add(vtg_string)
  48. End Sub
  49.  
  50. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  51. query_GGA()
  52. query_GLL()
  53. query_GSA()
  54. query_GSV()
  55. query_RMC()
  56. query_VTG()
  57. End Sub
Last edited by iamai; Jan 18th, 2010 at 12:57 pm. Reason: nothing
Reputation Points: 10
Solved Threads: 0
Newbie Poster
iamai is offline Offline
17 posts
since Oct 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: show menu items on vb.net application based on user rights
Next Thread in VB.NET Forum Timeline: Skip column in datagridview





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC