Debug Netlinx
adys
Posts: 395
Hi all
I have problems with netlinx debugger
The debuger stops all the time in this code, not matter what I do...
DATA_EVENT[vdvDEVICE]
{
COMMAND:
{
STACK_VAR CHAR datum[30]
STACK_VAR CHAR cCOMMAND[20][20]
IF (nDEBUG > 2)
Its code of a DVD module
I can't debug nothing unless I remarke this code.
Any ideas?
Another thing if I am here...
I know that in Netlinx all the vars behave as in reference in C++
what is the way to pass vars "by value"?
thanks
Adys
I have problems with netlinx debugger
The debuger stops all the time in this code, not matter what I do...
DATA_EVENT[vdvDEVICE]
{
COMMAND:
{
STACK_VAR CHAR datum[30]
STACK_VAR CHAR cCOMMAND[20][20]
IF (nDEBUG > 2)
Its code of a DVD module
I can't debug nothing unless I remarke this code.
Any ideas?
Another thing if I am here...
I know that in Netlinx all the vars behave as in reference in C++
what is the way to pass vars "by value"?
thanks
Adys
0
Comments
Unfortunately, you can't pass a variable to a function by value. The best you can do is duplicate it inside the function by making a variable of the same type, then assigning the parameter value to that, and working with that one instead of the actual parameter.
The debugger keep on stoping all the time even that there is no breakpoint....
This is a common issue, by the way, with how NetLinx Studio inserts debug tokens. Even on compile errors, you often get a bad line reported as being a line, or several lines, in front of the actual problem.
Ok
here is the full code
DATA_EVENT[vdvDEVICE]
{
COMMAND:
{
STACK_VAR CHAR datum[30]
STACK_VAR CHAR cCOMMAND[20][20]
IF (nDEBUG > 2)
SEND_STRING dvdDebug, "'UI/Virtual Device 1 received from Comm: ',data.text"
datum = remove_string(data.text, '-', 1)
SWITCH(datum) {
CASE 'TITLECOUNTER-':
{
m_DVDMode = 1
//SEND_COMMAND dvTPList, "'@TXT',nTXT_BTN[1],DATA.TEXT"
SEND_STRING dvdDebug,"'dvd CMD TITLECOUNTER'"
SEND_STRING dvdDebug,DATA.TEXT
m_TITLECOUNTER = DATA.TEXT
}
CASE 'TITLEINFO-':
{
fnPARSE(',',DATA.TEXT,cCOMMAND)
IF(cCOMMAND[1] == '-2147483648')
{
//SEND_COMMAND dvTPList, "'@TXT',nTXT_BTN[2],'TITLE: --'"//TITLE
m_TITLEINFO = "'TITLE: --'"
}
ELSE
{
//SEND_COMMAND dvTPList, "'@TXT',nTXT_BTN[2],'TITLE: ',cCOMMAND[1]"//TITLE
m_TITLEINFO = "'TITLE: ',cCOMMAND[1]"
}
SEND_STRING dvdDebug,"'dvd CMD TITLEINFO'"
SEND_STRING dvdDebug,cCOMMAND[1]
SEND_STRING dvdDebug,m_TITLEINFO
}
CASE 'TRACKCOUNTER-':
{
m_DVDMode = 0
SEND_COMMAND dvTPList, "'@TXT',nTXT_BTN[1],DATA.TEXT"
SEND_STRING dvdDebug,"'dvd CMD TRACKCOUNTER'"
SEND_STRING dvdDebug,DATA.TEXT
m_TRACKCOUNTER = DATA.TEXT
}
CASE 'TRACKINFO-':
{
SEND_COMMAND dvTPList, "'@TXT',nTXT_BTN[3],DATA.TEXT"
fnPARSE(',',DATA.TEXT, cCOMMAND)
IF(cCOMMAND[1] == '-2147483648')
{
//SEND_COMMAND dvTPList, "'@TXT',nTXT_BTN[3],'CHP/TRK: -- '"//CHAPTER
m_TRACKINFO = "'CHP/TRK: -- '"
}
ELSE
{
//SEND_COMMAND dvTPList, "'@TXT',nTXT_BTN[3],'CHP/TRK: ',cCOMMAND[1]"//CHAPTER
m_TRACKINFO = "'CHP/TRK: ',cCOMMAND[1]"
}
SEND_STRING dvdDebug,"'dvd CMD TRACKINFO'"
SEND_STRING dvdDebug,cCOMMAND[1]
SEND_STRING dvdDebug,m_TRACKINFO
}
CASE 'VERSION-':
{
sVERSION = DATA.TEXT
}
CASE 'DEBUG-': {
nDebug = atoi(data.text)
IF (nDebug)
SEND_STRING 0, "'Debug messages are now on.'"
ELSE
SEND_STRING 0, "'Debug messages are now off.'"
BREAK
}
}
}
STRING:
{
SEND_STRING dvdDebug,"'dvd STRING'"
SEND_STRING dvdDebug, DATA.TEXT
}
ONLINE:
{
SEND_COMMAND vdvDEVICE, "'TRACKCOUNTERNOTIFY-1'"
SEND_COMMAND vdvDEVICE, "'TITLECOUNTERNOTIFY-1'"
}
}
I don't understand why it stops here without me putting any break point, and without any code that generate "code break point"
If I want to debug any code in my system, I must remark this code.
its very annoying...
Two things I would try though:
1) Make datum a LOCAL_VAR instead of a STACK_VAR. I've seen some strange things happen with SWITCH...CASE and stack variables.
2) Replace the entire SWITCH...CASE with SELECT...ACTIVE.
There are some definite strange, undocumented weirdness about SWITCH...CASE that only appear at run time. I never use it anymore with any value that isn't a simple CHAR or INTEGER. I don't know if it's your problem, but that is where I would start.
The local_var solved it.
Thanks a lot
Ady
I would really like to see better documentation on the limits of SWITCH...CASE statements.
I'm sitting in Programmer II and have encountered a similiar debugging problem as described earlier in this thread.
Here's the code:
DATA_EVENT[dvTP_Main]
{
STRING:
{
LOCAL_VAR iTest;
STACK_VAR INTEGER iIpNode;
aTPBuff = "aTPBuff,DATA.TEXT";
IF (FIND_STRING(aTPBuff, 'KEYP-', 1))
{
REMOVE_STRING(aTPBuff, 'KEYP-', 1);
iIpNode = ATOI(aTPBuff);
IF (iIpNode >= 1 && iIpNode <= 254)
{
aUserClientIpAddress = "CLIENT_IP_SUB, ITOA(iIpNode)";
SEND_COMMAND dvTP_Main, "'^TXT-154,0,', aUserClientIpAddress";
ON[dvTP_Main, 151];
}
ELSE
{
SEND_COMMAND dvTP_Main, "'^TXT-154,0,INVALID IP'";
OFF[dvTP_Main, 151];
}
}
ELSE IF (FIND_STRING(aTPBuff, 'KEYB-', 1))
{
REMOVE_STRING(aTPBuff, 'KEYB-', 1);
IF (!FIND_STRING(UPPER_STRING(aTPBuff), 'ABORT', 1))
{
SEND_COMMAND dvTP_Main, "'^TXT-155,0,',aTPBuff";
SEND_STRING dvClient, "aTPBuff,':'";
}
}
WAIT 20
{
CLEAR_BUFFER aTPBuff;
}
}
}
I can't see the variable TPBuff (which is a VOLATILE global) in the DEBUG window when STACK_VAR INTEGER iIpNode is the first line in that code block. If I change iIpNode to LOCAL_VAR or add another bogus variable that is LOCAL_VAR above it, then everything is fine.
If you look at how the Adys problem was fixed by changing the first line from a STACK to LOCAL then things are working. I think there is something fishy going on with the debugger....
I failed to mention that I get the error message
"The compiled TKN file on the master controller doesn't match the source code file on that you have selected to debug with."
I've stripped my code down to about 7-8 lines and it is still happening.
The other thing that I have done is to have multiple versions of a master AXS file and keep sending a prior version's code to the master. For example, I changed from version 2 to version 3 and then edit for a while, and compile. Send the code but forget to change the file in the file transfer dialog. When I send code to the master, I try to watch the send dialog and make sure that the size of the files sent is not exactly the same as the last time I sent code.
You can telnet into your master and see what code is loaded with the "program info" command. If the return from the master matches what you are trying to debug with, I sure don't know what would be causing the "does not match" warning.
What do you mean by not having a single non-volatile variable? Is there a requirement to have at least one?
The code is definitely downloading every time. I've made changes and confirmed that the changes have occurred.