11-14-2006 05:13 AM
11-15-2006 07:53 AM
11-23-2006 04:08 AM
11-23-2006 07:15 AM
I got back to a very simple project 🙂
Here is the way I tried to convert a ReadMultiSampleAsync project into a WriteMultiSampleAsync project, using my own function generator library.
If I use WriteMultiSampleAsync, I get a "Unhandled exception at 0x6daf0c34 in ContAcqVoltageSamples_IntClk.exe: 0xC0000005: Access violation reading location 0x01f340a8." If I replace WriteMultiSampleAsync by WriteMultiSample, I have no such error.
Does somebody know what I am doing wrong? Or does somebody has a WriteMultiSampleAsync example?
11-24-2006 11:21 AM
Hi,
apologies for the delay.
In the startup section, you're using the asynchronous write, which given the speed of code execution, might not have finished writing the matrix to the buffer before you're actually starting it and it might not have established the full buffer area, so the next write is looking for memory that doesn't necessarily belong to the application at that point.
You always need to make sure that your initial write for a timed output has put all the buffer information written before you start.
You need to do one of two things around line 257
// Begin reading data
m_writer = std::auto_ptr<CNiDAQmxAnalogMultiChannelWriter>
(new CNiDAQmxAnalogMultiChannelWriter(m_task->Stream));
m_writer->InstallEventHandler(*this, OnEvent);
// NI Mod
//m_writer->WriteMultiSampleAsync(true, matrix, NULL);
// make sure the buffer is ready to start with.
m_writer->WriteMultiSample(false,matrix);
// End NI Mod
or you can do the WriteMultiSampleAsync, just wait using the return object from that function to see if it's finished writing first.
// Begin reading data
m_writer = std::auto_ptr<CNiDAQmxAnalogMultiChannelWriter>
(new CNiDAQmxAnalogMultiChannelWriter(m_task->Stream));
m_writer->InstallEventHandler(*this, OnEvent);
// NI Mod
//m_writer->WriteMultiSampleAsync(true, matrix, NULL);
CNiDAQmxAsyncOperation m_checkme;
// make sure the buffer is ready to start with.
m_checkme = m_writer->WriteMultiSampleAsync(false,matrix, 0);
m_checkme.WaitUntilDone(10000);
// End NI Mod
The upshot of the second method is you need to be careful about when the second write occurs, and how much data you write the second time (make sure you're writing half the buffer or less comapred to the amount initially written around line 257.
Hope that helps
Thanks
Sacha Emery
National Instruments (UK)
11-24-2006 11:27 AM
Hi,
here's another starting point to track through - hope that helps
Thanks
Sacha Emery
National Instruments (UK)
11-30-2006 07:53 AM
Hi SachaE,
I am sorry for the delay coming back to you. I really appreciate what you're doing for me! I have tried you solution and it works fine! I would never have though about that by myself to be honnest! I have been trying to use your solution as a new starting point but i have to say I am still struggling about a particular point.
My aim is to get my card send a signal continuously with a start and stop button.
I have tried two different things to do that, but none of them is working. I must be misusing the provided API again! ![]()
I include source code of both projects in this message. I defenetly must be doing something clumsy. Can you point me towards a new idea? ![]()
Thanks again !
12-12-2006 07:17 AM
Hi SachaE,
Do you have any idea about the previous post I have written?
Thank a lot for you help so far!
Rad