 |
 |

11-25-2003, 06:27 AM
|
|
Newcomer
|
|
Join Date: Nov 2003
Location: Chandigarh, India
Posts: 5
|
|
Timer Event
|
Hi,
I've written a piece of hardware interfacing code, where a certain array is populated with real time data from the hardware. On top of this sits a little winsock server, serving data as requested, to client connections, from this array.
On the other end (separate application), I'm using ioComp iPlotX graphing control, with a timer set to fire every 1ms (probably firing every 55ms actually) that queries the winsock server above and receives data. this happens on every timer event. when the data comes through, it is graphed using the control. The code is currently doing 4 iterations (data fetch->graph cycles) on every timer event.
All ok so far!
The problem is that (after poring over the code), the code doesn't seem to be able to exit the procedure before the next timer event is generated. Considering the code is small, I cannot see how this is happening. My basis for the above assumption is that debug.print shows a single entry into the procedure, two loops and then another entry into the procedure and so on... but no exit!
The code is below... any and all help is most welcome!!
Thanks,
Sid
Private Sub graphTimer_Timer()
Debug.Print "entry"
Dim strChannelTag As String
For dispChannel = 0 To Plot.ChannelCount - 1
' packet format will be - "Channel1, Channel2"
' send the channel tag directly
strChannelTag = frmGraphData.Plot.Channel(dispChannel).Tag
If isConnected Then
Debug.Print "in connected", dispChannel
' send the packet
EEGClient.SendData strChannelTag & "*"
' receive data packet
' packet format will be - "ChannelValue1, ChannelValue2*"
EEGClient.GetData strChannelValue
If Len(strChannelValue) > 0 Then
' get the position of the star
starPos = InStr(strChannelValue, "*")
' get the string before that point
strChannelValue = Left(strChannelValue, starPos - 1)
End If
' parse the packet
' get the position of the comma
commaPos = InStr(strChannelValue, ",")
' we have the position
' if there is no comma, value will be zero
' malformed packet will indicate comma at the end
' packet format will be - "Channel1, Channel2"
If commaPos = 0 Or commaPos = Len(strChannelValue) Then
Exit Sub
End If
' extract the channel numbers and convert them to
' numeric values
lngChannelOneValue = Val(Trim(Mid(strChannelValue, 1, commaPos)))
lngChannelTwoValue = Val(Trim(Mid(strChannelValue, commaPos + 1)))
End If
graphval = lngChannelOneValue - lngChannelTwoValue
X = Plot.Channel(dispChannel).AddXY(runningX, graphval)
Next dispChannel
runningX = runningX + 1
Debug.Print "exit"
dispChannel = 0
End Sub
|
|

11-25-2003, 06:57 AM
|
 |
MetaCenturion
Retired Moderator * Guru *
|
|
Join Date: Aug 2001
Location: California, USA
Posts: 16,583
|
|
What is the value for Plot.ChannelCount in the loop?
I also notice that you are Exiting Sub... this won't print the Debug.Print "exit" you get when the loop ends. You need Exit For for that, but you probably already knew that. 
|
|

11-25-2003, 09:56 PM
|
|
Newcomer
|
|
Join Date: Nov 2003
Location: Chandigarh, India
Posts: 5
|
|
Hi, Thanks for your reply.
The channel count is 4, thats why it does 4 iterations. When I make it one, the thing executes properly.
The exit subs are on errors actually, and I don't really expect them to occur... :-)
Any ideas?
Thanks,
Sid
Quote: Originally Posted by Iceplug What is the value for Plot.ChannelCount in the loop?
I also notice that you are Exiting Sub... this won't print the Debug.Print "exit" you get when the loop ends. You need Exit For for that, but you probably already knew that. 
|
|

11-25-2003, 11:23 PM
|
|
Newcomer
|
|
Join Date: Nov 2003
Location: Chandigarh, India
Posts: 5
|
|
|
Thanks! While that 'Exit sub' wasn't the problem, it sure as hell was an indicator. I was getting malformed packets, which caused that IF to execute and exitted the sub. Now all parsing ops are within the 'If xyz len > 0' condition... and its working!
Thanks again!!
Sid
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|