Waiting for VISA c# on QR

I am trying to write a simple program in c# (.NET 4.0) to control a Keithley 2400 SMU by VISA GPIB and I'm unable to switch to the program to wait as the demand for services which the Keithley send at the end of the scan.

The scan is a scan of simple linear voltage controlled internally by the unit Keithley. I have the device configured to receive a ServiceRequest signal at the end of the scan, or when compliance is reached.

I am able to send orders to the SMU and read data buffer, but only if I manually enter a timeout between the scan start command and the command to read data.

A question that I have is that I'm quite new to c# - I use this project (some parts of my code LV Portage) to learn it.

Here's what I have so far for my c# code:

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading;using NationalInstruments.VisaNS;

private void OnServiceRequest(object sender, MessageBasedSessionEventArgs e){    Console.WriteLine("Service Request Received!");}

// open the address
Console.WriteLine("Sending Commands to Instrument");
instrAddr = "GPIB0::25::INSTR";
mySession = ResourceManager.GetLocalManager().Open(instrAddr);
// Cast to message-based session
mbSession = (MessageBasedSession)mySession;
// Here's where things get iffy for me... Enabling the event and whatnot
mbSession.ServiceRequest += new MessageBasedSessionEventHandler(OnServiceRequest);
MessageBasedSessionEventType srq = MessageBasedSessionEventType.ServiceRequest;
mbSession.EnableEvent(srq, EventMechanism.Handler);

// Start the sweep (SMU was set up earlier)
Console.WriteLine("Starting Sweep");
mbSession.Write(":OUTP ON;:INIT");

int timeout = 10000;             // milliseconds
// Thread.Sleep(10000);          // using this line works fine, but it means the test always takes 10s even if compliance is hit early
// This raises error saying that the event is not enabled.mbSession.WaitOnEvent(srq, timeout);
// Turn off the SMU.Console.WriteLine("I hope the sweep is done, cause I'm tired of waiting");
mbSession.Write(":OUTP OFF;:TRAC:FEED:CONT NEV");
// Get the data string data = mbSession.Query(":TRAC:DATA?");

// Close session
mbSession.Dispose();

All the foregoing is supposed to imitate this LabVIEW code:

So, any ideas on where I'm wrong?

Thank you

It turns out that I need to activate the event as a queue rather than a Manager:

mbSession.EnableEvent(srq, EventMechanism.Handler);

Must be:

mbSession.EnableEvent(srq, EventMechanism.Queue);

