Home AMX User Forum NetLinx Studio

send_string 0, in a module

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

Comments

  • a_riot42a_riot42 Posts: 1,624
    does not yield anything at runtime.

    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
  • slip couganslip cougan Posts: 34
    Hi 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"
    }
    }
    }
    }
  • nicholasjamesnicholasjames Posts: 154
    I'm assuming dIpAddress is a string? Make sure it doesn't start with a NULL ($00) character. NetLinx has trouble with NULL characters.

    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.
  • slip couganslip cougan Posts: 34
    Hi Nick,

    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
  • regallionregallion Posts: 95
    I don't have any example code to hand at this time, but I too have experienced this!

    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!)
  • viningvining Posts: 4,368
    I've never had any issues with using send_string 0 in modules and i do it all the time.

    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.
  • DHawthorneDHawthorne Posts: 4,584
    SEND_STRING 0 doesn't send to the Diagnostics window. It sends to the terminal window. You have to open a terminal session to the master to see it. Diagnostics only shows internal events.
  • viningvining Posts: 4,368
    DHawthorne wrote: »
    SEND_STRING 0 doesn't send to the Diagnostics window. It sends to the terminal window. You have to open a terminal session to the master to see it. Diagnostics only shows internal events.

    Hmmm, that's all i ever use (diagnostic window) and never open the terminal window. Are you thinking the the notification window?
  • ericmedleyericmedley Posts: 4,177
    I typically send all messages to the virtual device being used by the module. That way multiple instances don't confuse me. (There's plenty of stuff out there already to confuse me...)
Sign In or Register to comment.