Measurement Studio for .NET Languages

Showing results for 
Search instead for 
Did you mean: 

Error on ReadSingleSampleInt32



I'm having an issue where a ReadSingleSampleInt32 call results in an error.  Some background:

I have a counter which counts pulses.  It gets initialized/started as follows:


CountPulseTask = New Task()
CountPulseTask.CIChannels.CreateCountEdgesChannel("/" & DAQName & CountPulseCounter, _
                                                  "CountPulses", CICountEdgesActiveEdge.Rising, 0, _
CountPulseTask.CIChannels.All.CountEdgesTerminal = "/" & DAQName & PressurePulseOutputChannel
CountPulseReader = New CounterSingleChannelReader(CountPulseTask.Stream)

Then, every 100ms (via .NET timer control), I obtain the count as follows:



    Public Function GetCount(ByRef ErrMsg As String) As Long
        Dim tmpCount As Long
            tmpCount = CountPulseReader.ReadSingleSampleInt32()
        Catch ex As Exception
            ErrMsg = ex.Message
            GetCount = ErrLong
            Exit Function
        End Try
        GetCount = tmpCount
    End Function

I've got an intermittent but reliable situation where the GetCount sub throws an exception--sometimes after 8k counts, sometimes after millions of counts.  I haven't seen this issue on my dev system, but my client has seen the error on their deployment system.  As a result, debug information is limited--I know that makes diagnosis very difficult.


But i'm wondering if anyone is aware of any reasons why a ReadSingleSampleInt32 call would work fine for millions of cycles, and then all of a sudden throw an exception. Not knowing the specific error, it's been hard to search the forums for possibilities.  I can confirm with near certainty that the counter task is still valid and running.


Any thoughts would be greatly appreciated.





0 Kudos
Message 1 of 3


Do you have any more information on the exception that is being thrown itself? Is it a DaqException or an OutOfMemoryException? 

Especially because this is happening at a client site (and not necessarily on your computer) it's possible that the computer they are running this on is less powerful than yours (less memory) or they have a lot of other operations running on the computer. This could lead to an out of memory exception. What does the resource usage look like on the client computer when the program is running?

ReadSingleSampleUInt32 Method::

DaqException Class::

R. Dahlman

0 Kudos
Message 2 of 3


Thanks for the response!  I added some debug capabilities to the application running on my client's computer and discovered that an error handler for another procedure was causing the task to be stopped/disposed.  So...user error on my part.



0 Kudos
Message 3 of 3