| Author |
Message |
|
|
Hi JointTech,
The sample code initializes the mobus holding register 0 to 123. For your first test, you don't have to do anything else; you can leave the your-code-goes-here part empty .
Next, hook up the Arduino serial port to the machine running Mango and create a Modubus data source.
Then create a data point for holding register 0 and have Mango poll it regularly. If all goes well, you should get the 123 value in your data point.
When this works, you can proceed to put whatever value you would like in the holding register from the your-code-goes-here section. Just assign the value to regs[MB_REG0]. The start_mb_slave() function in the loop runner will take care of responding to modbus master commands.
|
 |
|
|
Hi mgvanosd,
1) Your Arduino needs to be a modbus slave. You don't need a separate device.
You can use jpmzometa's mobus rtu slave library in your Arduino. I added some code to make it work with Mango. In the meantime this has been included in the library. You can download it from:
http://sites.google.com/site/jpmzometa/arduino-mbrt/arduino-modbus-slave
2) Some sample code can be found here:
http://www.tucsni.nl/jee/
|
 |
|
|
Yes, that did the trick. I no longer get the error messages Thanks !
|
 |
|
|
Hi jjconti,
Yes, Mango is prepared for localization. In you look in the folder WEB-INF/classes you can find the i18n files. If you open messages_en.properties, you will see key=value text lines. You can translate the value part to Spanish and put the translated text in a new file messages_es.properties. Also add a line "es=Espanol" to the file i18n.properties.
|
 |
|
|
Hi Matthew,
I replaced the Modbus4J.jar and set my modbus source to poll holding register 6 and 8 every 5 seconds (serial settings: 9600 8N1). I noticed that most of the time there is no error reported. About 1 out of 10 times I get an error message like this:
WARN 2010-04-09 10:09:05,029 (com.serotonin.mango.rt.dataSource.modbus.ModbusDa
taSource.receivedException:226) - Modbus exception
com.serotonin.modbus4j.exception.IllegalFunctionException: Function code: 0x28
at com.serotonin.modbus4j.msg.ModbusResponse.createModbusResponse(Modbus
Response.java:50)
at com.serotonin.modbus4j.serial.rtu.RtuMessageResponse.createRtuMessage
Response(RtuMessageResponse.java:16)
at com.serotonin.modbus4j.serial.rtu.RtuMessageParser.parseMessageImpl(R
tuMessageParser.java:21)
at com.serotonin.modbus4j.base.BaseMessageParser.parseMessage(BaseMessag
eParser.java:17)
at com.serotonin.messaging.MessageControl.data(MessageControl.java:129)
at com.serotonin.messaging.InputStreamListener.run(InputStreamListener.j
ava:76)
at java.lang.Thread.run(Thread.java:619)
tried to access field gnu.io.RXTXPort.IOLocked from class gnu.io.RXTXHack
The function code 0x28 reported above isn't always the same; it changes now and then. If we look at the serial trace it becomes clear why:
Request: 9-4-2010 10:09:04.25764 (+4.9375 seconds)
01 03 00 06 00 03 E5 CA ......åÊ
Answer: 9-4-2010 10:09:04.28864 (+0.0313 seconds)
01 03 06 00 00 00 00 00 D2 A1 28 ........Ò¡(
It looks like the 0x28 is the last byte of the CRC. Normally I see only 1 request and 1 reply in the trace every 5 secs, but when this error occurs Modbus4J retries and we see a second try shortly after the one that didn't succeed:
Request: 9-4-2010 10:09:05.77264 (+0.4375 seconds)
01 03 00 06 00 03 E5 CA ......åÊ
Answer: 9-4-2010 10:09:05.80464 (+0.0313 seconds)
01 03 06 00 00 00 00 00 D2 A1 28 ........Ò¡(
I suppose that's why I still get the data in Mango despite the errors.
Note that the request-reply that preceded the one with timestamp 10:09:04.25764 looks like this:
Request: 9-4-2010 10:08:59.25764 (+4.9688 seconds)
01 03 00 06 00 03 E5 CA ......åÊ
Answer: 9-4-2010 10:08:59.31964 (+0.0625 seconds)
01 03 06 00 01 00 00 00 D2 9C E8 ........Ò?è
So the 0x28 didn't appear in the answer message prior to the one that didn't succeed.
|
 |
|
|
Hi,
I upgraded from 1.8.0 to Mango 1.8.2. I'm since getting frequent exception messages from Modbus4J that I didn't get in 1.8.0, like this:
WARN 2010-04-07 10:23:07,562 (com.serotonin.mango.rt.dataSource.modbus.ModbusDataSource.receivedException:226) - Modbus exception
com.serotonin.modbus4j.exception.IllegalFunctionException
at com.serotonin.modbus4j.msg.ModbusResponse.createModbusResponse(ModbusResponse.java:50)
at com.serotonin.modbus4j.serial.rtu.RtuMessageResponse.createRtuMessageResponse(RtuMessageResponse.java:16)
at com.serotonin.modbus4j.serial.rtu.RtuMessageParser.parseMessageImpl(RtuMessageParser.java:21)
at com.serotonin.modbus4j.base.BaseMessageParser.parseMessage(BaseMessageParser.java:17)
at com.serotonin.messaging.MessageControl.data(MessageControl.java:129)
at com.serotonin.messaging.InputStreamListener.run(InputStreamListener.java:76)
at java.lang.Thread.run(Thread.java:619)
As an illegal function exception is reported, I'm guessing that the Modbus4J is using a modbus function that wasn't used before. Despite these error reports, my data is still comming in OK in Mango by the way.
I'm polling holding registers with Mango. The modbus device supports the modbus function 3 (read block), 6 (write single reg), 16 (write block). I know that Modbus4J reads with function 3 and writes with function 6 in the Modbus4J version that shipped with Mango 1.8.0. Did this mechanism perhaps change in the latest version ?
|
 |
|
|
Thanks a lot, that worked for me too.
Andras
|
 |
|
|
Hi profnova,
The Mango should normally be in the ROOT directory under webapps. After starting tomcat with the bin/starup.bat (or .sh on *nix) you should be able to get a Mango login page on http://localhost:8080
Be sure to read the installation instruction on the download page for more details:
http://mango.serotoninsoftware.com/download.jsp
|
 |
|
|
Hi Walid,
If your Mango is running op port 8080 (you access it on your localhost with http://localhost:8080), then you could configure your router under NAT/portforwarding/application_sharing (depends on your router) like this: set it to forward public TCP port 8080 of your router (or perhaps 80 if you like) to the LAN IP address and TCP port 8080 of the machine on your LAN (for example 192.168.0.1).
Perhaps stating the obvious, but ofcourse you should use a static LAN address for you server as well, or alternatively configure your router to always assign the same IP address to the paricular ethernet MAC address of your server.
|
 |
|
|
Hi, I have experienced the same thing upgrading from 1.8.0. There seems to be some problem with the Viconics stuff. The following messeages were recorded in the logfile:
5-apr-2010 22:24:07 org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
5-apr-2010 22:24:07 org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
5-apr-2010 22:24:07 org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeAdded('org.apache.catalina.Registry', 'org.apache.tomcat.util.modeler.Registry@15fadcf')
5-apr-2010 22:24:07 org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeAdded('org.apache.catalina.MBeanServer', 'com.sun.jmx.mbeanserver.JmxMBeanServer@8c1dd9')
5-apr-2010 22:24:08 org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
5-apr-2010 22:24:09 org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'DataSourceEditDwr' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: com/serotonin/viconics/ViconicsTransportException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:881)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:837)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:217)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3934)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4429)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:987)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:909)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:495)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1206)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:314)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:28
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: java.lang.NoClassDefFoundError: com/serotonin/viconics/ViconicsTransportException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
at java.lang.Class.getConstructor0(Class.java:2699)
at java.lang.Class.getDeclaredConstructor(Class.java:1985)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:54)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:875)
... 40 more
Caused by: java.lang.ClassNotFoundException: com.serotonin.viconics.ViconicsTransportException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 46 more
I also tried to do a new install instead of an upgrade (with the other zipfile), removing all the MangoDB database files, but I got the same problem there. I then rolled back to 1.8.0 which still works fine.
|
 |
