lmhhj
Hi,
    Sorry,my english is not good。
    I have successfully installed openplc_v3 on one Industrial Board with ubuntu 18.04 by "./ install.sh linux",and I make one I/O borad with Modbus RTU. the I/O board to CPU's uart  is named ttyS3 .
    Now I open th openplc web in http://linux IP:8080, the HardWare is blank linux ,when I add slave device , I found the COM port  has not Drop-down options, and I also don't fill in manually.  

企业微信æË†Ãƒ‚ªÃ¥â€ºÂ¾_16075849641830.png   Do I need to add some code in the openplc/webserver/core/hardware_layers/blank.cpp ? In addition,I think only  when I nedd cotrol my cpu borad's i/o, I need add some code in the openplc/webserver/core/hardware_layers/blank.cpp  like wiringPisetup, but I don't control linux board's i/o, I just want to control  the I/O brad's I/O .
   It troubles me! I hope to get some advice and help, thanks!
Reply 0 0
thiagoralves
The webserver uses pyserial to populate the COM field with all COM ports detected on the system. As far as I know this method works well. You don’t need to have any special driver or hardware layer to add slave devices. As I said, detecting COM ports is done through pyserial and should work universally as it relies on OS calls to check which ports are available. Make sure that your ttyS3 is really available using a terminal program like minicom. You can also check if pyserial is installed for Python 2.7 running pip2 install pyserial.
Reply 0 0
thiagoralves
edit: for debug purposes, you can look directly at the webserver code that lists the COM ports:
ports = [comport.device for comport in serial.tools.list_ports.comports()]
            for port in ports:
                if (platform.system().startswith("CYGWIN")):
                    port_name = "COM" + str(int(port.split("/dev/ttyS")[1]) + 1)
                else:
                    port_name = port
                return_str += "<option value='" + port_name + "'>" + port_name + "</option>"
            
            return_str += pages.add_slave_devices_tail + pages.add_devices_script

You can find this snippet at OpenPLC_v3/webserver/ webserver.py starting at line 1123
Reply 1 0
Guanghua
first use python to test whether you can communicate normally with RTU slave via pyserial
if pyserial works normally then
Modify the webserver .py file and statically configure "port_name" static as your uart port name
Reply 0 0
lmhhj
Thanks for your reply!
    I am a rookie in python. I have confirmed that ttyS3 is really available by minicom. And I also have confirmed pyserial is already installed.
    But I run "pyserial-ports ",output is "no ports found", and run "python2.7 -m serial.tools.list_ports", output is same.
     
root@ht:~/OpenPLC_v3-master#
root@ht:~/OpenPLC_v3-master# pip2 install pyserial
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Requirement already satisfied: pyserial in /usr/local/lib/python2.7/dist-packages (3.5)
root@ht:~/OpenPLC_v3-master#
root@ht:~/OpenPLC_v3-master#
root@ht:~/OpenPLC_v3-master# pyserial-ports
no ports found
root@ht:~/OpenPLC_v3-master#
root@ht:~/OpenPLC_v3-master# python2.7 -m serial.tools.list_ports
no ports found
root@ht:/usr/local/lib/python2.7# python
python2.7 python3 python3.7 python3.7m python3m
Reply 0 0
Guanghua
As long as pyserial works, modify the webserver .py,will function properly . I have had the same problem, When i statically configure "port_name" static as my uart port name,it works
Reply 0 0
lmhhj
I modify OpenPLC_v3/webserver/ webserver.py "port_name", now it works. I can see the com port in web.
企业微信截图_16079250362171.png  And As shown above picture, I just set the Holding Registers , then save device sucessfully.
  But when I start PLC, the dashboard log seem doesn't show the current log, it does'nt contiue to print more message.
企业微信截图_16079253155085.png  The mbconfig.cfg is txt mbconfig.txt     . In addition,I use cutecom to open /dev/ttyS3, and send funcition 0x06 data message to IO board ,the IO board is succeessfully receviced the commanda and make corresponding actions.
 
Reply 0 0
lmhhj
I don't know how to control the IO board by the openplc web. Wherther I need to add one .st file to the web  or by ScadaBR?
Reply 0 0
Guanghua
yes ,you need a .st file by OpenPLC Editor 
Reply 0 0
thiagoralves
lmhhj wrote:

  But when I start PLC, the dashboard log seem doesn't show the current log, it does'nt contiue to print more message.
企业微信截图_16079253155085.png  The mbconfig.cfg is txt mbconfig.txt     . In addition,I use cutecom to open /dev/ttyS3, and send funcition 0x06 data message to IO board ,the IO board is succeessfully receviced the commanda and make corresponding actions.
 

What did you want it to print? The log shows that OpenPLC connected to the device successfully, so it is working. You would only see more messages on the log if it wasn't working. Now you need to program OpenPLC to do whatever you want with your device. As you can see from the slave devices main page, your slave device is hooked up to addresses 100 onward. Just use those addresses to control inputs and outputs on your slave device from a PLC program you can write on OpenPLC Editor
Reply 1 0
lmhhj
Sorry,I have never used  OpenPLC Editor to write my own LD. The I/O board is for controling four relays, and the modus function I use is 0x06, to control the four relays is open or closed.The data type is selected for word, I think it is OK, but when I upload the .st file to openplc, is show compling program is error.

企业微信截图_16080227896924.png the error is 

企业微信截图_16080228743025.png Sorry I don't have enough time to learn plc or read related books for more better using plc_editor.
Reply 0 0
thiagoralves
If you don't know how to use a PLC, you should use something else to control your relay board. Why are you using OpenPLC? You can either Google to learn more about PLCs or use a different tool to control your board.
Reply 0 0
tim292stro
@lmhhj, if you're wondering what just happened...

You basically said that learning this isn't worth your time, but now you're expecting the rest of the world to invest their time in teaching you for free.

If you have the passion and drive, there will always be someone willing to teach, but most of us have only so much time to give to others - remember it needs to be worth THEIR time too...

Don't let frustration get the better of you either, you can miss a great opportunity to learn something you didn't think you needed!
Reply 0 0
richw
Guanghua wrote:
As long as pyserial works, modify the webserver .py,will function properly . I have had the same problem, When i statically configure "port_name" static as my uart port name,it works
Could you post example code to statically configure the port name?
Thanks
Reply 0 0
AlexNVZ
I have done this: 
ports = ["/dev/ttyS1", "/dev/ttyS1]
 
You need to comment out the lines and add them to 2 places.
Reply 0 0
Reply