Menu

How to start sequence script from command line

Anonymous
2020-12-10
2023-05-04
  • Anonymous

    Anonymous - 2020-12-10

    Hello everyone,
    I'm working on one project where I need to send some Hex sequence one by one to serial port and I would like to know how to do it from command line in order to perform action from Jenkins.
    Right now I know only how to open saved configuration
    ScriptCommunicator.exe -withScriptWindow -notMinimized -CC:\Users\Tijana\Documents\ScriptCommunicator\initialSettingsWin.config
    What should I use to start testsequence.seq to execute all lines?

     
  • Stefan Zieker

    Stefan Zieker - 2020-12-10

    Hi,

    you cannot execute a sequence script or sequences from the Send Window from command line. But you can execute a worker script that contains your sequence:
    ScriptCommunicator.exe -withScriptWindow -notMinimized C:/sequence.js

    You can find an example worker script in the attachment.

     
  • Anonymous

    Anonymous - 2020-12-23

    Hi Stefan,
    Thank you so much for your kind help. I manage to create script with sequnces and all is working fine if I start script manually from Scriptcommunicator window. Now, I have tried to create .sce file in order to start actual scenario from command line. I come accross issue that actual script can't be open this is what I get when I execute following command line:
    ScriptCommunicator.exe -C"C:\Users\Tijana\Documents\ScriptCommunicator\test.config" "C:/Users/Tijana/Downloads/citanjeserijskog/citanjeerijskog.sce"
    If you can please guide me how to resolve this.
    Thank you.
    Tijana

     
  • Stefan Zieker

    Stefan Zieker - 2020-12-23

    Hi Tijana,

    can you upload your sce file and your script please?

    Regards,
    Stefan

     

    Last edit: Stefan Zieker 2020-12-23
  • Anonymous

    Anonymous - 2020-12-23

    Hi Stefan,
    Thank you for your fast feedback. You can find in attachment script and .sce file.
    Kind Regards,
    Tijana

     
  • Stefan Zieker

    Stefan Zieker - 2020-12-23

    Hi Tijana,

    your sce file and your script worked fine. 'The only thing I had to do is to create a folder 'scripts' in the folder of the sce file and put sequence.js inside of it (the path to your script in the sce file is "./scripts/sequence.js").

    Regards,
    Stefan

     

    Last edit: Stefan Zieker 2020-12-23
  • Stefan Zieker

    Stefan Zieker - 2020-12-23

    By the way, you can connect/disconnect the main interface from inside your script. Then you don't need any config file.

     
  • Anonymous

    Anonymous - 2020-12-23

    Hi Stefan,
    I just manage to start script from command line, but I do not see any result of the execution in log file. Do you have some suggestion what to check? You can see in video what is happening.
    Kind regards,
    Tijana

     
  • Stefan Zieker

    Stefan Zieker - 2020-12-23

    Hi Tijana,

    the reason why your log file is empty is that ScriptCommunicator ingores the config file if a script or a sce file is in the command line options (I will add this information to the manual).
    In other words, you have to:
    1. connect the main interface from script
    2. create your log file from script (writeFile or writeBinaryFile)

    example for the serial port:

    if(!scriptInf.connectSerialPort("COM1", 115200))
    {
        //Error, do something.
    }
    

    example log file:

    //Append data to Testfile (relative path, this means the file is created in the folder of the script).
    scriptFile.writeFile("Testfile.txt", true, "new content", false);
    

    If you want to override/clear the file then you have to do this:

    scriptFile.writeFile("Testfile.txt", true, "", true);
    

    Regards,
    Stefan

     

    Last edit: Stefan Zieker 2020-12-23
  • Anonymous

    Anonymous - 2020-12-23

    Hi Stefan,

    You have help me a lot. Now the last thing will be: How to save output from serial port in File?

    Kind regards,
    Tijana

     
  • Stefan Zieker

    Stefan Zieker - 2020-12-23

    Hi Tijana,

    here is an exampe code:

    function dataReceivedSlot(data)
    {
    
    }
    scriptInf.dataReceivedSignal.connect(dataReceivedSlot);
    

    If you receive binary data and you want to save it as an hex string you can use conv.byteArrayToHexString to convert the received data (byte array).
    If you receive strings then you can use conv.byteArrayToUtf8String to convert the received data.

    Regards,
    Stefan

     

    Last edit: Stefan Zieker 2020-12-23
  • Anonymous

    Anonymous - 2020-12-24

    Hi Stefan,

    Thank you so much for all your help.
    I just manage to build completely working script for actual scenario where I'm going to use Script Communicator. It took me a while and some help of my collegues and we are very happy with end result. In case that someone in future need to use ScriptCommunicator in order to send hex data over serial port and collect all output and input in textual file I will attache example of my script.

     
    • Anonymous

      Anonymous - 2020-12-24

      Cheers,
      Tijana

       
  • Stefan Zieker

    Stefan Zieker - 2020-12-27

    Hi Tijana,

    I'm glad I could help you. And thx for sharing your script.

    Cheers,
    Stefan

     
  • Anonymous

    Anonymous - 2022-01-24

    I am just trying to send a hex command to a device that connected via RS-232, when i send command script, nothing happens but this is what i see

     
  • Stefan Zieker

    Stefan Zieker - 2022-01-24

    You are using the Main Interface. Is your Main Interface connected?

    You can connect it manually (Settings Window) or by script:

    scriptInf.connectSerialPort("COM1", 19200);
    
     

    Last edit: Stefan Zieker 2022-01-24
  • Anonymous

    Anonymous - 2022-01-24

    Thanks I was able to get what i wanted done with your help .. what would i need to do to implement disconnect from the COM1 connection once it has been ran, I must of overlooked this part

     
  • Stefan Zieker

    Stefan Zieker - 2022-01-25

    You must call scriptInf.disconnect() to disconnect the Main Interface.

     

    Last edit: Stefan Zieker 2022-01-25
  • Anonymous

    Anonymous - 2022-01-25

    Stefan I have to say this program works flawlessly, thanks so much for the time you put into it and the help that you provide afterwards

     
  • Stefan Zieker

    Stefan Zieker - 2022-01-26

    :-)

     
  • Anonymous

    Anonymous - 2023-05-02

    HI,
    I would like to read data in a loop with some delay in between, how to do that?

    thanks

     
  • Anonymous

    Anonymous - 2023-05-04

    Hi,

    what are you exactly trying to do (are you writting a worker script?)?

     

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.