Source: the documentation under the heading "remarks". It was a pain to find documentation about it... NEITHER needs to make it easier :-(.

With this change, I also don't need to create the MessageBasedSessionEventHandler.

The final, labour code (with fluff like the namespaces and classes deleted) looks like:

rm = ResourceManager.GetLocalManager().Open("GPIB0::25::INSTR");
MessageBasedSession mbSession = (MessageBasedSession)rm;
MessageBasedSessionEventType srq = MessageBasedSessionEventType.ServiceRequest;
mbSession.EnableEvent(srq, EventMechanism.Queue); // Note QUEUE, not HANDLER
int timeout = 10000;// Start the sweep
mbSession.Write(":OUTP ON;:INIT");

// This waits for the Service Request
mbSession.WaitOnEvent(srq, timeout);// After the Service Request, turn off the SMUs and get the data
mbSession.Write(":OUTP OFF;:TRAC:FEED:CONT NEV");
string data = mbSession.Query(":TRAC:DATA?");
mbSession.Dispose();

I hope this helps future programmers.

Tags: NI Software

Similar Questions

  • "Waiting for in time (RT PXI target) real answer" error when the program is waiting interruptions

    Hello

    I developed an application to detect interruptions generated by an electronic card and act accordingly. The program was developed in labview, but she calls a dll; created with labwindows. The dll is scheduled to open the visa communication, select the events and install the interrupt handler and when an interruption is detected, it reads the value of the different registers of the map and returns to labview to view.

    The problem is that when the program expects an interruption, a prompt appears with the message "Waiting for real-time (RT PXI target) real answer" and the only option I have is to click on the button to disconnect the pxi or just wait. If I wait and I generate an interrupt, the prompt disappears and the application view data as it was planned.

    To wait for the following code the interruption has been programmed into the function:

    While (flag == 0)

    {

    Sleep (1000);

    }

    When an interruption occurs, the value of flag set to 1 and function continues without any problem. I am not really sure, but here is probably the problem and it probably isn't the best way to wait for a break because the sleep function suspends the thread to the configured time, but at least the load calculation in the PXI is between 0 and 1%. I was wondering if anyone knows how to wait for a break without 'lost' communication with PXI and if there is a better way to do it.

    Any response will be welcome and thank you for them,

    Jaime

    Hey there.

    You see problems with connectivity it's because the thread by DEFAULT CallLibrary nodes running in is the UI (UI) thread - UI thread manages also the important things like, say, communications (especially all the connections for the VI server) and other things that you could run all the time.  A CallLibraryNode is not, by default, intended to be used to execute code that runs for a long period of time.  If you want to do this, you assign the execution of the CallLibrary node to run in the context of a LabVIEW run-time engine thread (by selecting to make it work "in any thread") and not the UI thread.  This can be done through the properties of the CallLibraryNode.  By selecting "run in any thread" the call DLL will be generally in the context of the thread running in the run LabVIEW, which is usually what is meant when even.  The VI CallLibraryNode color change of Orange (UI) to blue (LabVIEW thread) so that you can quickly tell what context the appeal will be in.

    The reason the interface thread user is the default thread is because most often DLLS calls need to be serialized (because of functions is not not thread-safe) and so it serves to protect the integrity of the system.  However, if you know your threads are thread-safe, or you will use these threads for a while, it is best to program the CallLibraryNode to use a Thread of LabVIEW execution rather than the UI thread.

    For more information on this review on these pages:

    https://decibel.NI.com/content/docs/doc-9069

    http://zone.NI.com/reference/en-XX/help/371361J-01/lvexcodeconcepts/configuring_the_clf_node/

    DLL' happy ing.

    -Danny

  • Waiting for data on serial port

    Hello everyone.

    I'm trying to figure out how I can solve a problem on LabView. I programmed an Arduino board to read and send a data table of the accelerometer on the serial port. I want to LabView to receive the data and graphs it. My problem is that Arduino send data on an ongoing basis and sometimes LabView can not cope with traffic and read some values "0".

    Is it possible to wait for the data and solve this problem?

    I joined my current vi.

    Thank you much in advance.

    AndreasSchnaas wrote:

    Yes, the characters are 0-9 and - no. ' + 'or'. '. And bytes that vary.

    Once again, thank you very much.

    Given that you send ASCII characters, change your Arduino code to send a character to end of line (10 byte value) at the end of each transmission.  Your code is already configured to use it.  Then you need not use the bytes to the Port at all.  Suffice to say the VISA of reading to read a large number of bytes.  Playback stops when it finds the stop character (value 10).  Your code will get a lot easier from there.

  • Delay (30000 milliseconds) waiting for the SNMP service to communicate.

    When I start the SNMP service in Windows Server 2003 Enterprise 64-bit (SP2), the event ID 7009 (Timeout (30000 milliseconds) waiting for the SNMP service to communicate.), kindly help me to solve this problem.

    Hello

    Note that your computer is under domain, you must contact the TechNet forum, where we are the support technicians who are well equipped with knowledge on the issues of domain, do please visit the link provided below.

    http://social.technet.Microsoft.com/forums/en-us/winserverfiles/threads

  • Start stuck on "Please wait for the Local Session Manager."

    I would say that this problem started a couple of days. Went to start my laptop (Toshiba) and he sat on the "Please wait" message forever.

    Had no problems to start in safe mode. Looked up various ways of addressing the problem.

    Was able to change the resume date and back a few weeks ago. Still no luck. Happened to read something on a printer Epson being perhaps the problem driver (it was installed a day before the date of restoration chosen). Uninstalled the drivers, computer still does not start.

    Tried restarting running. I do not have the CD it came with Vista, but it was an option when you hold F8 during startup (I think?) Couldn't find any problems.

    Ran check on memory. No problem either.

    Changed settings for a verbose startup and ran a Diagnostic startup - all good for this. Then tried selective startup load system services... This is when the error occurs. When starting, it hangs on "Please wait for the Local Session Manager" and does nothing more.

    I looked in the event viewer to see what came that time and a couple mistakes were:

    Event ID 6000: winlogon notification subscriber was unavailable to handle a notification event.

    Event ID 7026: the next (s) start or start failed to load system
    spldr
    Wanarpv6

    It would be very useful for me not having to run my computer in safe mode automatically all the time, although it is useful that I at least have that option. Any help is greatly appreciated.

    Hello

    1. by chance your computer is connected to a domain environment?

    2. as you mentioned in your article that you tried the selective startup, I want to confirm if you have disabled the services left 3rd after hide Microsoft services?

    If you did not disable these services make sure you disable and then check if it works.
    See the article below for more information.
    How to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7
    http://support.Microsoft.com/kb/929135
    Note: When the diagnosis is complete, don't forget to reset your computer to normal startup. Follow step 7 in the above article.

    I hope this helps.

    Thank you, and in what concerns:
    Shekhar S - Microsoft technical support.

    Visit our Microsoft answers feedback Forum and let us know what you think.
    If this post can help solve your problem, please click the 'Mark as answer' or 'Useful' at the top of this message. Marking a post as answer, or relatively useful, you help others find the answer more quickly.

  • Should I switch from 7.5 to 7.6, or should I wait for version 8.0?

    We are currently running version 7.5.304.547. It is better to upgrade to version 7.6, or should I wait for version 8.0? Is the upgrade from 7.5 to 7.6 painless?

    Hi David,

    There is a fix for the problem mentioned Scott, it's hotfix 217443. Please visit this page on our support site for more details of this and other packages of fixes that have been released for vWorkspace 7.6

    https://support.quest.com/Softwaredownloads.aspx?PR=268445634&PV=4294952544

    Kind regards

    David

  • Waiting for CPU: what exactly does that mean?

    Hi all

    I worked on this database (11.2.0.3 on AIX 6.1) try to improve the performance of certain lots of an ERP system developed by my company. These are all processes that work very well in other environments, but here the clock times are horrible for the load and I was seeing 10% CPU, 90% CPU waiting for almost every process. This is the last section of a very long trace file where you can see the invisible "wait."

    I know not how to do this: if I run something in the OS with a higher priority than to Oracle, what I will get. "Lack of processor" according to me, is the name for it. My question is: what else can cause this? If the OS say that nothing was on the computer, how can I study the root cause?
    OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse   762529      3.24      16.60          0          3          0           0
    Execute 8334641   5593.35   51349.14     344238    2115862   12349440     1341634
    Fetch   7048666   1142.66    5978.90     385152   58108531       2068     7944263
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total   16145836   6739.25   57344.65     729390   60224396   12351508     9285897
    
    Misses in library cache during parse: 734
    Misses in library cache during execute: 731
    
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      db file sequential read                    620864        0.62       4858.21
      Disk file operations I/O                       42        0.00          0.00
      latch: shared pool                              8        0.04          0.06
      asynch descriptor resize                        6        0.00          0.00
      direct path write temp                          2        0.01          0.01
      direct path read temp                          94        0.03          0.57
      db file scattered read                       2129        0.44         23.90
      log file switch completion                     15        0.12          0.98
      latch: cache buffers lru chain                  2        0.00          0.00
      resmgr:cpu quantum                             15        0.00          0.03
      latch: object queue header operation            2        0.00          0.00
    
     8180  user  SQL statements in session.
      609  internal SQL statements in session.
     8789  SQL statements in session.
      288  statements EXPLAINed in this session.
    ********************************************************************************
    Trace file: dbkpv_ora_811258_ARREC_BXA_AUTOMATICA.trc
    Trace file compatibility: 11.1.0.7
    Sort options: prsela  fchela  exeela  
           1  session in tracefile.
        8180  user  SQL statements in trace file.
         609  internal SQL statements in trace file.
        8789  SQL statements in trace file.
         754  unique SQL statements in trace file.
         288  SQL statements EXPLAINed using schema:
               KIPREV.prof$plan_table
                 Default table was used.
                 Table was created.
                 Table was dropped.
     25357662  lines in trace file.
       57345  elapsed seconds in trace file.

    marcusrangel wrote:
    don't you think that it is possible that tracing would cause such a huge head?

    Your trace file contains 25 million lines, that is a significant amount of write operations, to be compared with the information that reads one-piece 620K consume dry 4858.
    It is necessary to note that writing in the trace file leads to loss of time only when it is caused between measure of elapsed time from a visit to the database. But even if the write operation is due to the outside to measure the time of the call for a database (for example, information about a call, as FETCH #) it can be inside some call parent and will be included in the duration of the call of the mother.
    If you are interested in the details of this process, I prepare an article on this topic in my blog.

    I would therefore recommend to reproduce a similar load without follow-up.

    Published by: Alexander Anokhin on 12.07.2012 22:07

  • Stuck "waiting for the printer to be available."

    After initially looking at it's going to print, the printer dialog box displays "waiting for printer to be available" and it's there (even if the printer - inkjet HP series C3800 - is ready).

    Here is what I tried:

    Using the HP utility software on the same computer, I am able to successfully print a test page, which rules out a problem with the printer and its connection to the computer.

    Printing worked normally before moving on to the Sierra. I tried resetting the printing system and add new printer (Sierra recognizes very well). I also tried to run in case disk utility have a permissions problem.

    I'm stumped at this point. Help much appreciated.

    Same story, but with a HP Laserjet P3005dn, specific scenario, the exact symptoms, exact attempts to improve...

  • Hi8 thru cam HDV into FCP 7: waiting for timecode

    Hello

    I have a bunch of Hi8 tapes I want to capture on the drive by running through Sony CCD-TR400 on the Canon HV - 20 MBPro & FCP 7.

    I can see the execution in the window capture, but when I hit capture now it gets no further than "Waiting for time code."

    I guess the Hi8 analog, but hoped the Canon with its AV > DV option would treat his way through.

    Any ideas?

    Is the only way to do this would save on tape dv on Canon HV-20 and then capture the disk?

    The best

    Elmer

    Hi8 uses only consumer re-writable (CCFC) timecode that is not readable by the PCF.  In the FCP capture settings, set "Device Control" device not controllable and then use Capture now capture rather than in batches.

    -DH

  • "waiting for encrypted google" does not allow me to open a Web site

    When I try to open lifenews.com, which I visited many times, there is a message saying left down "waiting for encrypted google." I don't even use google chrome? I don't know where to go to get rid of it, I don't want nothing blocked unless I specifically ask to be blocked. I did the research, said it's a blur, said another security settings to uncheck the ssl2 and ssl3. Nothing works. Can someone tell me please how to remove this thing waiting for encrypted google.

    You said blur, which is an add-on. Use the blur, or any extension of similar content filtering? If you think one of them might be the problem, you can test Firefox Safe mode. It is a standard diagnostic tool to disable extensions, hardware acceleration, and a few other advanced features of Firefox.

    Does not work if Firefox: Hold down the SHIFT key when you start Firefox.

    If Firefox is running: You can restart Firefox in Mode safe mode using either:

    • button "3-bar" menu > "?" button > restart with disabled modules
    • Help menu > restart with disabled modules

    and OK reboot.

    Two scenarios: A small dialog box should appear. Click on 'Start mode safe' (not update).

    Any improvement?

  • iMessage is stuck at waiting for Activation.

    Hello

    I have iPhone 6 Plus with iMessage stuck waiting for activation. May that what's wrong with it? These are the work with other vendors if I insert the sim card. Is it something to do with the question SMS relay or something else?

    Need help to solve my problem.

    Thanks in advance.

    If you get an error when you try to activate FaceTime - Apple Support or iMessage

  • How long should you wait for your apple account unlock

    How long should you wait for your apple account unlock?

    of > If your identifier Apple is locked - Apple supports

    ...

    When you see one of these alerts, you can go to iforgot.apple.com to unlock your account with your existing password or reset your password. After multiple unsuccessful attempts to unlock your account, your identifier Apple will remain locked and you can try again the next day.

    ...

  • Extend my extreme network with another extreme - waiting for internet access

    Hello - I have a new generation Airport Extreme (let's call it Extreme1) connected to a Comcast modem and it works very well. The extreme will be the router that the modem has no router function. I'm trying to expand my network to another room with another extreme (let's call it Extreme2). I have a connection cable between two rooms. Extreme1 has an ethernet cable from one of its LAN ports connected on port WAN Extreme2. When I try to create a new network with Extreme2 (in aid of the same name, passwords, etc.) it does not work. He was suspended at the end when he is looking for a connection ("Waiting for internet access")-I did the following things based on what I read here:

    1. Changed IPv6 link local parameters
    2. Tried the whole upward on my Macbook and tried on my iphone
    3. The Wan first and then tried to change the configuration after you done for Extreme2 by creating a network
    4. Tried to create a network with Extreme2 connected directly to the modem
    5. Extreme2 factory reset after every attepmt

    And nothing works. Kicker is, I also have a reasonably new airport express and the same thing happens to her as well.

    Do I need to adjust some parameters of network that I'm not aware of? Is it possible that my LAN ports are disabled on Extreme2? It is brand new.

    Thanks for any help.

    Have you used the Apple Setup Assistant?  If you did, it had notified you that the extreme second was being configured "add using Ethernet. The wizard will automatically configure the second airport with the appropriate settings for you.  All you have to do is enter a name of device for the second AirPort Extreme.

    Here I'm assuming that you reset the second extreme to parameters by default until you set it up again and that your second Extreme is the current version of the "tower" or that of previous versions "flat or square.

    The example below shows an AirPort Express as the device which is the extension of the network, but you will see the name of your network and AirPort Extreme on your configuration screen.

    Post back if you need some tips on using the "Wizard" for your configuration.

  • photos has not been loaded for weeks (usually the browser chrome on PC windows at work).  I tried now on some other computers and get the same error message and I report every time.  can I do or just wait for someone to fix it

    photos has not been loaded for weeks (usually the browser chrome on PC windows at work).  I tried now on some other computers and get the same error message and I report every time.  is there anything I can do or just wait for someone to fix it?

    If you want any help here, you'll have to tell us what the error message.

    Which report you errors to?

  • iPad 4 blocked mode recovery, itunes waiting for ipad

    I've had my IPad for over two years now and it worked great. But yesterday it just no longer lights. I don't know weather it auto-updated or not, but it became all black. I tried to reload, but the screen remains black after hours of load. The combo of home button and lock 10 seconds also does nothing. I plugged into my Macbook so and tried Itunes. ITunes says "ITunes has detected an iPad in recovery mode. You must restore this iPad before it can be used with iTunes. «So I press ok and restore the iPad, software is extracted and it said "Waiting for iPad...» "for a minute. The next thing is the error message ' the iPad could not be restored. An unknown error occurred (4005). "I tried several times with different cables and USB ports... I don't know what to do anymore.

    I'd be happy for something useful!

    You can try the DFU mode

    If you are unable to update or restore your iPhone, iPad or iPod touch - Apple supports

    If this does not help

    An appointment of 'Genius' to an Apple Store, or select another authorized service provider.

Maybe you are looking for

  • I can do ststionery for thunderbird

    I used to make stationery for windows mail. Is it possible to add stationery to Thunderbird?

  • the capital file el has not completely download

    MY download has been blocked to 1.4 GB but installing OS X app appeared, I clicked and he said this: -. now how remove this copy of the application when when you press 'alt' no option does not appear. And my App Store said sorryosx el capital could n

  • files .lisj

    I'm under Synology Cloudstation backup photos to a Synology NAS to my MacBook Pro and I get as an authorization error of repeated access associated 2 files .lisj in the Cloudstation newspaper. I searched high and low, and I can't find any info on the

  • Satellite Pro L10: Pop up to say 'Enter Password'

    HELP ME I LET MY SON USE MY LAPTOP AND SOME DAY LEAVE, I PUT IT ON... A AND THEN THE TOSHIBA LOGOBLUE POP UP SAYING ENTER PASSWORDSO I DID AND THEN... INSTALLATION WARNINGINVALID PASSWORD

  • Tecra A11 - cannot burn CD - R

    Hello My Tecra A11 with Win 7 Pro 64 and a carpet * a DVD-RAM UJ890AS is not able to burn on a CD - R. CD - RW and DVD no problem, but when you try to burn a CD - R I got following error Code: 060277-26 - 2A 031000 I tried the solution inhttp://forum