Thursday, November 19, 2015
Monitor the Boat, remotely
With a FONA connected on the Raspberry PI (where the NMEA Console is running), you can remotely monitor what's going on.
The feature has been implemented - as usual - as a UserExit.
This UserExit is in the Desktop repo, the FONA Java interface is here.
Just by sending an SMS, you can retrieve the data read by the Raspberry PI on board, like True Wind Speed, Battery Voltage, Air and Water Temperature, etc, all you need is a smart phone that can send and receive SMSs.
That sounds promising...
This assumes that the boat is docked in a place where there is SMS coverage, of course. I'm working on an Internet version...
Just by sending an SMS, you can retrieve the data read by the Raspberry PI on board, like True Wind Speed, Battery Voltage, Air and Water Temperature, etc, all you need is a smart phone that can send and receive SMSs.
That sounds promising...
This assumes that the boat is docked in a place where there is SMS coverage, of course. I'm working on an Internet version...
Saturday, September 12, 2015
Ephemeris emails
Along with the headless mode, you can now send ephemeris emails to whoever you want.
The email you'd receive would look like this:
For this, you need to set some preferences:
When all this is set, you have to modify the command line that starts the Weather Wizard in headless mode:
Enjoy!
PS: The code is in github, see below for details.
The email you'd receive would look like this:
Ephemeris for 12 Sep 2015
At N 37°46.00' / W 122°31.00' Sun Rise:12 Sep 2015 06:52 Sun Set :12 Sep 2015 19:20 Moon Phase: 28 day(s).
Tide at Ocean Beach: LW Sat Sep 12 04:52:00 PDT 2015 : +0.40 feet HW Sat Sep 12 11:34:00 PDT 2015 : +5.27 feet LW Sat Sep 12 17:09:00 PDT 2015 : +1.45 feet HW Sat Sep 12 23:14:00 PDT 2015 : +5.47 feet
For this, you need to set some preferences:
- The position is used for the sun rise and set
- The tide station must be spelled exactly as in the tide application (in the Navigation Console)
- You can send to several recepients, separated with a semi-column
- The timezone is used to display the sun ephemeris
- The email provider refers to the file
ephemeris.email.properties, see below
ephemeris.email.properties, this file must be in the all-scripts directory.
ee.yahoo.mail.protocol=pop3 ee.yahoo.incoming.server=pop.mail.yahoo.com ee.yahoo.outgoing.server=smtp.mail.yahoo.com ee.yahoo.mail.smtpauth=true ee.yahoo.outgoing.server.port=587 ee.yahoo.mail.username=olivier.lediouris ee.yahoo.mail.password=XXXXXX ee.yahoo.mail.replyto=olivier@lediouris.net # ee.google.mail.protocol=pop3 ee.google.incoming.server=pop.gmail.com ee.google.outgoing.server=smtp.gmail.com ee.google.mail.smtpauth=true ee.google.outgoing.server.port=465 ee.google.incoming.server.port=995 ee.google.mail.username=olivier.lediouris@gmail.com ee.google.mail.password=XXXXXX ee.google.mail.replyto=olivier.lediouris@gmail.com # ee.oracle.mail.protocol=imap ee.oracle.incoming.server=stbeehive.oracle.com ee.oracle.outgoing.server=stbeehive.oracle.com ee.oracle.mail.smtpauth=true ee.oracle.outgoing.server.port=465 ee.oracle.incoming.server.port=993 ee.oracle.mail.username=olivier.lediouris@oracle.com ee.oracle.mail.password=XXXXXX ee.oracle.mail.replyto=olivier.lediouris@oracle.com #The email provider mentionned in the preferences can be in this example
yahoo, google, or oracle.
When all this is set, you have to modify the command line that starts the Weather Wizard in headless mode:
set JAVA_OPTIONS=%JAVA_OPTIONS% -Dheadless=true -Dephemeris.email=true -Dstart.ephemeris.loop.at=05:00This will generate the email displayed above every day at 5am local time.
Enjoy!
PS: The code is in github, see below for details.
Wednesday, April 8, 2015
GoogleCode going out of business
GoogleCode will close soon, I moved everything on github.
For the navigation part, you can build everything for yourself from here.
This could be the opportunity to move things around, and do some cleanup, to make the distribution and the result of such builds identical.
With the integration of the Raspberry PI in the navigation console, the paradign has slightly shifted, the architecture becomes more hub-and-spoke oriented.
It makes the data avaiable to any software able to understand non-serial protocols like TCP, UDP, etc.
OpenCPN, SeaWi, fall in that category, specially that now, I found a way to create an Access-Point network from the Raspberry PI, it makes it available to Android devices.
For the Raspberry, the easiest seems to post SD Card images, like here.
Thursday, January 8, 2015
Version 3.0.1.5 available
New version - for both the Weather Wizard and the Navigation Console - 3.0.1.5 is available, at the usual place.
Few new features, minor UI improvements, and big uptake for the Raspberry PI.
A new feature for the Weather Wizard in headless mode, you can download several composites at the same time (one after the other actually). Use the
For example, on Windows:
Few new features, minor UI improvements, and big uptake for the Raspberry PI.
A new feature for the Weather Wizard in headless mode, you can download several composites at the same time (one after the other actually). Use the
-composite: and -pattern: parameters, separate each value with a comma.
For example, on Windows:
set PRMS=-composite:./patterns/01.Favorites/01.3.00.Pacific.Sfc.500.Tropic.GRIB.ptrn set PRMS=%PRMS%,./patterns/01.Favorites/06.01.AllPac.Faxes.Satellite.ptrn set PRMS=%PRMS% -interval:360 set PRMS=%PRMS% "-pattern:/yyyy/MM-MMM | | yyyy-MM-dd_HHmmss_z | _Pacific | waz,/yyyy/MM-MMM | | yyyy-MM-dd_HHmmss_z | _Pacific.SatPic | waz" :: set command=java %JAVA_OPTIONS% -client -classpath "%CP%" -Dheadless=true main.splash.Splasher %PRMS%On Linux and Mac:
PRMS=-composite:./patterns/01.Favorites/01.3.00.Pacific.Sfc.500.Tropic.GRIB.ptrn PRMS=$PRMS,./patterns/01.Favorites/06.01.AllPac.Faxes.Satellite.ptrn PRMS=$PRMS -interval:360 PRMS=$PRMS "-pattern:/yyyy/MM-MMM | | yyyy-MM-dd_HHmmss_z | _Pacific | waz,/yyyy/MM-MMM | | yyyy-MM-dd_HHmmss_z | _Pacific.SatPic | waz" # command=java $JAVA_OPTIONS -client -classpath "$CP" -Dheadless=true main.splash.Splasher $PRMS
Sunday, December 21, 2014
Un peu de finesse, dans ce monde de brutes
Trois poëtes, trois poëmes
Ah seja como for, seja por onde for, partir!
Largar por aì fora, pelas ondas, pelo perigo, pelo mar.
Ir para Longe, ir para Fora, para a Distância Abstrata,
Indefinidamente, pelas noites misteriosas e fundas,
Levado, como a poeira, plos ventos, plos vendavais!
Ir, ir, ir, ir de vez!
Ah, n'importe comment et n'importe où, partir !
Larguer les amarres hors d'ici, cap sur les vagues, le péril et la mer.
S'en aller au Large, au Dehors, à l'Abstraite Distance,
Indéfiniment, dans les nuits mystérieuses et profondes,
Emporté, comme la poussière, par les vents, par les ouragans !
S'en aller, s'en aller, s'en aller une bonne fois !
(Traduit par Patrick Quillier)
Fernando Pessoa, Ode maritime
VIII
Ô Mort, vieux capitaine, il est temps ! Levons l'ancre !
Ce pays nous ennuie, ô Mort ! Appareillons !
Si le ciel et la mer sont noirs comme de l'encre,
Nos cœurs que tu connais sont remplis de rayons !
Verse-nous ton poison pour qu'il nous réconforte !
Nous voulons, tant ce feu nous brûle le cerveau,
Plonger au fond du gouffre, Enfer ou Ciel, qu'importe ?
Au fond de l'inconnu pour trouver du nouveau !
Charles Baudelaire, Les Fleurs du Mal, La Mort, Le Voyage.
Avec ses quatre dromadaires
Don Pedro d'Alfaroubeira
Courut le monde et l'admira
Il fit ce que je voudrais faire
Si j'avais quatre dromadaires
Guillaume Appollinaire, Alcools, Le Dromadaire
Tuesday, August 12, 2014
Raspberry PI on board: the numbers!
Using the Charger Doctor from Adafruit, I was able to see how much the Raspberry PI is drawing when at work.
When it boots, with the 7" RCA screen on, it takes 0.24 Amps. This remains the same when starting the Headless Console, with user-exits, battery monitoring, and re-broadcasting on HTTP and TCP.
When the small RCA screen is turned off, the consumption drops to 0.19 to 0.20 Amps.
As
This even below what the Raspberry PI documentation is saying!
When it boots, with the 7" RCA screen on, it takes 0.24 Amps. This remains the same when starting the Headless Console, with user-exits, battery monitoring, and re-broadcasting on HTTP and TCP.
When the small RCA screen is turned off, the consumption drops to 0.19 to 0.20 Amps.
As
P = UI, that means that the Raspberry PI at works takes about 1 Watt (5v × 0.2 A).
This even below what the Raspberry PI documentation is saying!
Saturday, June 21, 2014
Raspberry Sailing. How the Raspberry Pi makes sense on board.
A computer can be helpful on board, for several reasons.
Electricity can be precious on board (specially on a sail boat, where it is in short supply), it is required to run several important devices, like the autopilot, the water maker, and to some extend, the fridge. A laptop can draw a substantial amount of current, specially if its battery is old (2 to 3 amps and more, I have evidences). In those conditions, leaving it on all the time can be questionable. On top of that, turning it down, and turning it back up takes time...
The chart plotter will be interested in the GPS data, another soft might be interested in the wind data; but there is no way around, one program, one port.
GPSd does not address this issue (even if it pretends to), and - in my opinion - makes things more complex. It's only interested in GPS data (not in Speed Through Water, not in Wind Data, etc), but it locks the port like everyone else, and just rebroadcasts them in another bloody format! Why isn't it just rebroadcasting the NMEA sentences as they've been read?.., I have no idea.
The Raspberry PI can read the serial port - Ok, exclusively - and re-broadcast the data on whatever channel (TCP, HTTP, UDP, RMI, whatever). This way they can be accessed from this channel, the data remaining the same. As soon as a device is turned on, it can join the ad-hoc network created by the Raspberry PI, and immediately read the data it broadcasts.
A program like OpenCPN is smart enough to support several kinds of channels.
HTTP is also an option to consider, smart phones and tablets are ready for that, without any modifications. HTML5 and CCS3 will do the job. Those devices have browsers that understand those technologies. It is very easy to display the data read by the Raspberry PI on an iPhone.
In addition, the Raspberry PI can log the data read from the NMEA Port, its SD card is big enough to log several days of data. Another feature of the Raspberry PI is its GPIO Header. This is the bridge to the world of sensors. For example, the BMP180 will allow the Raspberry PI to read the air temperature and the atmospheric pressure. Those data can very well be injected in the NMEA stream (they both have an NMEA equivalent). Some navigation station already provide this kind of interfaces, but in case yours does not, you will then get those data for less than $10.
See some implementation details here.
Even further, it is not difficult to come up with a small setting the Raspberry PI can use to monitor the tension of the batteries on the boat. This one does not - as far as I know - have an NMEA equivalent. It can be injected in the NMEA stream though, it will be considered as a custom sentence. And it can be logged too, along with the rest.
If needed, the data can be displayed on the Raspberry PI as they are read. I did some tests with a graphical interface, as well as in character mode, just to keep the energy consumption as low as possible. The screen is turned off when not needed, for the same reason.
Basically, you can reproduce the settings used during the last Aremica's Cup, for a tiny fraction of their budget! The Raspberry PI is less than $40.
Compare with this...
- Some useful navigation softwares need one to run (SailMail, for example, that allows you to receive faxes through the SSB, send and receive emails, all kinds of useful things)
- Some chart plotter softwares (like OpenCPN, the best) require a computer to run as well, to plot the current position on an electronic chart.
- The on-board electronics can be read from a computer (through NMEA, or some other proprietary protocols), and the data they emit can be used as parameters for calculations, like performance evaluation, routing, current estimation (tricky, but so useful).
Electricity can be precious on board (specially on a sail boat, where it is in short supply), it is required to run several important devices, like the autopilot, the water maker, and to some extend, the fridge. A laptop can draw a substantial amount of current, specially if its battery is old (2 to 3 amps and more, I have evidences). In those conditions, leaving it on all the time can be questionable. On top of that, turning it down, and turning it back up takes time...
Serial port access
The data we are interested in usually (like in 99% of the cases) come from a Serial port (USB, or 9-pins). A big detail to mention is that a Serial port can only be accessed by one process at a time. That means that when your chart plotter accesses the serial port, no other program can access it, even it is is not the same data the other program is interested in.The chart plotter will be interested in the GPS data, another soft might be interested in the wind data; but there is no way around, one program, one port.
GPSd does not address this issue (even if it pretends to), and - in my opinion - makes things more complex. It's only interested in GPS data (not in Speed Through Water, not in Wind Data, etc), but it locks the port like everyone else, and just rebroadcasts them in another bloody format! Why isn't it just rebroadcasting the NMEA sentences as they've been read?.., I have no idea.
Introducing the Raspberry PI
The Raspberry PI does much more than the boards like Arduino, Sparkfun, Beaglebones, and others (those are great, don't get me wrong, I am not spitting in the soup), it is a fully featured Linux (Debian) computer, that can - as such - do all a computer can do, like multi tasking, multi threading, remote access (SSH, VNC), network access (Ethernet and Wireless). It only has 512 Mb of RAM. But that is enough, as we will see. Its hard disk is replaced by an SD card, ranging from 4GB to whatever you want. I use 16Gb cards. And at work, it draws less than 500mA, which is ridiculous. You can plug several kinds of screen on the Raspberry PI, a TV screen using an HDMI port, or a rear camera car monitor (3.5", 4.3", or 7") using an RCA port. Turning those screens off when not needed will also contribute to save some energy.The Raspberry PI can read the serial port - Ok, exclusively - and re-broadcast the data on whatever channel (TCP, HTTP, UDP, RMI, whatever). This way they can be accessed from this channel, the data remaining the same. As soon as a device is turned on, it can join the ad-hoc network created by the Raspberry PI, and immediately read the data it broadcasts.
A program like OpenCPN is smart enough to support several kinds of channels.
HTTP is also an option to consider, smart phones and tablets are ready for that, without any modifications. HTML5 and CCS3 will do the job. Those devices have browsers that understand those technologies. It is very easy to display the data read by the Raspberry PI on an iPhone.
In addition, the Raspberry PI can log the data read from the NMEA Port, its SD card is big enough to log several days of data. Another feature of the Raspberry PI is its GPIO Header. This is the bridge to the world of sensors. For example, the BMP180 will allow the Raspberry PI to read the air temperature and the atmospheric pressure. Those data can very well be injected in the NMEA stream (they both have an NMEA equivalent). Some navigation station already provide this kind of interfaces, but in case yours does not, you will then get those data for less than $10.
See some implementation details here.
Even further, it is not difficult to come up with a small setting the Raspberry PI can use to monitor the tension of the batteries on the boat. This one does not - as far as I know - have an NMEA equivalent. It can be injected in the NMEA stream though, it will be considered as a custom sentence. And it can be logged too, along with the rest.
If needed, the data can be displayed on the Raspberry PI as they are read. I did some tests with a graphical interface, as well as in character mode, just to keep the energy consumption as low as possible. The screen is turned off when not needed, for the same reason.
Useful links
- OpenCPN
- Raspberry PI
- Adafruit
- NMEA Console, that runs on the Raspberry PI
Basically, you can reproduce the settings used during the last Aremica's Cup, for a tiny fraction of their budget! The Raspberry PI is less than $40.
Compare with this...
If it does not work for you, do let me know, it should. I might be able to help.
Wednesday, June 11, 2014
Character Mode Console, for the Raspberry PI
Working on low consumption setup...
The laptop is quite demanding on the batteries, but the Raspberry PI is not.
The thing is that the laptop can do many calculations, for example for the current speed and direction, using real time triangulation, dead reckoning on 1 minute, dead reckoning on 10 minutes, etc...
Being written in Java, the console runs - theorically - also on the Raspberry PI. This is true, but the Swing UI is definitely too demanding on the RasPI.
Well, the is now available in character mode, driven by the file named
The RasPi can rebroadcast the NMEA - and calculated - data on TCP, UDP, http, etc. So, the laptop can use them (from OpenCPN for example), as well as tablets or other devices, as shown in earlier posts.
All this - along with the routing on archived GRIB files - is available in a new version (3.0.1.4), available at the usual place (Navigation Desktop, and Weather Wizard). One detail though, Google Code does not support the downloads anymore, I moved the new ones to Google Drive. Use the link you'll find in the "Featured" section on the project pages.
The laptop is quite demanding on the batteries, but the Raspberry PI is not.
The thing is that the laptop can do many calculations, for example for the current speed and direction, using real time triangulation, dead reckoning on 1 minute, dead reckoning on 10 minutes, etc...
Being written in Java, the console runs - theorically - also on the Raspberry PI. This is true, but the Swing UI is definitely too demanding on the RasPI.
Well, the is now available in character mode, driven by the file named
char.console.properties.
Notice on the screen, some data come from some sensors that can be attached to the RasPi, like air temperature, atmospheric pressure, battery voltage.
The RasPi can rebroadcast the NMEA - and calculated - data on TCP, UDP, http, etc. So, the laptop can use them (from OpenCPN for example), as well as tablets or other devices, as shown in earlier posts.
All this - along with the routing on archived GRIB files - is available in a new version (3.0.1.4), available at the usual place (Navigation Desktop, and Weather Wizard). One detail though, Google Code does not support the downloads anymore, I moved the new ones to Google Drive. Use the link you'll find in the "Featured" section on the project pages.
Monday, June 2, 2014
Introducing the "Archived GRIB Routing"
The idea here is like replacing the pilot charts with some GRIBs stored in some composites you have already archived, to plan a trip for example.
At sea, the GRIBs you will download will provide a reliable forecast for about 3 days. After that, it's more like science fiction...
By looking into your archived composites, you can have a look at the weather that actually happened.
This brings us back to the importance of naming conventions, mentioned in the User's Manual.
Open the Weather Wizard as usual, without loading any data. Re-locate the chart to the desired area, if needed. Next, plot the start and arrival points. Let's try here to go from the SF Bay Area to the Christmas Island, in the Kiribati Republic. Next, go to the menu Tools > Routing > Routing from Archived GRIBs You will be prompted to choose the directory containing the composites containing the GRIBs you are interested in, and the Regular Expression filtering them. Just in case you forgot,
This feature is still in development, it will be available very soon.
Hope you will lilke it!
At sea, the GRIBs you will download will provide a reliable forecast for about 3 days. After that, it's more like science fiction...
By looking into your archived composites, you can have a look at the weather that actually happened.
This brings us back to the importance of naming conventions, mentioned in the User's Manual.
Here is a quick step-by-step introduction to the feature.
Click on the images to see them in full size, easier to read.Open the Weather Wizard as usual, without loading any data. Re-locate the chart to the desired area, if needed. Next, plot the start and arrival points. Let's try here to go from the SF Bay Area to the Christmas Island, in the Kiribati Republic. Next, go to the menu Tools > Routing > Routing from Archived GRIBs You will be prompted to choose the directory containing the composites containing the GRIBs you are interested in, and the Regular Expression filtering them. Just in case you forgot,
".*" will select everything (no filter).
The application will tell you how many composites your selection will return, they will be used to build one single BIG GRIB document that will be used to compute the routing.
One important thing to be careful with: By default, the application suggests you to start the routing at the current time and date. As you can see on the dialog, the GRIB start and end dates do not contain the current date. You need to change the date you want to start the routing from, so it is within the GRIB date range.
Now, the routing start date is within the GRIB's range.
From now on, the process is the usual routing one. Except that the GRIB will probably not expire.
You can tell by the color of the isochrones that the GRIB did indeed not expire.
Note: Once the big GRIB has been generated, it is loaded in the application, just like if it had been downloaded from the net, or read from the disc. You can re-launch a routing computation without having to re-generate it, until you close the tab it lives in.
This feature is still in development, it will be available very soon.
Hope you will lilke it!
Labels:
archived,
composite,
grib,
pilot charts,
routing,
Weather Wizard
Wednesday, May 14, 2014
Kiting the Bay
Warm weather in the SF Bay Area this week, the wind picks up around 3 in the afternoon, easily reaching 20 knots near Treasure Island.
Monday, May 12, 2014
Monitoring the batteries with the Raspberry PI
It turned out to be easy and inexpensive.
See the details here.
The next step will be to log all this, along with the wind speed, to see how the wind generator works with the solar panel.
See the details here.
The next step will be to log all this, along with the wind speed, to see how the wind generator works with the solar panel.
Thursday, April 10, 2014
Introducing live wallpaper in the Navigation Desktop
The foreground data were not very convenient, they are now replaced with a "Live Wallpaper".
And there is also an option to put the desktop in full screen.
And there is also an option to put the desktop in full screen.
Tuesday, April 1, 2014
NMEA Multiplexing, with Raspberry PI and sensors
This is a first test, but already promising...
See details here.
Still working on the Atmospheric Pressure for OpenCPN, trying to manage the MDA NMEA Sentence.
More to come, stay tuned.
Tuesday, March 25, 2014
SPOT Parser in the Console
We already had one Web version of a SPOT Parser, we now have one embedded in the Navigation Console.
It allows the manipulation of the SPOT bulletins even if you are far from the Internet...
It also comes with a possibility to compose your own SPOT request.
At sea, you would compose your request (possibly with the data from the GPS), paste it into your Airmail client to send it through SailMail.
Once the response is in your inbox, you paste it in the utility featured above, and you have a graphical rendering of the SPOT data.
Enjoy!
At sea, you would compose your request (possibly with the data from the GPS), paste it into your Airmail client to send it through SailMail.
Once the response is in your inbox, you paste it in the utility featured above, and you have a graphical rendering of the SPOT data.
Enjoy!
Wednesday, December 18, 2013
Introducing the Headless Weather Wizard
Two things:
You just need to run it this way:
On Windows:
On Linux:
Notice the parameters
This means that the pattern mentioned in
- The Weather Wizard runs on a Raspberry PI
- It can load (and save) a default composite, and reload it on a regular base
You just need to run it this way:
On Windows:
set MEM_OPTIONS=-XX:NewSize=512m -XX:MaxNewSize=512m -Xmn768m -Xms1024m -Xmx1024m set MEM_OPTIONS=%MEM_OPTIONS% -XX:SurvivorRatio=1 -XX:PermSize=30m -XX:+UseParallelGC set JAVA_OPTIONS=%EXTRA_JVM_PRM% %MEM_OPTIONS% %JAVA_OPTIONS% :: set PRMS=-composite:./patterns/01.Favorites/01.3.00.Pacific.Sfc.500.Tropic.GRIB.ptrn set PRMS=%PRMS% -interval:360 set PRMS=%PRMS% "-pattern:/yyyy/MM-MMM | Auto_ | yyyy_MM_dd_HH_mm_ss_z | waz" :: set command=java %JAVA_OPTIONS% -client -classpath "%CP%" -Dheadless=true main.splash.Splasher %PRMS% start "Headless Weather Wizard" %command%
MEM_OPTIONS=-XX:NewSize=512m -XX:MaxNewSize=512m -Xmn768m -Xms1024m -Xmx1024m MEM_OPTIONS=$MEM_OPTIONS -XX:SurvivorRatio=1 -XX:PermSize=30m -XX:+UseParallelGC JAVA_OPTIONS=$EXTRA_JVM_PRM $MEM_OPTIONS $JAVA_OPTIONS # PRM1=-composite:./patterns/01.Favorites/01.3.00.Pacific.Sfc.500.Tropic.GRIB.ptrn PRM2=-interval:360 PRM3="-pattern:/yyyy/MM-MMM | Auto_ | yyyy_MM_dd_HH_mm_ss_z | waz" # java $JAVA_OPTIONS -client -classpath "$CP" -Dheadless=true main.splash.Splasher $PRM1 $PRM2 "$PRM3" &
-composite:, -interval:, and -pattern:.
Same for the System variable -Dheadless=true.
This means that the pattern mentioned in
-composite: will be reloaded every 360 minutes, and stored as stated in the -pattern: parameter.
Labels:
fax,
grib,
headless,
meteo,
Raspberry Pi,
sailing,
Weather Wizard
Monday, December 16, 2013
Introducing Console User-Exits
There are many things to do with the NMEA Data available in the cache, and the console
is just doing a little - obvious - part of them.
In order for the users to implement their own features and ideas, we now provide a "user-exit" mechanism.
The user-exits are to be written in Java, and implement a specific interface named
It could probably not be any simpler.
Here is a simple implementation of this interface. This one evaluates the True Wind Speed every time a sentence is received from the NMEA station, and displays a message if the TWS is above 10 knots.
See how the
You have an internet connection on the boat, it is docked or anchored in the harbor.
From wherever you are, you want to know what the wind is like where the boat is.
This user-exit monitors the True Wind Speed (TWS), and send an email when it is above a given threshold. It looks at the wind speed every X minutes, the X comes from a configuration file (
All the sources of this example.
Possibilities are endless. The limit is your imagination.
Combining the two examples above, you can as well gather all the data into a single document (XML, json, etc), and send it through email on a regular base, so it can be rendered by the receipient.
Etc, etc...
In order for the users to implement their own features and ideas, we now provide a "user-exit" mechanism.
The user-exits are to be written in Java, and implement a specific interface named
olivsoftdesktop.DesktopUserExitInterface,
and defined as foillow:
1 package olivsoftdesktop;
2
3 public interface DesktopUserExitInterface
4 {
5 public void start();
6 public void stop();
7 public void describe();
8 }
A Simple User-exit implementation
To develop your own features, you would need to put - at least - into your classpath:desktop.jar
nmeaparser.jarnmeareader.jarcoreutilitiesgeomutil.jar
Here is a simple implementation of this interface. This one evaluates the True Wind Speed every time a sentence is received from the NMEA station, and displays a message if the TWS is above 10 knots.
See how the
NMEAReaderListener is registered.
1 package olivsoftdesktop.sampleue;
2
3 import nmea.event.NMEAReaderListener;
4 import nmea.server.ctx.NMEAContext;
5 import nmea.server.ctx.NMEADataCache;
6 import ocss.nmea.parser.Angle360;
7 import ocss.nmea.parser.Speed;
8 import olivsoftdesktop.DesktopUserExitInterface;
9
10 public class UserExitSample
11 implements DesktopUserExitInterface
12 {
13 public UserExitSample()
14 {
15 super();
16 }
17
18 @Override
19 public void start()
20 {
21 System.out.println("User exit is starting...");
22 NMEAContext.getInstance().addNMEAReaderListener(new NMEAReaderListener()
23 {
24 @Override
25 public void manageNMEAString(String nmeaString)
26 {
27 // System.out.println(" ... From user exit, got NMEA Data [" + nmeaString + "]");
28 NMEADataCache dc = NMEAContext.getInstance().getCache();
29 double tws = ((Speed) dc.get(NMEADataCache.TWS)).getValue();
30 double twd = ((Angle360) dc.get(NMEADataCache.TWD)).getValue();
31 if (tws > 10 && !Double.isInfinite(tws))
32 {
33 System.out.println("Wind is over 10 kts:" + tws + ", TWD:" + twd);
34 // TODO Send an email...
35 }
36 }
37 });
38 }
39
40 @Override
41 public void stop()
42 {
43 System.out.println("Terminating User exit");
44 }
45
46 @Override
47 public void describe()
48 {
49 System.out.println("This is a simple user-exit example that shows howto register an NMEAReaderListener from your code.");
50 }
51 }
User-exit runtime
To have your user-exit to be taken care if, you need to:-
Archive it in a jar-file, and put the jar (along with the ones it may depend on) in one of the following directories
all-user-exits(recommended)all-libsall-3rd-party
-
Mention the name of the user-exit in the command-line parameters, like
-ue:myspecial.feature.SuperUserExit. For the example above, the parameter would be-ue:olivsoftdesktop.sampleue.UserExitSample.
A more complex sample
Here is the scenario:You have an internet connection on the boat, it is docked or anchored in the harbor.
From wherever you are, you want to know what the wind is like where the boat is.
This user-exit monitors the True Wind Speed (TWS), and send an email when it is above a given threshold. It looks at the wind speed every X minutes, the X comes from a configuration file (
email.properties) that can be edited.
1 package olivsoftdesktopuserexits;
2
3 import java.io.FileInputStream;
4 import java.text.DecimalFormat;
5 import java.text.SimpleDateFormat;
6 import java.util.Calendar;
7 import java.util.Date;
8 import java.util.Properties;
9 import java.util.TimeZone;
10 import nmea.server.ctx.NMEAContext;
11 import nmea.server.ctx.NMEADataCache;
12 import ocss.nmea.parser.Angle360;
13 import ocss.nmea.parser.GeoPos;
14 import ocss.nmea.parser.Speed;
15 import ocss.nmea.parser.UTCDate;
16 import olivsoftdesktop.DesktopUserExitInterface;
17 import olivsoftdesktopuserexits.emailutil.EmailSender;
18
19 public class DesktopEmailSender
20 implements DesktopUserExitInterface
21 {
22 private final static SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MMM-dd HH:mm:ss");
23 private final static DecimalFormat DF22 = new DecimalFormat("##0.00 'kts'");
24 private final static DecimalFormat DF30 = new DecimalFormat("##0'\272'");
25 private static String SEND_PROVIDER = "google";
26 private Thread watcher = null;
27 private boolean keepWatching = true;
28 private EmailSender sender = null;
29
30 private double windThreshold = -1;
31 private long betweenLoops = 600 * 1000L; // 10 minutes default
32
33 public DesktopEmailSender()
34 {
35 super();
36 }
37
38 @Override
39 public void start()
40 {
41 System.out.println("Method 'start':" + this.getClass().getName() + " User exit is starting...");
42 Properties props = new Properties();
43 String propFile = "email.properties";
44 try
45 {
46 FileInputStream fis = new FileInputStream(propFile);
47 props.load(fis);
48 }
49 catch (Exception e)
50 {
51 System.err.println("email.properies file problem..., from " + System.getProperty("user.dir"));
52 throw new RuntimeException("File not found:email.properies");
53 }
54 SEND_PROVIDER = props.getProperty("ue.preferred.provider", SEND_PROVIDER);
55 sender = new EmailSender(SEND_PROVIDER);
56 try
57 {
58 windThreshold = Double.parseDouble(props.getProperty("ue.wind.threshold"));
59 System.out.println("Will send emails when the wind is above [" + windThreshold + "]");
60 }
61 catch (NumberFormatException nfe)
62 {
63 throw new RuntimeException("Bad wind threshold:" + props.getProperty("ue.wind.threshold"));
64 }
65 try
66 {
67 betweenLoops = Long.parseLong(props.getProperty("ue.between.loops.in.minute"));
68 }
69 catch (NumberFormatException nfe)
70 {
71 throw new RuntimeException("Bad Loop interval:" + props.getProperty("ue.between.loops.in.minute"));
72 }
73 final long _betweenLoops = betweenLoops;
74 watcher = new Thread()
75 {
76 private boolean started = false;
77 private final long BETWEEN_LOOPS = _betweenLoops * 60 * 1000;
78 private final long TEN_SECONDS = 10000L;
79 private long waitTime = BETWEEN_LOOPS;
80 public void run()
81 {
82 while (keepWatching)
83 {
84 waitTime = BETWEEN_LOOPS;
85 NMEADataCache dc = NMEAContext.getInstance().getCache();
86 try
87 {
88 double tws = ((Speed) dc.get(NMEADataCache.TWS)).getValue();
89 double twd = ((Angle360) dc.get(NMEADataCache.TWD)).getValue();
90 String date = "";
91 UTCDate utcDate = (UTCDate)NMEAContext.getInstance().getCache().get(NMEADataCache.GPS_DATE_TIME);
92 if (utcDate != null && utcDate.getValue() != null)
93 {
94 Date d = utcDate.getValue();
95 Calendar cal = Calendar.getInstance();
96 cal.setTime(d);
97 cal.setTimeZone(TimeZone.getTimeZone("Etc/UTC"));
98 date = SDF.format(cal.getTime());
99 }
100 String pos = "";
101 try { pos = ((GeoPos)dc.get(NMEADataCache.POSITION)).toString(); } catch (Exception ex) {}
102 if (!started)
103 {
104 started = true;
105 System.out.println(" -- User exit started for good.");
106 }
107 if (tws > windThreshold && !Double.isInfinite(tws))
108 {
109 String alertMessage =
110 (date.trim().length() > 0 ? "Date:" + date + "\n": "") +
111 (pos.trim().length() > 0 ? "Pos:" + pos + "\n" : "") +
112 "Wind is over " + DF22.format(windThreshold) + ":" + DF22.format(tws) + ", TWD:" + DF30.format(twd);
113 System.out.println(alertMessage);
114 // Send an email...
115 try
116 {
117 sender.send(alertMessage);
118 System.out.println("Email sent.");
119 }
120 catch (Exception ex)
121 {
122 System.err.println("Sending email failed through [" + SEND_PROVIDER + "]");
123 ex.printStackTrace();
124 }
125 }
126 }
127 catch (NullPointerException npe)
128 {
129 // Just wait til next time...
130 System.out.println("Cache not initialized (yet)");
131 waitTime = TEN_SECONDS;
132 }
133 synchronized (this)
134 {
135 System.out.println(" ...User exit going to wait, at " + new Date().toString() + " (will wait for " + (waitTime / 1000) + " s)");
136 try { wait(waitTime); }
137 catch (InterruptedException ie)
138 {
139 System.out.println("Told to stop!");
140 keepWatching = false;
141 }
142 }
143 }
144 System.out.println("Stop waiting.");
145 }
146 };
147 keepWatching = true;
148 watcher.start();
149 }
150
151 @Override
152 public void stop()
153 {
154 System.out.println(this.getClass().getName() + " is terminating");
155 keepWatching = false;
156 synchronized (watcher)
157 {
158 watcher.notify();
159 }
160 }
161
162 @Override
163 public void describe()
164 {
165 System.out.println("Polls the NMEA Cache on a regular base, and sends an email if the TWS is above a given threshold.");
166 System.out.println("Driven by a properties file named email.properties, in the all-scripts directory.");
167 }
168 }
Possibilities are endless. The limit is your imagination.
Combining the two examples above, you can as well gather all the data into a single document (XML, json, etc), and send it through email on a regular base, so it can be rendered by the receipient.
Etc, etc...
How to do it for yourself, step by step
- Download all the sources, in the zip mentionned above
- Extract it is a new clean directory
- Make sure the jar
mail.jaris in yourall-3rd-partydirectory - Make sure you have installed a JDK in your environment
- In a system console, navigate to the directory where you unzipped the sources
- If it does not exist, create a
classesdirectory. Make sure it is empty -
Compile the code:
On WindowsOn LinuxPrompt> set OLIV_HOME=D:\OlivSoft Prompt> set CP=%OLIV_HOME%\all-3rd-party\mail.jar Prompt> set CP=%CP%;%OLIV_HOME%\all-libs\nmeaparser.jar Prompt> set CP=%CP%;%OLIV_HOME%\all-libs\nmeareader.jar Prompt> set CP=%CP%;%OLIV_HOME%\all-libs\desktop.jar Prompt> set CP=%CP%;%OLIV_HOME%\all-libs\geomutil.jar Prompt> javac -d classes -sourcepath src -cp %CP% src\olivsoftdesktopuserexits\*.javaMake sure you do not see any error.Prompt> bash Prompt> OLIV_HOME=/usr/OlivSoft Prompt> CP=$OLIV_HOME/all-3rd-party/mail.jar Prompt> CP=$CP:$OLIV_HOME/all-libs/nmeaparser.jar Prompt> CP=$CP:$OLIV_HOME/all-libs/nmeareader.jar Prompt> CP=$CP:$OLIV_HOME/all-libs/desktop.jar Prompt> CP=$CP:$OLIV_HOME/all-libs/geomutil.jar Prompt> javac -d classes -sourcepath src -cp $CP src/olivsoftdesktopuserexits/*.java -
Archive the generated classes:
On WindowsOn LinuxPrompt> cd classes Prompt> jar -cvf ..\emailUserExit.jar *Prompt> cd classes Prompt> jar -cvf ../emailUserExit.jar * -
Copy the archive in the
all-user-exitsdirectory
On WindowsOn LinuxPrompt> cd .. Prompt> copy *.jar %OLIV_HOME%\all-user-exitsCopyPrompt> cd .. Prompt> cp *.jar $OLIV_HOME/all-user-exitsemail.propertiesin theall-scriptsdirectory
On WindowsOn LinuxPrompt> copy email.properties %OLIV_HOME%\all-scriptsYou are almost done...Prompt> cp email.properties $OLIV_HOME/all-scripts -
Modify the line that starts the console, so it takes your work in account:
On WindowsOn Linuxset COMMAND=java %JAVA_OPTIONS% -classpath %CP% olivsoftdesktop.OlivSoftDesktop %HEADLESS_OPTIONS% -ue:olivsoftdesktopuserexits.DesktopEmailSender start "Headless Console (User-Exit)" %COMMAND%That's it!java $JAVA_OPTIONS -classpath $CP olivsoftdesktop.OlivSoftDesktop $HEADLESS_OPTIONS -ue:olivsoftdesktopuserexits.DesktopEmailSender &
Important: Do not forget to edit and modifyemail.properties, so it matches your environment, and your needs.
Labels:
console,
Navigatrix,
NMEA,
OlivSoft,
Raspberry Pi,
UserExit
Monday, November 18, 2013
Multiple Access, for real
Now we've setup the ad-hoc network from the Raspberry PI reading the NMEA Data, we can simultaneously access the data, from several devices connected on the ad-hoc network defined on the boat, from the Raspberry PI itself:
A small glitch I need to address: Android does not want to connect to an ad-hoc network. I need to fix that, more to come soon.
Swing Console from a laptop
OpenCPN from a laptop
HTML Console from a laptop
HTML Console from an iPad
HTML Console from an iPhone
All the pictures above were taken with all the programs on the devices running simultaneously.
A small glitch I need to address: Android does not want to connect to an ad-hoc network. I need to fix that, more to come soon.
Saturday, November 9, 2013
NMEA with Raspberry PI: All Good!
The last step - after this one - was not as straight forward. But finally, everything works fine.
The idea was to use PI4J to read the serial port (
But as reading a USB port (
The NMEA Console and OpenCPN can use TCP to get the data, The html5 Console uses HTML..., everything goes seamlessly. For less than 700mA. And around $50.
We will detail later all the steps to go through to get this done anywhere. This is just an easy check list.
And we'll built a nice box to host all this. The Raspberry, an optional small screen, and possibly a small keyboard.
More soon.
And just to give you a taste of what will come next,node.js works like a charm on the Raspberry PI, and the WebSocket protocol works as if it had been designed for this platform... That is going to seriously rock.
The main points this project addresses:
So, here is the story:
The SD card containing the OS of the PI needs to be 4Gb big, minimal recommended. Mine is 8, and it can go beyond 32. This allows DAYS of logging.
Now, when a device from the boat wants to see what's going on (i.e. visualize the data), it connects to the boat's ad-hoc network. Then, depending on its possibilities and needs, it can use the NMEA Console (that one can read any channel for its data input), or the HTML5 Console (at the bottom of this page).
The chart plotting program (like OpenCPN) can use the exact same data stream.
And when you're done watching your device, you can turn it off, hibernate it, what not, the RaspPi keeps reading and broadcasting.
The RaspPi does not take more than 700mA.
And it costs less than $50.
The RaspPi does not need any keyboard or screen. (I use SSH from a laptop to start the reading program on it).
The main points are:
I was very interested during the recent America's Cup, to see all the crews watching several kind of devices..., many had those displays on their fore-arms, tacticians had some iPad-like devices, fasten on their bellies with some shock-cords and velcro..., it kind of rang a bell! Those boats had for sure way more sensors that just an NMEA station (up to 3000 sensors for Oracle, I heard), but I believe that there is already a LOT to do with the data you can get from a regular NMEA station.
Once the ad-hoc network is setup, the crew members can even use their smart phone to access it, and visualize the HTML5 Console. That actually enhances one point: All the technology is here - nothing has been built or invented specially for this project. It's all about getting access to it with existing devices and techniques. Everyone (including me!) now has a smartphone, Linux has been around for ages, NMEA is one of the (if not THE) oldest standards in IT... And again, a small device you can get for less that $50 makes it all possible!
I like that.
The idea was to use PI4J to read the serial port (
/dev/ttyAMA0). All the tests I made with PI4J were all very positive, but apparently, there is a bug when the baud rate is 4800. And unfortunately, this is the one we need.
But as reading a USB port (
/dev/ttyUSB0) was not a problem, a simple adapter (serial 9 pin to USB) fixed everything. And on Linux (Raspberry PI runs Linux, a tweaked version of Debian), no driver or any such thing is required. Plug it in, and boom! It works.
The Raspberry PI reads the serial port with the headless console, and rebroadcasts everything appropriately.
The NMEA Console and OpenCPN can use TCP to get the data, The html5 Console uses HTML..., everything goes seamlessly. For less than 700mA. And around $50.
We will detail later all the steps to go through to get this done anywhere. This is just an easy check list.
And we'll built a nice box to host all this. The Raspberry, an optional small screen, and possibly a small keyboard.
More soon.
And just to give you a taste of what will come next,node.js works like a charm on the Raspberry PI, and the WebSocket protocol works as if it had been designed for this platform... That is going to seriously rock.
To summarize
This project goes along with the NMEA console, found here.The main points this project addresses:
- Serial ports (most of the data we're interested in come through a serial port) are accessed exclusively. Only one program at a time can access the data. I had the problem on the ketch, when the cartography soft was accessing the data port (to plot the boat on the chart), the console (the one evaluating current and performances) had to wait.
- The laptop you can use to read the data draws a substantial amount of electricity (around 10W is not unusual).
- Several devices on the boat (tactician, driver, navigator, trimmers) might need to have simultaneous access to the data, and they might need to be already processed and smoothed (damped)
So, here is the story:
- The Raspberry PI creates its own ad-hoc network when it boots, and you start on it a utility that reads the data from the serial (or whatever) port connected to the NMEA station
- The data are read, and stored on the raspberry in some cache (a hashmap).
- The data are logged (optional), and processed (true wind is calculated, current is evaluated, VMG - on the wind or on the mark, performance, are evaluated). Those data are cached as well. Those calculations require some parameters to be set (max leeway, deviation curves, polars of the boat, some coefficients for the instruments, etc), they are available on the Raspberry PI.
- The data rebroadcasted on TCP, UDP, and HTML (also possibly RMI; I dropped GPSd). You can select one or more of those channels for rebroadcasting.
The SD card containing the OS of the PI needs to be 4Gb big, minimal recommended. Mine is 8, and it can go beyond 32. This allows DAYS of logging.
Now, when a device from the boat wants to see what's going on (i.e. visualize the data), it connects to the boat's ad-hoc network. Then, depending on its possibilities and needs, it can use the NMEA Console (that one can read any channel for its data input), or the HTML5 Console (at the bottom of this page).
The chart plotting program (like OpenCPN) can use the exact same data stream.
And when you're done watching your device, you can turn it off, hibernate it, what not, the RaspPi keeps reading and broadcasting.
The RaspPi does not take more than 700mA.
And it costs less than $50.
The RaspPi does not need any keyboard or screen. (I use SSH from a laptop to start the reading program on it).
The main points are:
- Low consumption (and low price, if it makes any sense in this context)
- Data rebroadcasting
-
Logging (ages of logging).
I log VWR, RMC, MWV, RMB, VHW, VLW, HDG, MTW and GLL. It's about 1 Mb per hour.
One day would be 24 Mb. One week around 168 Mb. Peanuts.
I was very interested during the recent America's Cup, to see all the crews watching several kind of devices..., many had those displays on their fore-arms, tacticians had some iPad-like devices, fasten on their bellies with some shock-cords and velcro..., it kind of rang a bell! Those boats had for sure way more sensors that just an NMEA station (up to 3000 sensors for Oracle, I heard), but I believe that there is already a LOT to do with the data you can get from a regular NMEA station.
Once the ad-hoc network is setup, the crew members can even use their smart phone to access it, and visualize the HTML5 Console. That actually enhances one point: All the technology is here - nothing has been built or invented specially for this project. It's all about getting access to it with existing devices and techniques. Everyone (including me!) now has a smartphone, Linux has been around for ages, NMEA is one of the (if not THE) oldest standards in IT... And again, a small device you can get for less that $50 makes it all possible!
I like that.
Subscribe to:
Posts (Atom)



























