Menu

dataReceivedSignal.connect does not work

Anonymous
2015-10-14
2016-01-15
  • Anonymous

    Anonymous - 2015-10-14

    Hi!
    I have changed from 2.14 to 3.11 and have found that scriptThread.dataReceivedSignal.connect(dataReceivedSlot) function does not work (it does not call dataReceivedSlot function when data arrives through serial port)!
    If I use my script file in the old version it works fine.

     
  • Stefan Zieker

    Stefan Zieker - 2015-10-14

    Hi,

    thx for your bug report. I will check this.

    Best regards,
    Stefan

     
  • Stefan Zieker

    Stefan Zieker - 2015-10-14

    Hi,

    I have connected two PC's over Rs232. On the first PC I runned CyclicReceive.js and on the second CyclicSend.js. Everything works fine.

    I have changed the script API from 2.14 to 3.11 a little bit. Maybe you are using it not correctly. Could you send me your script (or the corresponding parts of it) so that I can check it?

    Maybe you can check at which version of ScriptCommunicator the problem occures?

    Best regards,
    Stefan

     
  • Anonymous

    Anonymous - 2015-10-15

    Hi,

    Thanks for the quick response!
    In my script I send out a string for a device, and wait for the answer that is a multi-line message. I check the incoming string length periodically, and if it does not get longer, I continue the script.
    The problem is that the connected function (resultreceived) is not called when data arrives.

    To check the last working version takes some time, but I try to find it as soon as possible.

    Best regards,
    Bálint

    The corresponding part of my code is:

    function resultreceived(data)
    {
    scriptThread.appendTextToConsole ("Data function is called");
    for (i in data){
    resultString+=String.fromCharCode(data[i]);
    }
    }

    try
    {
    scriptThread.appendTextToConsole('script has started');
    var resultString = '';

    if(scriptThread.connectSerialPort("COM4",baudRate = 9600))
      {
          scriptThread.appendTextToConsole ("Connect to SerialPort succeeded");
    
          scriptThread.dataReceivedSignal.connect(resultreceived);
    
          resultStringLength_old = 0;
          resultStringLength = 1;
    
          sentbyte = scriptThread.sendString("at+ws\r\n",0,0);
            while (resultStringLength_old<resultStringLength) {
              resultStringLength_old=resultString.length;
              scriptThread.sleepFromScript(1000);
              resultStringLength=resultString.length;
            }
          scriptThread.dataReceivedSignal.disconnect(resultreceived);
      }
      else
      {
          scriptThread.messageBox("Critical", 'error', 'could not open serial port');
      }
    
    scriptThread.stopScript()
    

    }
    catch(e)
    {
    scriptThread.appendTextToConsole("exception while starting the script: " + e);
    scriptThread.stopScript()
    }

     
  • Anonymous

    Anonymous - 2015-10-15

    Hi Stefan,

    I have tested several program versions, but this function works only in 2.14.
    Worker script is the same, but in 2.15, 2.16, 3.00, 3.11 it does not work.

    Best regards,
    Bálint

     
  • Anonymous

    Anonymous - 2015-10-15

    Hi Bálint,

    I found the problem in ScriptCommunicator. I will release a new version today.
    But I can see that your script is blocking the script main function (therefore you can not stop the script with the stop button).
    You should only put initialization code here and your working code in the asynchronous function calls (like timer callbacks or data receive callbacks).
    I have changed your script (attachment). This script should run in all SciptCommunicator versions.

    Best regards
    Stefan

     
    • Anonymous

      Anonymous - 2015-10-15

      Hi Stefan,

      Thanks for your suggestion, but the truth is that it was my intention to block the main function, because I have to wait until the transaction ends (but it varies in time) :) The rest of the script (that I have removed for the sake of simplicity) uses the results of first (long) transaction.

       

      Last edit: Anonymous 2015-10-15
      • Stefan Zieker

        Stefan Zieker - 2015-10-15

        Hi Bálint,

        then it would be better to put following code into your main function:

        if(scriptThread.scriptShallExit())
        {
        //Leave the main function
        }

        With this code you can stop the script by pressing the stop button (if you don't get an answer from your device).

        Best regards,
        Stefan

         
  • Stefan Zieker

    Stefan Zieker - 2015-10-15

    Hi Bálint,

    I have released a new Version of ScriptCommunicator (3.12).

    Do you have any suggestions to improve ScriptCommunicator?

    Best regards,
    Stefan

     
  • Anonymous

    Anonymous - 2015-10-15

    Stefan, thank you for help! The problem is solved, now the latest release works fine! :)

    At the moment I have only a few suggestions to improve ScriptCommunicator:
    1. When it is used in command line mode with -withScriptWindow switch, the script window opens, but it disappears (actually goes below other windows) instantly. It would be better if it would open as the topmost window.
    2. Using -withScriptWindow option the manual states: "ScriptCommunicator exits automatically when the script window has been closed". I think it would be useful to be able to close it automatically by e.g. calling a function within the script.
    3. One can send out hexadecimal strings with e.g. data = Array(0x74, 0x01, 0x00); sentbyte = scriptThread.sendDataArray(data,0,0); but it does not work when array contains only 0x00, because another character is sent with it together. This happened a few months ago, so I hope I still remember well... I have checked the serial transmission with a serial port sniffer sw. The solution was to use a different solution: sentbyte = scriptThread.sendString(String.fromCharCode(0),0,0); This sends out only one 0x00 character code.

    Thanks again for your support!

    Best regards,
    Bálint

     

    Last edit: Anonymous 2015-10-15
  • Stefan Zieker

    Stefan Zieker - 2015-10-15

    Hi Bálint,

    1. I will introduce a new visibility option.
    2. I will introduce a function to exit ScriptCommunicator
    3. I will check this.

    Thx for your reply.

    Best regards,
    Stefan

     

    Last edit: Stefan Zieker 2015-10-15
  • Stefan Zieker

    Stefan Zieker - 2015-10-18

    Hi Bálint,

    I have released a new version of ScriptCommunicator (3.13) which includes:
    - the new command line option '-notMinimized'
    - the new script function scriptThread.exitScriptCommunicator()

    Best regards,
    Stefan

     
    • Nick

      Nick - 2016-01-15

      Hi Stefan:

      I am new to your tool. I have installed 3.28 version for windows. When I try to send AT command over my COM3 serial port, all i receive is an echo of whatever i am sending. When using Putty or other terminal software, I get the right respond (OK) from my GSM module.

      I played around with the settings and I could not figure out why.
      Can you help please?

      nic

       
  • Stefan Zieker

    Stefan Zieker - 2016-01-15

    Hi Nick,

    • how do you send your AT command (entered in a console, with the main window send area, with the send window or with a worker thread)?
    • can you switch on the hex console and send me the bytes which you send?
    • send me the output of Putty please

    Do you fnished your command with an 'enter' (entered in a console, with the main window send area or with the send window). If this is the case then maybe the 'send on enter' setting (settings window/console tab) is not correct.

    Best regards,
    Stefan

     

    Last edit: Stefan Zieker 2016-01-15
    • Anonymous

      Anonymous - 2016-01-15

      thanks for your swift reply!
      i was looking for a fast way of testing a set of command in the main window.

      i already found the problem. i did not include the "enter" as i thought the programme would add it for me just like it does for "space" etc. i managed to receive from the device after i input hex value of change of line after command.

      thanks for your help, when i have time i will read through the documentation to try out some scripts.

       
  • Stefan Zieker

    Stefan Zieker - 2016-01-15

    If you have any questions, post again.

    Best regards,
    Stefan

     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.