|
|
Regarding your problem to access the manager: did you check that the manager role was assigned to the user with which you tried to access the manager ?
In conf/tomcat-users.xml you should have something like
<tomcat-users>
<role rolename="manager"/>
<user username="manager" password="manager" roles="manager"/>
</tomcat-users>
to be able to access http://localhost:8080/manager/html with user manager
|
 |
|
|
Mango seems to work OK with Firefox 3.6, so as a quick fix you could do this:
In ROOT/resources/header.js in the function checkCombo add a statement that returns true for version == 3.6.
|
 |
|
|
Hi Mario,
For building Mango you don't need the axis stuff. Besides removing the axis jars from the build path, you can remove the last WDSL related part of the build.xml as well. It's not needed for the "deploy" build target. Building the way I described above should then work.
Although building now works, when using the IDE, you will still get quite some unresolved red markings. You can solve that by adding some jars to the build path under the menu "project->properties->java build path->libraries". I used "add jar" to add these jars in war/WEB-INF/lib :
modbus4J
seroUtils
common-httputils
quartz
bacnet4J
commons-codec
joda
You might also need use "add external jar" to point to the servlet and jsp api. For Tomcat 5 these jars are in ${tomcat.home}/lib and are named:
servlet-api
jsp-api
Regards,
Andras
|
 |
|
|
Another possibility could perhaps be to use the http publisher with some voip account or SMS gateway provider. The Betamax voip family (voipbuster etc.) have an http api with which you can send your SMS message using GET variables. Usually the SMS rates are better (at least in Europe) than with a normal GSM subscription.
|
 |
|
|
OK, thanks for the tip. I also added function 6 and I can now set points too I also made the whole thing into a separated Arduino library (which was something that needed to be done anyway).
I also added code to make it easy to check which registers were changed by the master.
I'll ask jpmzometa if he wants to include the changes.
(Again, sorry for being off topic here)
|
 |
|
|