MarioT
Quote:

kebomar@kebomar-PC ~/OpenPLC_v2
$ node server_win.js
events.js:141
throw er; // Unhandled 'error' event
^

Error: spawn ./core/openplc ENOENT
at exports._errnoException (util.js:873:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)
at onErrorNT (internal/child_process.js:344:16)
at nextTickCallbackWith2Args (node.js:442:9)
at process._tickCallback (node.js:356:17)
at Function.Module.runMain (module.js:443:11)
at startup (node.js:139:18)
at node.js:968:3



The "Cygwin64 Terminal" give me this error when im trying to run "node server_win.js". Help please.
Quote 0 0
thiagoralves
Apparently your build might have failed at some point. Can you run ./build_win.sh and post here the output?
Quote 0 0
MarioT
thiagoralves wrote:
Apparently your build might have failed at some point. Can you run ./build_win.sh and post here the output?


kebomar@kebomar-PC ~/OpenPLC_v2
$ ./build_win.sh
Building OpenPLC environment:
[MATIEC COMPILER]
[LIBMODBUS]
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, 'build-aux'.
libtoolize: linking file 'build-aux/ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'.
libtoolize: linking file 'm4/libtool.m4'
libtoolize: linking file 'm4/ltoptions.m4'
libtoolize: linking file 'm4/ltsugar.m4'
libtoolize: linking file 'm4/ltversion.m4'
libtoolize: linking file 'm4/lt~obsolete.m4'
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/\${ <-- HERE ([^ \t=:+{}]+)}/ at /usr/bin/automake-1.14 line 3930.
configure.ac:33: installing 'build-aux/compile'
configure.ac:32: installing 'build-aux/missing'
src/Makefile.am: installing 'build-aux/depcomp'

------------------------------------------------------
Initialized build system. You can now run ./configure
------------------------------------------------------

checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking how to create a pax tar archive... gnutar
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/home/kebomar/OpenPLC_v2/libmodbus_src':
configure: error: C compiler cannot create executables
See `config.log' for more details
make: *** There's no rule for create the object 'install'. Stop.
[LADDER]
POUS.c
POUS.h
LOCATED_VARIABLES.h
VARIABLES.csv
Config0.c
Config0.h
Res0.c
[GLUE GENERATOR]
/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -ladvapi32
/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lshell32
/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -luser32
/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lkernel32
collect2: error: ld return output state 1
cp: cannot do `stat' sobre './glue_generator_src/glue_generator.exe': No such file or directory


The OpenPLC needs a driver to be able to control physical or virtual hardware.
Please select the driver you would like to use:
1) Blank 4) RaspberryPi 7) Arduino+RaspberryPi
2) Modbus 5) Unipi 8) Simulink
3) Fischertechnik 6) Arduino
#? 6
[OPENPLC]
Generating object files...
Generating glueVars.cpp
./build_core.sh: línea 7: ./glue_generator.exe: No such file or directory
Compiling main program
glueVars.cpp: En la función ‘void glueVars()’:
glueVars.cpp:73:21: error: ‘__IX0_0’ ambit not created
bool_input[0][0] = __IX0_0;
^
glueVars.cpp:74:21: error: ‘__IX0_1’ ambit not created
bool_input[0][1] = __IX0_1;
^
glueVars.cpp:75:22: error: ‘__QX0_0’ ambit not created
bool_output[0][0] = __QX0_0;
^
glueVars.cpp:76:22: error: ‘__QX0_1’ ambit not created
bool_output[0][1] = __QX0_1;
^
server.cpp:31:20: error fatal: modbus.h: No such file or directory
compilation ended.

Edit: Translated to english

Quote 0 0
thiagoralves
The build failed in many stages. It seems that GCC is not working on your environment. You might have a bad installation of cygwin or the packets required to run the OpenPLC are missing. Try to apt-cyg install the packets again by typing:

apt-cyg install gcc-core gcc-g++ git
apt-cyg install automake autoconf libtool make

and show me the output.
Quote 0 0
MarioT
thiagoralves wrote:
The build failed in many stages. It seems that GCC is not working on your environment. You might have a bad installation of cygwin or the packets required to run the OpenPLC are missing. Try to apt-cyg install the packets again by typing: apt-cyg install gcc-core gcc-g++ git apt-cyg install automake autoconf libtool make and show me the output.


kebomar@kebomar-PC ~
$ apt-cyg install gcc-core gcc-g++ git
Package gcc-core is already installed, skipping
Package gcc-g++ is already installed, skipping
Package git is already installed, skipping

---------------------------------------------------------

kebomar@kebomar-PC ~
$ apt-cyg install automake autoconf libtool make
Package automake is already installed, skipping
Package autoconf is already installed, skipping
Package libtool is already installed, skipping
Package make is already installed, skipping

Quote 0 0
thiagoralves
Hmm...apparently all the packets are installed, but the environment is not working. Which windows version are you running?

