send_string 0, in a module
slip cougan
Posts: 34
It's been a while since I had to write a module and I'm curious as to how people send text to the Diagnostics window from a module.
send_string 0,"'some data in my module: ', myDataString"
does not yield anything at runtime.
This of course works fine in the main source file.
Any guidance would be appreciated.
Many thanks
slip
send_string 0,"'some data in my module: ', myDataString"
does not yield anything at runtime.
This of course works fine in the main source file.
Any guidance would be appreciated.
Many thanks
slip
0
Comments
It should. Post your code. I use a print function that does some pretty printing to the console, but it does a send_string 0 so yours should work.
Paul
Thanks for the prompt reply.
Thanks
slip
Here's the code:
data_event[dPort]
{
online:
{
send_string 0,"dIpAddress,' device online'" // dIpAddress is already defined and passed from the main program
}
offline:
{
ipPortStatus = ipPortClosed
send_string 0,"dIpAddress,' device offline!'"
}
onerror:
{
// error handling stuff here
}
string:
{
stack_var char getChar[1]
stack_var char rxCommand[bufferSize]
stack_var integer len
if(length_array(rx) + length_array(data.text) > bufferSize)
{
send_string 0,"dIpAddress,' Error! Receive buffer overflow'"
}
else
{
rx = "rx, data.text" // append data.text to the rx buffer
if(debug) send_string 0,"'rx: ', rx"
while(length_array(rx) >0)
{
getChar = "get_buffer_char(rx)"
if(debug)
{
len = length_array(rx)
send_string 0,"'getChar: ', itoa(getChar), ' ', itoa(len)"
}
switch(getChar)
{
Case 10:
{
processFB(rxCommand) // the events are occurring and this function does process the command ok
}
}
rxCommand = "rxCommand, getChar"
}
}
}
}
Does it show up in telnet? A telnet session using "msg on" shows the same messages as diagnostics.
Silly question, but are you sure that IP device is coming online? You're only sending a string when the device is coming online, going offline, or receiving a string. If it never comes online, it can never go back offline, and you certainly won't get any strings.
Yes the device is online as all the feedback from the module (that I currently have working) appears as expected.
Also it's not just those events;
In my data_event string: I have
if(debug) send_string 0,"'rx: ', rx" and various other send_string 0's scattered throughout the module. I wrote the code in the master file first and moved it over to a module later.
I have also tried doing
send_string 0,"'this is a string'" and that sends nothing either and as stated in my post
send_string 0,"'some data in my module: ', myDataString" produces nothing either.
If I add this to my master source file:
DATA_EVENT[pDevice1]
{
online:
{
// stuff here
}
offline:
{
// stuff here
}
string:
{
send_string 0,"'module rx:', data.text"
}
}
then I can see the send_string events in the module being passed back to the main source and appended to 'module rx:'
I am obviously missing something here!
slip
Bizarrely, I have noticed it to be someone random. Sometimes I'll see debug output, sometimes I won't.
Just wanted to add this anecdote as it may well not actually be something wrong with the OPs code (unless it's something wrong with both of us lol!)
I would verify the module is instatiated properly, make sure you re-compile the module after any changes and verify the path to the tko file that the system is pulling in. Nothing worse than modifying a module when the system is pulling in a different version, different path.
Hmmm, that's all i ever use (diagnostic window) and never open the terminal window. Are you thinking the the notification window?