Can the NI know its being debugged?
Jeff
Posts: 374
So . . . run with me on a flight of fancy here. Is it possible for an NI master to know that it is being debugged? I'd love to set up my code so that if I'm in debug mode, it knows it, and it doesn't do my tp feedback, which would make stepping through code so much easier. I'm thinking something like
Any ideas? I thought maybe I coudl tie a variable to the online/offline events of the NS Studio application, but that wouldnt' just be debug mode, that would be any time the NS Studio app connects . . . . which might not be horrible.
J
if (nDebug) { tp_fb() }
Any ideas? I thought maybe I coudl tie a variable to the online/offline events of the NS Studio application, but that wouldnt' just be debug mode, that would be any time the NS Studio app connects . . . . which might not be horrible.
J
0
Comments
Never observed in detail, but the nature of the range 32001...32767 is that "ungonfigured" devices will automatically set there with addresses assigned automatically by the master. This means if you have .i.e an unaddressed NXM-COM2, it may become address 32001 and Studio may get 32002 if it is launched as second. But after the next reboot, both may get new addresses. So if it WOULD be possible to detect Studio, it may become difficult to find it (because it is also possible to connect two or more Studios the same time).....
And if you're debugging you can just set nSkipFeedback to 1 and it'll be much easier to step through code.
In case you're wondering why I'm trying to do all this, its because the primary objection to doing feedback in a timeline or in define_program that I'm getting from my coworkers (see the thread about device combines and arrays) is stepping through code gets harder, so if I can eliminate that problem maybe I can win the array fight.
J
CIpDiag::OpenSession 32001:1:1
Likewise "CloseSession"
I have only been able to generate these messages by opening and closing debug.
So, if in your code you initiate an IP client to the localhost telnet server (127.0.0.1 port 23) and do 'msg on' in that IPclient session, you will get a string event when you open or close debug. You will also get a string event for that IPClient for all your strings to zero, which may be a killer in your case.
I just tried this, and it does work.
In our code we usually have a virtual device for various devices or functions that we use and we like to setup a command event for the virtual device for turning on and off a debug variable. This way we can send a command to a virtual device and turn on debug for that device or code function. The person trouble shooting does not need to have the correctly compiled code because they are not trying to turn the variable on or off directly through studio. You don't even need studio to do the debugging. You can use telnet and that's it. All you need to do is turn on messages for the telnet session and you need to know is the virtual device you want debug info from.