How to send command to standard serial port

 

    
Dear Sir:
 
  1. I had a hardware(switch), direct connect to computer com1 using R485 line.
  2. I can turn the switch  on/off using standard serial test code.
  3. I can also using following rxtx( same version as scadabr using)  java code to turn it on/off.
 
  now with ScadaBR, I created modbus serial data source, and it can scan found 1 node. But when create data point,
  there is no "output"  option for "Register range", so I do not know how to continue.
 
  would you please help me how to create data source ( modbus serial or .. ?) ,
  data point and script to turn the switch on/off ?
 
Thanks a lot.
william
wf321@163.com
 
*********************************** RXTX CODE ****************************
import gnu.io.CommPort;
import gnu.io.CommPortIdentifier;
import gnu.io.SerialPort;
 
import java.io.FileDescriptor;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
 
   public static void main ( String[] args )
    {
          connect("COM1");
    }
 
 
    void connect ( String portName ) throws Exception
    {
        CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(portName);
        CommPort commPort = portIdentifier.open(this.getClass().getName(),2000);
 
                SerialPort serialPort = (SerialPort) commPort;
                    
serialPort.setSerialPortParams(4800,SerialPort.DATABITS_8,SerialPort.STOPBITS_2,SerialPort.PARITY_NONE);
 
                System.out.println(serialPort.getName());
                InputStream in = serialPort.getInputStream();
                OutputStream out = serialPort.getOutputStream();
                
                // send 8 int to control the switch
                int len = 8;
                int[] buffer = new int[len];
 
 
                buffer[0] = 0x01;  // com1
                buffer[1] = 0x05;  
                buffer[2] = 0x00;  // port 0
                buffer[3] = 0x01;  // channel
                buffer[4] = 0xff;  // turn the switch on , 0X00 means tuen off
                buffer[5] = 0x00;
                buffer[6] = 0xdd;  // check use crc16
                buffer[7] = 0xfa;  // check use crc16
 
                
                for (int i = 0; i < len; i++)
                {
                    System.out.println(buffer[i]);
                out.write(buffer[i]);
                }
                out.flush();
                
                commPort.close();
    }
 

Hello Willian,

Thanks for reaching us. Let me see if I understood it correctly.

While using ScadaBR you cannot set holding registers as outputs, but you can make them configurable. Just check the box in the data point configuration.

You can write data to those Holding Registers Data Points. that are set to be configurable, in the watch lists and graphic views.

In the graphic view you can use a button, as switch ON/OFF

I hope this helps you =]

Best Regards,

thanks for your help.

I found soluction now. I can not send command to com port , but I can set value to modbus coil.

from   buffer[1] = 0x05;  I know it will write to modbus coil, so I create a data point to coil, and try to set value to 0 or 1 ( offset try 0,1,2...), and found for offset=1, value=0 the switch will turn of, value=1 will tuen on.

thanks.

 

Ok, Great.

Thanks for the feedback