Actually the "missing link" was catching pid of java, not mango, so simple "kill pidof java
" instead "killall mango" inside stop part of script seems to work just fine.
Posts made by ime
-
RE: Start / stop mango from linux shell script
-
RE: Start / stop mango from linux shell script
"kill <procId>" seems to work fine. I`ll try in this direction and post here final working script.
Thanks.
-
RE: Start / stop mango from linux shell script
Ok i changed script a bit so that it works for automatic startup at boot. I added $ALL $sshd in required-start and "&" char at the end of calling ma-start.sh. Now i can get to login prompt from keyboard and also connect over ssh to the system. Also in etc/rc.local file i added these two llines for getting serial port to work correctly with mango (thanks to Cyberdog):
sudo ln -s /dev/ttyAMA0 /dev/ttyS0 sudo chown root:dialout /dev/ttyS0
now my /etc/init.d/mango script looks like this:
#! /bin/sh # /etc/init.d/mango ### BEGIN INIT INFO # Provides: mango # Required-Start: $ALL $sshd $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Description: script to start / stop mango ### END INIT INFO case "$1" in start) echo "Starting mango" /home/pi/mango/ma-start.sh & ;; stop) echo "Stopping mango" killall mango ;; *) echo "Usage: /etc/init.d/mango {start|stop}" exit 1 ;; esac exit 0
Still can
t figure out "stop" part. Killall isn
t solution. -
RE: Start / stop mango from linux shell script
@JoelHaggar said:
Attached is a linux service that works on Ubuntu. I put it in the ext/init/ dir You'll have to edit the path to the ma-start.sh file but then you can run sudo service mango start and sudo service mango stop from the terminal.
Let me know if this works for you?
Joel.
Thanks, this works on ubuntu. I already have similar conf file on ubuntu machine, but i
m trying this also on raspberry pi (sorry, did
t mention at the beginning) which has some issues with upstart configuration files, and i was hoping getting mango as a service through init.d kind of script. Do you have any idea about this?
Also starting on boot with this script as i wrote in first post is not good because mango should run after all other service - with this script i locked myself without login prompt and also ssh deamon didn`t started, so i had to correct files on SD card from another linux box. -
RE: Start / stop mango from linux shell script
@mlohbihler said:
What do you mean the kill signal doesn't close the database as it should? It does for me.
I mean then when i close mango with command "/etc/init.d/mango stop" from another terminal window i cannot run it again because it says the another instance of db is already running. It doesn`t terminate mango as does ctrc+c inside terminal from which mango is started, but rather forcefully shuts it down leaving database open.
-
Start / stop mango from linux shell script
Can someone help me with advice how to stop mango from /etc/init.d shell script.
I want to start mango automatically after machine boots and this works ok, but for shutdown i tried with sending killall signal which is not good as it doesnt close database as it should so mango can
t be started again.So the question is how should i modify stop case in next script so that mango finishes the same way when closed with ctrl+c from terminal window:
#! /bin/sh # /etc/init.d/mango case "$1" in start) echo "Starting mango" /home/user/mango/ma-start.sh ;; stop) echo "Stopping mango" killall mango ;; *) echo "Usage: /etc/init.d/mango {start|stop}" exit 1 ;; esac exit 0
-
RE: Start / stop mango from linux shell script
Can someone help me with advice how to stop mango from /etc/init.d shell script.
I want to start mango automatically after machine boots and this works ok, but for shutdown i tried with sending killall signal which is not good as it doesnt close database as it should so mango can
t be started again.So the question is how should i modify stop case in next script so that mango finishes the same way when closed with ctrl+c from terminal window:
#! /bin/sh # /etc/init.d/mango case "$1" in start) echo "Starting mango" /home/user/mango/ma-start.sh ;; stop) echo "Stopping mango" killall mango ;; *) echo "Usage: /etc/init.d/mango {start|stop}" exit 1 ;; esac exit 0
-
RE: Ubuntu 12.04 / java 1.7.0_09 / librxtx-java / mango automation Installation How-to
Maybe i should mention in first post that i used 32 bit ubuntu. I had no idea that it would matter regarding rxtx issues.
Do you have any clue what would be minimum hardware specifications for running mango smoothly?
-
RE: Ubuntu 12.04 / java 1.7.0_09 / librxtx-java / mango automation Installation How-to
copied from http://rxtx.qbang.org/wiki/index.php/Download#x64_Binaries
x64 Binaries
Should you wish to use RxTx on a x64 based computer, note that the downloads on this page will not work, for x64 compiled binaries go to: Cloudhopper RxTx page. Binaries have been tested successfully on Windows Server 2008 R2, although they are slightly outdated (december 2008), and known to crash when unplugging an USB serial adapter. Another option obtaining prebuilt binaries for x64 is one of the #Known RXTX forks below.
-
RE: Ubuntu 12.04 / java 1.7.0_09 / librxtx-java / mango automation Installation How-to
You
re welcome. Thank you for sharing this SCADA. No special reason for 1.7. I just wanted latest available software packages, and as for tomcat - it
s not needed for latest mango, right?
I also tried installing with openjdk but had some problems regarding librxtx so decided to drop it and install from oracle.
Cheers! -
Ubuntu 12.04 / java 1.7.0_09 / librxtx-java / mango automation Installation How-to
Since i struggled too long with installing this application to get everything right (and i definitely think it’s worth looking into it) i wrote this step by step how-to hoping to save someone else
s time. Although i found this sentence: “Mango Installations are usually very easy and we provide good instruction in the documentation section“, on this web site i actually couldn
t find any for linux installation.
And somehow i got feeling that lack of installation documentation is not because of company’s trying to commercialize whole mango project (there is nothing wrong with that) and to make users pay for support (there is nothing wrong with that also but installation should be straight forward so more time can be spent on exploring application rather than troubleshooting linux issues) so if im right and not ruining someone’s business plan here
s basic how-to for ubuntu installation:I wanted to run this on clean install of ubuntu 12.04 server using old unused hardware. I needed headless cheap system for logging information from device with modbus capability and then automate things like mailing daily reports, connecting to it over internet to see real time values and similar. All that (and much more) is possible with mango. I installed this on old motherboard with serial port, amd barton PCU running at 2,8GHz and with 2GB RAM. I tried also on old P3 machine (700MHz) with 256 MB RAM but its painfully slow and actually not useable. I would like to see someone writes down minimum hardware specs for this application.
**
STEP 1: Install ubuntu 12.04 server edition** with only openssh package selected (i wanted to run this as headless server connected to my modbus device) - you will find this during installation setup.Note: This installation is done with 32 bit ubuntu version - there are issues with librxtx-java (if you need serial port) if installed on 64-bit.
During installation define servers name, your user name, network etc. Be sure to have your server connected to your LAN during installation for automatic network setup (if you have DHCP) or do it manually during install or later.
After installation is finished and network configured you can connect to your new server over ssh (i use putty for that) from some other machine in your LAN.
To get audio signal from pc speaker that your system is up and ready after startup/reboot (since it will not have monitor connected to it) do following steps in your terminal window:sudo apt-get install beep
- add line "pcspkr" in file "/etc/modules":
sudo pico /etc/modules
- add line "beep -l 900 -r 1 -f 500" in file "/etc/rc.local" before "exit 0":
sudo pico /etc/rc.local
(You can try your pc speaker with “beep” command)
**
STEP 2: Installing java from oracle.com **
I installed java according to these instructions with slight modifications (/etc/profile is not the recommended way for adding system variables but rather /etc/environment):
http://www.wikihow.com/Install-Oracle-Java-on-Ubuntu-Linux
Following are mostly copy / paste commands from above site:sudo mkdir -p /usr/local/java
Now download java sdk and jre from oracle (i used at the time latest 7u9 version from http://www.oracle.com/technetwork/java/javase/downloads/index.html).
(to do downloads over terminal window i use method of starting download in my firefox browser and then stopping it and copying download link with right clicking in downloads window and selecting “Copy Download Link”. Then in servers terminal window i use wget + paste. If downloaded file name is mixed up correct it with mv command or similar)
Copy the Oracle Java downloaded binaries into the /usr/local/java directory.
Write following to your terminal window:sudo -s cp -r jdk-7u9-linux-i586.tar.gz /usr/local/java sudo -s cp -r jre-7u9-linux-i586.tar.gz /usr/local/java cd /usr/local/java sudo -s chmod a+x jdk-7u9-linux-i586.tar.gz sudo -s chmod a+x jre-7u9-linux-i586.tar.gz sudo -s tar xvzf jdk-7u9-linux-i586.tar.gz sudo -s tar xvzf jre-7u9-linux-i586.tar.gz ls –a
you should see two directories:
• jdk1.7.0_09
• jre1.7.0_09add system variables JAVA_HOME, JRE_HOME and M2M2_HOME to environment file:
sudo pico /etc/environment
add lines under PATH:
JAVA_HOME=/usr/local/java/jdk1.7.0_09 JRE_HOME=/usr/local/java/jre1.7.0_09 M2M2_HOME=/home/”your user name”/mango
add at the end of PATH following :/usr/local/java/jdk1.7.0_0_09/bin:/usr/local/java/jre1.7.0_09/bin”
save /etc/environment (ctrl+x in pico)
for this changes to take effect you need to logout/login to your user account
after login do following:sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jre1.7.0_09/bin/java" 1
• this command notifies the system that Oracle Java JRE is available for use
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.7.0_09/bin/javac" 1
• this command notifies the system that Oracle Java JDK is available for use
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jre1.7.0_09/bin/javaws" 1
• this command notifies the system that Oracle Java Web start is available for use
sudo update-alternatives --set java /usr/local/java/jre1.7.0_09/bin/java
• this command will set the java runtime environment for the system
sudo update-alternatives --set javac /usr/local/java/jdk1.7.0_09/bin/javac
• this command will set the javac compiler for the system
sudo update-alternatives --set javaws /usr/local/java/jre1.7.0_09/bin/javaws
• this command will set Java Web start for the system
java -version
• This command displays the version of java running on your system
• You should receive a message which displays:
• java version "1.7.0_09"
Java(TM) SE Runtime Environment (build 1.7.0_09-b09)
Java HotSpot(TM) Server VM (build 23.1-b03, mixed mode)javac -version
• This command lets you know that you are now able to compile Java programs from the terminal.
• You should receive a message which displays:
• javac 1.7.0_09STEP 3: Install librxtx-java
To use your serial port for connecting to (in my case) modbus device over rs232->rs485 adapter you need to do following:
according to this site: http://rxtx.qbang.org/wiki/index.php/Installation_on_Linux install librxtx-javasudo apt-get install librxtx-java
then copy files librxtxSerial.so and RXTXcomm.jar to following directories:
sudo cp /usr/lib/jni/librxtxSerial.so /usr/local/java/jdk1.7.0_09/jre/lib/i386 sudo cp /usr/share/java/RXTXcomm.jar /usr/local/java/jdk1.7.0_09/jre/lib/ext
STEP 4: Install mango automation
Now we can download mango automation full core and modbus ip & serial data source from here: http://infiniteautomation.com/index.php/download.html
after download finishes do following:cd /home/”your user name”/ sudo mkdir mango sudo apt-get install unzip unzip ma-full-core-2.0.3.zip –d mango
copy “modbus IP & serial data source” module to mango/web/modules and start mango
sudo cp m2m2-modbus-1.4.1.zip mango/web/modules sudo chmod +x mango/ma-start.sh sudo ./mango/ma-start.sh
Now mango should start and you can connect to it with your browser on any computer inside LAN over address yourserversname:8080
You should be able to add serial modbus (RTU) data source, select appropriate serial port and add data points.
Explore and customize your system. Have fun. -
RE: Ubuntu 12.04 / java 1.7.0_09 / librxtx-java / mango automation Installation How-to
Since i struggled too long with installing this application to get everything right (and i definitely think it’s worth looking into it) i wrote this step by step how-to hoping to save someone else
s time. Although i found this sentence: “Mango Installations are usually very easy and we provide good instruction in the documentation section“, on this web site i actually couldn
t find any for linux installation.
And somehow i got feeling that lack of installation documentation is not because of company’s trying to commercialize whole mango project (there is nothing wrong with that) and to make users pay for support (there is nothing wrong with that also but installation should be straight forward so more time can be spent on exploring application rather than troubleshooting linux issues) so if im right and not ruining someone’s business plan here
s basic how-to for ubuntu installation:I wanted to run this on clean install of ubuntu 12.04 server using old unused hardware. I needed headless cheap system for logging information from device with modbus capability and then automate things like mailing daily reports, connecting to it over internet to see real time values and similar. All that (and much more) is possible with mango. I installed this on old motherboard with serial port, amd barton PCU running at 2,8GHz and with 2GB RAM. I tried also on old P3 machine (700MHz) with 256 MB RAM but its painfully slow and actually not useable. I would like to see someone writes down minimum hardware specs for this application.
**
STEP 1: Install ubuntu 12.04 server edition** with only openssh package selected (i wanted to run this as headless server connected to my modbus device) - you will find this during installation setup.Note: This installation is done with 32 bit ubuntu version - there are issues with librxtx-java (if you need serial port) if installed on 64-bit.
During installation define servers name, your user name, network etc. Be sure to have your server connected to your LAN during installation for automatic network setup (if you have DHCP) or do it manually during install or later.
After installation is finished and network configured you can connect to your new server over ssh (i use putty for that) from some other machine in your LAN.
To get audio signal from pc speaker that your system is up and ready after startup/reboot (since it will not have monitor connected to it) do following steps in your terminal window:sudo apt-get install beep
- add line "pcspkr" in file "/etc/modules":
sudo pico /etc/modules
- add line "beep -l 900 -r 1 -f 500" in file "/etc/rc.local" before "exit 0":
sudo pico /etc/rc.local
(You can try your pc speaker with “beep” command)
**
STEP 2: Installing java from oracle.com **
I installed java according to these instructions with slight modifications (/etc/profile is not the recommended way for adding system variables but rather /etc/environment):
http://www.wikihow.com/Install-Oracle-Java-on-Ubuntu-Linux
Following are mostly copy / paste commands from above site:sudo mkdir -p /usr/local/java
Now download java sdk and jre from oracle (i used at the time latest 7u9 version from http://www.oracle.com/technetwork/java/javase/downloads/index.html).
(to do downloads over terminal window i use method of starting download in my firefox browser and then stopping it and copying download link with right clicking in downloads window and selecting “Copy Download Link”. Then in servers terminal window i use wget + paste. If downloaded file name is mixed up correct it with mv command or similar)
Copy the Oracle Java downloaded binaries into the /usr/local/java directory.
Write following to your terminal window:sudo -s cp -r jdk-7u9-linux-i586.tar.gz /usr/local/java sudo -s cp -r jre-7u9-linux-i586.tar.gz /usr/local/java cd /usr/local/java sudo -s chmod a+x jdk-7u9-linux-i586.tar.gz sudo -s chmod a+x jre-7u9-linux-i586.tar.gz sudo -s tar xvzf jdk-7u9-linux-i586.tar.gz sudo -s tar xvzf jre-7u9-linux-i586.tar.gz ls –a
you should see two directories:
• jdk1.7.0_09
• jre1.7.0_09add system variables JAVA_HOME, JRE_HOME and M2M2_HOME to environment file:
sudo pico /etc/environment
add lines under PATH:
JAVA_HOME=/usr/local/java/jdk1.7.0_09 JRE_HOME=/usr/local/java/jre1.7.0_09 M2M2_HOME=/home/”your user name”/mango
add at the end of PATH following :/usr/local/java/jdk1.7.0_0_09/bin:/usr/local/java/jre1.7.0_09/bin”
save /etc/environment (ctrl+x in pico)
for this changes to take effect you need to logout/login to your user account
after login do following:sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jre1.7.0_09/bin/java" 1
• this command notifies the system that Oracle Java JRE is available for use
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.7.0_09/bin/javac" 1
• this command notifies the system that Oracle Java JDK is available for use
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jre1.7.0_09/bin/javaws" 1
• this command notifies the system that Oracle Java Web start is available for use
sudo update-alternatives --set java /usr/local/java/jre1.7.0_09/bin/java
• this command will set the java runtime environment for the system
sudo update-alternatives --set javac /usr/local/java/jdk1.7.0_09/bin/javac
• this command will set the javac compiler for the system
sudo update-alternatives --set javaws /usr/local/java/jre1.7.0_09/bin/javaws
• this command will set Java Web start for the system
java -version
• This command displays the version of java running on your system
• You should receive a message which displays:
• java version "1.7.0_09"
Java(TM) SE Runtime Environment (build 1.7.0_09-b09)
Java HotSpot(TM) Server VM (build 23.1-b03, mixed mode)javac -version
• This command lets you know that you are now able to compile Java programs from the terminal.
• You should receive a message which displays:
• javac 1.7.0_09STEP 3: Install librxtx-java
To use your serial port for connecting to (in my case) modbus device over rs232->rs485 adapter you need to do following:
according to this site: http://rxtx.qbang.org/wiki/index.php/Installation_on_Linux install librxtx-javasudo apt-get install librxtx-java
then copy files librxtxSerial.so and RXTXcomm.jar to following directories:
sudo cp /usr/lib/jni/librxtxSerial.so /usr/local/java/jdk1.7.0_09/jre/lib/i386 sudo cp /usr/share/java/RXTXcomm.jar /usr/local/java/jdk1.7.0_09/jre/lib/ext
STEP 4: Install mango automation
Now we can download mango automation full core and modbus ip & serial data source from here: http://infiniteautomation.com/index.php/download.html
after download finishes do following:cd /home/”your user name”/ sudo mkdir mango sudo apt-get install unzip unzip ma-full-core-2.0.3.zip –d mango
copy “modbus IP & serial data source” module to mango/web/modules and start mango
sudo cp m2m2-modbus-1.4.1.zip mango/web/modules sudo chmod +x mango/ma-start.sh sudo ./mango/ma-start.sh
Now mango should start and you can connect to it with your browser on any computer inside LAN over address yourserversname:8080
You should be able to add serial modbus (RTU) data source, select appropriate serial port and add data points.
Explore and customize your system. Have fun. -
RE: MODBUS RTU
Thank you for pointing that up. I wasn
t aware of i/o logging before. And it helped me troubleshoot this issue. It turns out that the problem occur because of grouping requests for reading multiple registers that have addresses in sequential order, so one word of data got eaten. :) My device has one variable represented with 2 Bytes and all others are represented with 4. So once i correctly set its data type to 2 bytes all variables with address behind it were correctly displayed. That
s why i was getting correct result with manual reading from single address. My bad.Thanks!
-
MODBUS RTU
Hello,
i need help running mango with modbus rtu protocol.
Im reading data from holding register (4 bytes - 2 words data format) and values i got with automatic pooling are different in sense that word values are switched. If i press reload value button, correct value is displayed. Let me explain a bit more: From one address i read value 73 -> which is 0000 0000 0000 0000 0000 0000 0100 1001 binary (double word variable) and that is correct value also shown on modbus device display. Then all suddenly this value on watch list switches to 4784128 -> which is 0000 0000 0100 1001 0000 0000 0000 0000 binary. Most significant word becomes least significant word and opposite. If i press reload value, it again reads it as 73. I have this problem on linux and windows installations and also on mango m2m 1.12.5 and mango automation 2.0. However ScadaBR which is based on mango doesn
t seem to have this issue. I only tested it on windows for now.Do you have any idea where should i look to correct this and what could be the problem?
-
RE: MODBUS RTU
Hello,
i need help running mango with modbus rtu protocol.
Im reading data from holding register (4 bytes - 2 words data format) and values i got with automatic pooling are different in sense that word values are switched. If i press reload value button, correct value is displayed. Let me explain a bit more: From one address i read value 73 -> which is 0000 0000 0000 0000 0000 0000 0100 1001 binary (double word variable) and that is correct value also shown on modbus device display. Then all suddenly this value on watch list switches to 4784128 -> which is 0000 0000 0100 1001 0000 0000 0000 0000 binary. Most significant word becomes least significant word and opposite. If i press reload value, it again reads it as 73. I have this problem on linux and windows installations and also on mango m2m 1.12.5 and mango automation 2.0. However ScadaBR which is based on mango doesn
t seem to have this issue. I only tested it on windows for now.Do you have any idea where should i look to correct this and what could be the problem?