Try reinstalling cygwin with all the default options (including the default directory) and try again.
Quote 0 0
MarioT
thiagoralves wrote:
Hmm...apparently all the packets are installed, but the environment is not working. Which windows version are you running? Try reinstalling cygwin with all the default options (including the default directory) and try again.


Already done that. Windows 10 Home 64bits
Quote 0 0
thiagoralves
That's very weird. The compilation is failing when it checks the C compiler: 
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/home/kebomar/OpenPLC_v2/libmodbus_src':
configure: error: C compiler cannot create executables


And then it fails again when it tries to load a bunch of libraries to compile a single .cpp file:
/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -ladvapi32
/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lshell32
/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -luser32
/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lkernel32


I'm not sure about this, but have you tried to run cygwin as administrator (right click at the link on start menu and then run as administrator) and then reinstall the packets and build again? It seems that something is wrong about permissions or cygwin paths are bad or not set. I'll ask Dr. Google about it and see what I can find.
Quote 0 0
thiagoralves
I did a quick Google search and I found this and this where people were saying that anti-virus is causing a problem similar to yours. Do you have any anti-virus installed and enabled (other than the default one that comes with windows)? If you have, try disabling it during the build process.
Quote 0 0
MarioT
  1. No others anti-virus installed. 
  2. I disable windows defender and firewall, did a clean install of cygwin.
  3. Remember that before when I was running the commands it give some mensgae like this "wget is not installed, using lynx as fallback" so before everything i run this command "apt-cyg install wget".
  4. Then run this: apt-cyg install gcc-core gcc-g++ git.
                            apt-cyg install automake autoconf libtool make.
5. node server_win.js

Now I can work on the Web Interface. So I run the hello world example (.st file generated) it says running but where do I see it run it?

PS: Thanks for the help!









Quote 0 0
thiagoralves
The message "wget is not installed" is not a problem. It is just used to download the packets from the web, but Lynx can do it just fine. Perhaps it was some problem with windows defender... I have a clean installation of Windows 10 Home 64bits and installed OpenPLC on it just fine. Anyway, I'm glad it is working now. [smile]

The program is running on your computer, it is just like a PLC. You need to give it some I/O to control in order for you to see things happening. The I/O you will use depends on which driver you chose by the end of the build process. If you chose blank, there isn't any I/O for the OpenPLC to control. You can interact with it using any Modbus Master software like Modbus Poll, Radzio or this one. But this is no fun. The best way would be to have some real I/O for you to interact with. The cheapest one is an Arduino board. If you have an Arduino board lying around somewhere, just connect it to your computer, build OpenPLC again and select the Arduino driver. You will then be able to program the board as you would do with a PLC.

You can find more information about the OpenPLC on Arduino here: http://www.openplcproject.com/#!getting-started-arduino/id7fq
Quote 0 0
MarioT
I got another problem

I'm using an Arduino Mega2560. Upload the "OpenPLC_MEGA_fw" to the board without errors, then I upload the .st generated by "PLCOpenEditor" with the Hello World example and compile without erros again. Everything seems fine but when I try to test the program on the board using the specified pins of your Pin Mapping and does nothing as spected. So I checked the PLC Logs and says this: 

Quote:
Starting OpenPLC Application...
OpenPLC Software running...

Port found: ttyS0
Port found: ttyS3

Trying to open /dev/ttyS0

Couldn't read from IO

Couldn't read from IO

Couldn't read from IO

Couldn't read from IO

Couldn't read from IO

The port didn't respond properly

Trying to open /dev/ttyS3

Couldn't read from IO

Couldn't read from IO

Couldn't read from IO

Couldn't read from IO

Couldn't read from IO

The port didn't respond properly

Couldn't find any suitable port

Getting current time

Waiting for Modbus/TCP connection on Port 502


I don't know how the web interface works but I think it isn't uploading correctly
Quote 0 0
thiagoralves
For some reason it couldn't find your Arduino board. Can you tell me on which COM port it is connected? Also, when you start the OpenPLC, do you see the RX/TX lights flashing on the Arduino?
Quote 0 0
MarioT
COM4
Type: Port (COM y LPT)
Manufacturer: Arduino LLC (www.arduino.cc)
Location: Port_#0002.Hub_#0003

On OpenPLC just flash the RX. TX is off all the time

Quote 0 0
thiagoralves

If the RX is flashing it means that the OpenPLC is trying to communicate with the board but the board is not responding. Let's make sure that the firmware is working on your board. I don't have a Mega to test, but both firmwares worked great on my Uno (obviously the pinout was messed up when I used the Mega firmware, but the communication with OpenPLC worked).

To test the communication, burn the firmware again using the arduino IDE (btw I'm using Arduino IDE 1.6.7), then open Serial Monitor and set the speed to 115200. Make sure that the drop down menu on the bottom of the screen says "No line ending". Then write this message and click Send:

S0000000E

You should receive some feedback with weird characters as the picture below:

Capture.PNG 
If you don't see any response, your arduino board is not working properly with the firmware. Try uploading the Uno firmware and repeat the test.

Quote 0 0