|
-
November 2nd, 2003, 02:58 PM
#1
Mscomm
Hello All-
This is my fist time posting on the board but I read your information all the time. I haven't been able to find exactly what I need to hopefully someone is out there who can address my question.
So....
As a part of my senior project, I'm hooking up a GPS unit to my computer through VB6, which posts paragraphs of data every second. It will be used to load the coordinates into a MYSQL database to be used for a vehicle tracking webpage. My problem arises with the MSCOMM control. I am using a click control that periodically calls the MSCOmm1_oncomm() subroutine. With in this subroutine I ask if MSCOMM1.commevent has happened because once the recieve buffer has something in it, i want it to download the whole paragraph for that second from the receive buffer. My non functioning code is as follows:
********************************************
Private Sub MSComm1_OnComm()
'set up the comm ports to 4800 baud
MSComm1.CommPort = 1
MSComm1.Settings = "4800, N, 8, 1" specified by the GPS
MSComm1.InputLen = 0 'indetermined amount of data
MSComm1.PortOpen = True
MSComm1.RThreshold = 1
waiting:
If MSComm1.CommEvent = comEvReceive Then
'For pointer = 1 To 30000000
'Next pointer
For pointer = 1 To 300 'cheexy delay so i get all the
Next pointer 'of the paragraph
buffer = MSComm1.Input 'takes what is in the receive buffer
Print buffer
Else: GoTo waiting
End If
MSComm1.PortOpen = False
End Sub
*************************************************
now I know that the gps can communicate with the code because when I step through it, the code downloads and the buffer has the data in it. I have also tried to put all this code under the click control and not calling a sub routine. Both do not work. My problem is, when I just execute the program, it gets locked into the wait loop forever. For some reason the condition never happens that MSCOMM1.commevent = 2. But then if I ctrl break the program and print the contents of MSCOMM1.commevent it is equal to 0, i guess meaning no events or errors have occured. But then if I step through one "waiting" loop again, the program seems to works.
Any hints or suggestions would be really needed, especially since this needs to be done by friday. Ohh yeah, I have gotten it to work if I use this code
*************************************************
'set up the comm ports to 4800 baud
MSComm1.CommPort = 1
MSComm1.Settings = "4800, N, 8, 1" specified by the GPS
MSComm1.InputLen = 0 'indetermined amount of data
MSComm1.PortOpen = True
For pointer = 1 To 30000000 'this is just a one second delay
on my machine
Next pointer
buffer = MSComm1.Input 'takes what is in the receive buffer
Print buffer
MSComm1.PortOpen = False
******************************************
Thanks again for your help in advance. I really appreciate it.
Marko
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
|