Sunday, November 29, 2015

HowTo: Verify My NTP Working Or Not

http://www.cyberciti.biz/faq/linux-unix-bsd-is-ntp-client-working/

HowTo: Verify My NTP Working Or Not

by VIVEK GITEon MARCH 25, 2010 last updated NOVEMBER 29, 2015

in LINUXNETWORKINGUNIX

I've setup an NTP (Network Time Protocol) client and/or server to manage the system clock over a network. But, how do I verify that it is working correctly?

You can use any one of the following program to verify ntp client configuration:

ntpq - standard NTP query programntpstat - show network time synchronisation statustimedatectl - show or set info about ntp using systemd

ntpstat command

The ntpstat command will report the synchronisation state of the NTP daemon running on the local machine. If the local system is found to be synchronised to a reference time source, ntpstat will report the approximate time accuracy.

exit status

You can use the exit status (return values) to verify its operations from a shell script or command line itself:

exit status 0 - Clock is synchronised.exit status 1 - Clock is not synchronised.exit status 2 - If clock state is indeterminant, for example if ntpd is not contactable.

Type the command as follows:
$ ntpstat
Sample outputs:

synchronised to NTP server (149.20.54.20) at stratum 3 time correct to within 42 ms polling server every 1024 s

Use the echo command to display exit status of ntp client:
$ echo $?
Sample outputs:

0

ntpq command

The ntpq utility program is used to monitor NTP daemon ntpd operations and determine performance. The program can be run either in interactive mode or controlled using command line arguments. Type the following command
$ ntpq -pn
OR
$ ntpq -p
Sample outputs:

remote refid st t when poll reach delay offset jitter ============================================================================== *dione.cbane.org 204.123.2.5 2 u 509 1024 377 51.661 -3.343 0.279 +ns1.your-site.c 132.236.56.252 3 u 899 1024 377 48.395 2.047 1.006 +ntp.yoinks.net 129.7.1.66 2 u 930 1024 377 0.693 1.035 0.241 LOCAL(0) .LOCL. 10 l 45 64 377 0.000 0.000 0.001

The above is an example of working ntp client. Where,

-p : Print a list of the peers known to the server as well as a summary of their state.-n : Output all host addresses in dotted-quad numeric format rather than converting to the canonical host names.

A note about timedatectl command

If you are using systemd based system, run the following command to check the service status
# timedatectl status
Sample outputs:

Fig.01: Is my NTP (systemd-timesyncd) Working?

systemd-timesyncd configuration

If NTP enabled is set to No. Try configuring by editing/etc/systemd/timesyncd.conf file as follows:
# vi /etc/systemd/timesyncd.conf
Append/edit [Time] as follows i.e. add time servers or change the provided ones, uncomment the relevant line and list their host name or IP separated by a space (default from my Debian 8.x server):

[Time] Servers=0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org

Save and close the file. Finally, start and enable it, run:
# timedatectl set-ntp true
# timedatectl status

Recommend readings:

man ntpq

TwitterFacebookGoogle+Download PDF version Found an error/typo on this page?

More like this:Debian / Ubuntu Linux Install NTPD To Synchronism Clock With Internet…What are the exit statuses of ssh command?Ubuntu Linux how to set the date and time via Network Time Protocol (NTP)Bourne Shell Exit Status ExamplesHP-UX UNIX Configure an NTP ServerShell: How to determine the exit status of Linux and UNIX commandCentOS / Red Hat Configure an NTP Client And ServerCentOS / Redhat Linux: Install OpenNTPD To Synchronize The Local ClockCentOS Linux Install and Configure NTP to Synchronize The System ClockBash: Find out the exit codes of all piped commands

{ 5 comments… add one }

Philippe Petrinko

Informative and simple. Thanks Vivek

REPLY LINK

Wes

You should fix this typo:

>> “exit status 1 – Cock is not synchronised.”

REPLY LINK

Nix Craft

Thanks for the heads up. The faq has been updated.

REPLY LINK

Philippe Petrinko

Hi Vivek,

Recommend readings link seems to be broken:

“man ntpq”
http://www.manpager.com/linux/man8/ntpq.8.html

I guess you may want to recommend:
http://linux.die.net/man/8/ntpd
https://en.wikipedia.org/wiki/Ntpd
http://www.eecis.udel.edu/~mills/ntp/html/ntpq.html
http://support.ntp.org/bin/view/Support/TroubleshootingNTP
https://en.wikipedia.org/wiki/Ntpd
http://www.unix.com/man-page/freebsd/8/ntpq/
http://www.kossboss.com/linux—maintaining-time-on-debian—datetime-and-ntp-client-and-server

REPLY LINK

Nix Craft

Hi Philippe,

The post has been updated. As always, I appreciate your feedback and time :)

REPLY LINK

Leave a Comment

Name *

Email *

Comment

   Tagged with: client configurationecho command,network time protocolntpntp daemonntp network,ntpdntpqntpq commandntpstatntpstat command,system clocksystemdtime accuracytime synchronisationEasy

Next FAQ: Linux / UNIX: Encrypt Backup Tape Using Tar & OpenSSL

Previous FAQ: Linux Kernel Recompile: Do I Have To Recompile All Installed Applications

Featured Articles:

30 Cool Open Source Software I Discovered in 201330 Handy Bash Shell Aliases For Linux / Unix / Mac OS XTop 30 Nmap Command Examples For Sys/Network Admins25 PHP Security Best Practices For Sys Admins20 Linux System Monitoring Tools Every SysAdmin Should Know20 Linux Server Hardening Security TipsLinux: 20 Iptables Examples For New SysAdminsTop 20 OpenSSH Server Best Security PracticesTop 20 Nginx WebServer Best Security Practices20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors15 Greatest Open Source Terminal Applications Of 2012My 10 UNIX Command Line MistakesTop 10 Open Source Web-Based Project Management SoftwareTop 5 Email Client For Linux, Mac OS X, and Windows UsersThe Novice Guide To Buying A Linux Laptop

Follow Us

©2000-2015 nixCraft. All rights reserved. Privacy -Terms of Service - Questions or Comments

Thursday, November 12, 2015

Kilopass announces breakthrough memory technology for IoT devices

http://www.digitimes.com//supply_chain_window/story.asp?datepublish=2015/11/11&pages=PR&seq=200

Kilopass announces breakthrough memory technology for IoT devices

Press release [Wednesday 11 November 2015]

Kilopass Technology, Inc., the leading provider of semiconductor embedded non-volatile memory (eNVM) intellectual property (IP), will unveil at ARM TechCon its new eNVM, the X2Bit bitcell, delivering 10X power reduction compared to currently available eNVM technologies.

The patent-pending X2Bit bitcell has been silicon proven since Q2 2015, and its use in the macro-level Gusto product line will be optimized for extremely low-power Internet of Things (IoT) devices in Q1 2016.

Kilopass has pioneered the antifuse One-Time-Programmable (OTP) eNVM technologies since 2001, including all variants of 1 transistor (1T), 1.5T, 2T, 3T, and 3.5T versions. A new programming method for its most popular bitcell topology, the 2T bitcell, yielded the 10X improvement in lower power consumption.

"The X2Bit bitcell is a very exciting innovation, and somewhat unexpected in my long career in the non-volatile memory industry," remarks Harry Luan, Kilopass' chief technology officer. "The tenfold improvement is obviously important for the emerging IoT market. But to achieve it without having to change any bitcell architecture, topology, or layout means we can go right to the market and deliver the benefits to our licensees without years of field trial and validation. It's truly remarkable."

The X2Bit bitcell technology

The X2Bit bitcell retains the configuration of the existing bitcell in the current XPM, Gusto-2, and SecretCode OTP products. However, using a patented new programming method, the new bitcell achieves a much lower turn-on voltage, the voltage at which the "1" memory bitcell generates current to distinguish itself from the "0" bitcell. For example, in the 55nm technology, popular for IoT devices, traditional Kilopass OTP bitcells have a typical turn-on voltage of more than 1V. With the X2Bit bitcell, the turn-on voltage that is much lower than 1V. As a result, Kilopass products employing the X2Bit bitcell would operate with core voltage supplies as low as 0.75V that are used in the emerging Ultra-Low-Power (ULP) process technologies from semiconductor manufacturers.

"We are excited about the potential of the X2Bit bitcell memory bitcell," says Linh Hong, vice president of marketing at Kilopass. "The X2Bit bitcell technology is a quantum step forward in the development of antifuse NVM IP in the standard logic process. We believe it's the next natural step to deliver the relentless cost, power, performance and integration improvements the industry demands."

Implementation benefits

The X2Bit bitcell is ideally suited for next-generation IoT devices that demand less than 10uA/MHz in read currents. Currently available eNVM technologies typically consume 100uA/MHz under comparable operating conditions. The X2Bit bitcell lowers the turn-on voltage by optimizing the programming condition. This patent-pending implementation results in a more ohmic programming of the N-MOS transistor with controlled locality toward the source, drain region rather than in the middle of the channel.

Benefits are twofold. First, since power consumption is directly proportional to the square of operating voltage, lowering the read voltage by two-thirds would result in tenfold power reduction. Equally important, with lower turn-on voltage, the memory macro would be able to operate at the same operating voltage as the rest of the chip, without resorting to power consuming charge pumps and voltage regulators.

Availability

Kilopass has completed the mini-array test vehicle of the X2Bit bitcell in a 65nm manufacturing process technology. The first product, likely the next-generation Gusto, using the X2Bit bitcell will tape-out in Q1, 2016. Pricing is available upon request. For more information about taking advantage of the X2Bit bitcell, contact info@kilopass.com.

Kilopass at ARM TechCon

Kilopass will exhibit at ARM TechCon (Booth #827), demonstrating the X2Bit bitcell Wednesday, November 11, and Thursday, November 12, from 11 a.m. until 6:30 p.m. at the Santa Clara Convention Center, Santa Clara, Calif.

For more information, visit http://www.kilopass.com/ or email info@kilopass.com

The cause and cure for cancer

http://dailydigest.com/health/the-cure-for-cancer-otto-hanburg/2647

Thursday, October 29, 2015

How to measure differential signals

Ref: http://electronics.stackexchange.com/questions/76514/how-do-i-measure-differential-signals-like-rs-485-or-dmx-on-an-oscilloscope

How do I measure differential signals (like RS-485 or DMX) on an oscilloscope?

I've encountered differential signals in a few places, such as a differential output audio amplifier and now in a project working with DMX which is similar to RS-485. (Here's a similarquestion about RS-485.)

Looking at a waveform from a DMX lighting controller for example, I connected the channel 1 probe to D+, channel 2 probe to D-, and both ground leads to ground.

It produces this display:

While this is usable, I know it's still not the correct way to look at differential signals.

What is the correct way? I've heard of "differential probes;" does that mean I need to purchase new probes?


The reason you can't measure differential signals quite as easily with an oscilloscope has to do with the fact that oscilloscopes are (generally) notfloating. The ground lead on the probes are connected to the oscilloscope chassis, which in turn is earth grounded. Because of this, anything you connect the ground lead to will also be connected to earth ground. (As videos I link below demonstrate, this is dangerous if measuring high voltage!)

When you measure two random points with a multimeter, the meter is floating, so you're not connecting either point to actual earth ground, which lets you measure differences between points without concern that you're creating a short circuit.

In low voltage signal applications, tying one side of a differential signal to ground can cause problems and might damage a transceiver.

There are two ways to measure differential signals with an oscilloscope:

If you have a two-channel oscilloscope, connect one side of the signal to channel 1, and the complementary signal to channel 2. The ground leads stay unconnected.

Since you are interested in thedifference between the signals, you want to subtract channel 2 from channel 1. Most scopes provide a way to add or subtract channel 1 and channel 2 inputs. On some scopes you might have to add channel 2, but invert it so that you are effectively subtracting it.

In this image, the scope has an A-B mode which subtracts channel 2 from 1:

Differential Measurement Subtracting Second Channel

The other way is indeed using differential probes, and provides better results without reducing the number of usable channels on the oscilloscope. (And are usually designed for safer high-voltage measurements.) However these probes are expensive.

W2AEW does a superb job explaining these concepts in his video on differential measurements using oscilloscopes. There's also a video by BTC Instrumentation which shows the channel subtraction method in more detail.







Sunday, October 25, 2015

Urban Manufacturing Making a Difference

Ref: http://brandinsider.straitstimes.com/hitachi/urban-manufacturing-making-a-difference/

Urban Manufacturing: Making a Difference

An example of advanced manufacturing in Singapore: the Dyson advanced motor manufacturing facility with an annual production capacity of 11 million motors. The S$200 million investment in West Park Tuas, which opened in 2012, has more than 800 employees. Fifty robots and 22 components produce motors on the highly automated production line. Only 13 operators are needed to operate an entire line. In July this year, Dyson manufactured its 10 millionth digital motor. Photo: Dyson

Governments, developers see the economic and social values of urban manufacturing hubs that bring together design, creative technology and business talent.

By Martin L Dunn and Jeffrey Huang
The Business Times
Sponsored Content
October 13, 2015

IN April 2014, in the small prefecture of Aichi, Toyota City, a ‘model intelligent city’ called Toyota Ecoful Town opened to much fanfare. It was designed to be a place where the flow of traffic, human, goods, waste and resources would be monitored, managed and regulated, promising an urban life that would be more energy-efficient, less congested and better served.

Toshihiko Ota, the Mayor of Toyota City, noted that one aim was “to provide a single contact point, take responsibility to provide a site, and offer other support to proving experiments that promise to solve Toyota City’s problems and make our citizens’ lives happier.”

Toyota City’s Ecoful Town, also nicknamed “Mirai no Futsu” (Normal in the Future) can be seen as a harbinger of a first generation of smart cities that also include larger, international examples such as SongDo in South Korea, Rio in Brazil and Masdar City in the UAE. It was a generation of smart cities often sponsored by big tech companies and based on the idea of centralising big data captured for the “better good,” with regulated public welfare.

However, Smart City writer Adam Greenfield cautions about the much publicised Rio control room “that fuses data from weather stations, traffic cameras, police patrols, sewer-mounded sensors and social media postings into a synoptic, war-room style overview”.

While it epitomises this first smart city generation’s ambition, it also reveals its Achilles heels – that of being overly invasive.

In reaction to the fear of the city becoming an Orwellian big brother who incessantly monitors its the inhabitants and turning them into involuntary subjects for the big tech sponsors’ experiments, a few courageous citizens protested. They stood up and started a “bottom-up” movement as an alternative to the prevalent smart city focus.

Anthony Townshend, an early advocate, calls it the Smart Citizens movement. “Our goal is to shift the debate toward the central place of citizens, and of decentralised, open urban infrastructures”. Examples of the Smart Citizens movement, where city data are given to citizens and ethical hackers to develop their own applications, can be found in the USA, Europe and Asia.

In September, at the URA Centre in Singapore, Mr Ridwan Kamil, the young Mayor of Bandung, gave a rousing keynote speech on the design and management of Bandung. He advocated, as a counterpoint to the top-down smart city infrastructure, a series of “open government” initiatives to empower citizens. He explained that “empowerment and citizen activism was built into the system.” Free Wi-Fi access points and open data access encourage citizens to use the data; they have already built more than 300 apps.

Evolution

Urban manufacturing in New York City: US company Normal designs, manufactures, and sells personalised headphones from their trendy Manhattan store/factory, where customers can view their own headphones being manufactured by 3D printing. Photo: James Ewing/OTTO

Fast forward, and we see a third wave in the Smart City Saga, characterised by the shift from the digital to the physical, from the ‘cerebral informing’ to the ‘tangible making’.

This coincides with the evolution of manufacturing over the last 50 years. Manufacturing went through a process of transformation: from manual to skilled labour, to technology based, and now is on the precipice of an innovation-based manufacturing paradigm.

This includes big ideas in next-generation manufacturing based on highly-instrumented processes acquiring data in real time from machines, people and materials across the manufacturing enterprise. Examples include Industrie 4.0 in Germany and the Industrial Internet in the USA.

Basically, this move is enabling the manufacturing process to be more flexible and agile. The ultimate result is the ability to offer design differentiated higher-value products to market demands that are increasingly fragmented and customised.

While the industrial city of 1900s is likely gone forever, urban manufacturing is a logical convergence of the evolution of manufacturing and the smart city. It not only drives advancement, job creation and innovation but also the renewal and transformation of the city.

For example, post-industrial factories, warehouses and logistics facilities are being rejuvenated through contemporary urban manufacturing.

Maker movement

A particularly visible intersection of the urban and manufacturing trajectories is the maker movement that started in Silicon Valley. It has evolved worldwide with maker-spaces and fab labs popping up weekly that open previously inaccessible and often expensive tools of production to citizens.

Here, digital fabrication technologies like 3D printing, laser machining and robotics are integrated with design software that is often available in an open-source form. There is also an abundance of digital libraries of freely-available design files to provide a low entry barrier for makers to express their creative visions and turn them into new business opportunities.

While some may dismiss the maker movement as limited to do-it-yourself (DIY) hobbyists, there are growing signs that this is instead an important signal in a transformation in the way things are made. In the US, President Barack Obama went as far as to note that “Today’s DIY is tomorrow’s ‘Made in America’”.

His Advanced Manufacturing Initiative is creating new research institutes. This includes additive manufacturing, digital design and manufacturing, composites, photonics and advanced textiles.

In March 2014, President Obama inaugurated the Digital Design and Manufacturing Innovation Institute in Chicago, an example of an early urban manufacturing initiative. Chicago Mayor Rahm Emanuel proclaimed this “a game changer for the City of Chicago”. Governor Pat Quinn noted that “advanced manufacturing is a great way to grow jobs, retain jobs and to literally bring back jobs that have gone to foreign shores. If you want Made-in-America, this is the heart of that initiative because advanced manufacturing makes it much more feasible to do that manufacturing in your own backyard.”

Examples are emerging worldwide, driven in part by consumers who desire design-differentiated high-quality goods produced locally ranging from craft beers to apparel to creative tech. Local character is resulting in valuable branding both for the products and the city, and is attracting artisans, small and medium-sized companies. Even big companies are looking to new manufacturing technologies to build and share shorter and sustainable supply chains, and enable design-oriented mass customisation.

Hubs

Governments and developers see the economic and social values of urban manufacturing hubs that bring together design, creative technology and business talent. And they are placing bets. In cities around the world, areas that were once populated by decaying warehouses and factories are re-emerging as hip and trendy hubs anchored by local manufacturers. For example, Brooklyn NY is transforming through recent investments in excess of US$1 billion in manufacturing and technology infrastructure. Areas like the Tech Triangle, Industry City, Liberty View Industrial Plaza and the Brooklyn Navy Yard are hotbeds of local designers and manufacturers who are exploiting new design and fabrication technologies to innovate and grow the “Brooklyn brand”.

In San Francisco, space has been set aside for local manufacturers in places such as Pier 70 and the SF Giants baseball complex, and ground floors of apartment buildings, to accelerate the maker movement while increasing the value of real estate and making neighbourhoods more hip.

Particularly interesting is the emerging phenomenon of micro factories, like the innovative Local Motors in the USA.
The company boldly seeks to produce automobiles at a fraction of the cost and time required in the traditionally large capital-intensive industry. It is creating designs by crowd-sourcing and producing automobiles in small local factories based on local needs.

Recently, it has partnered General Electric to explore these innovative approaches for product design and manufacture broadly.

Interestingly, many emerging urban manufacturing hubs strive to achieve creativity, supply-chain agility and fast transition from design to production. In this regard, the manufacturing ecosystem of Prato, Italy, is an outstanding example, making it a powerhouse in high-value fashion and textile markets.

Singapore

In Singapore, urban manufacturing is especially promising and potentially impactful. The country already has the ideal ingredients: a rich knowledge base; cultural diversity with social harmony; sophisticated smart nation infrastructure; excellent logistics and supply chain, precision engineering and creative and technical design capabilities. These can help to shift manufacturing into innovation-based high value production; and help to maintain manufacturing at a healthy 20-25 percent of GDP, and build the ‘Made in Singapore’ brand.

The Singapore University of Technology and Design has launched the SUTD Digital Manufacturing and Design (DManD) Centre to contribute to such a vision. DManD is bringing together creative, technical, and business ideas in new ways to create innovation-driven advanced manufacturing paradigms and possibilities.

These will play a transformative role in the long-term evolution of manufacturing and provide the human capital that will help establish Singapore as a world leader in high-value digital manufacturing. DManD is pursuing innovations in design software, 3D and 4D printing and robotics to impact industry sectors that relate to the smart city of tomorrow. These include smart products ranging from wearable technology for fashion to healthcare, and design and fabrication approaches for building and construction.

It is an exciting time as urban manufacturing emerges in various forms as a central actor in the Smart City movement around the world. Such developments will be further enabled by smart city infrastructures and will ultimately impact the economic and social fabric of these cities.

In turn, it will influence the future of production and the citizens involved in production. Indeed this dynamic is a pathway to one aspect of self-building and renewal of cities – an imperative put forth by Jane Jacobs in her 1961 plea for what makes a city work.

Professor Martin L Dunn is the Associate Provost, Research SUTD and Professor Jeffrey Huang is the Head of Pillar, Architecture and Sustainable Design SUTD.

This is the fourth of a six-part series brought to you by Hitachi, in collaboration with the Lee Kuan Yew Centre for Innovative Cities (LKY CIC), SUTD. The next part of this series, Smart design on an aging population, will be published on Nov 17, 2015.

Monday, October 19, 2015

How to Watch Premier League NFL Live Sports Kodi 2015

Ref: https://seo-michael.co.uk/how-to-watch-premier-league-football-using-xbmc/


How to Watch Premier League NFL Live Sports Kodi 2015

The Best NFL, Football & Sports Add-Ons for Free on Kodi in 2015

Using the add-ons below you will be able to find plenty of other sports not just the Premier League. You will find that many of these add-ons also show live NFL games, Ice Hockey, Cricket and much more.
Some of these add-ons use Plexus so please install that first using this guide. As this uses P2P is it prudent to use a VPN (check out with the code **PREMIER2015 to save 15%

This page was originally a guide for watching Football on Kodi but now it encompasses add-ons that show all sports. It has become an extremely popular page especially on a Saturdays and Sundays when people are looking for alternatives to Sky Sports.
I will continually update this list. Feel free to bookmark the page and come back as and when you please to see what other add-ons have been added to the list.

MBOX - This is a paid add-on (the only paid add-on you will find on my site). It's the best paid service you will get and I can guarantee you will not be disappointed as you won't miss any football. Quote MJD if you contact them (no, I don't get paid)

Install NJM Soccer - Once installed click on the Matchday 2015 link

Use this guide to install DexterTV. Once installed select Live TV > Sports Channels. Some sections may require a US VPN. If you are looking for a high quality VPN then use IPVanish

Use this guide to install Jekyll-Hyde IPTV add-on and once installed look in:
Live TV > UK in there you should see the channels you need.
They also have a Live Sports section on the first page but that wasn't updated at the time of writing.

Follow my guide on installing the VdubT25 add-on. Once installed check the USA Sports section where you will find good HD channels

DIJ Entertainments - A great little add-on with links to SKy Sports and more

Use this guide to install Sports Devil. Once you have that installed open Live Sports.

Follow my guide to install Phoenix and then you can watch streams that Staael has found for you. When you have that installed you can choose from the following:
Staael > Live TV > Sport
or
Phoenix TV > Sports

Use this guide for installing the UK Turk Live Streams Add-On. Just select Sports to find a wide selection of channels.

Use this guide to install ZemTV. Once installed look in the Sports section. The PV2 Sports section has lots of good working channels

Use this guide to install .F.U.B.A.R. add-on. In there select IPTV > hac-sat. In there you will find ESPN, RAISPORT & others

Take a look at my guide on installing p2p streams. This is probably my favourite as it just works perfectly. This shows Sky Sports & BT Sports 1,2 & Europe as well as others.

Operation Robocop. With this add-on installed check the sections marked Bein Sports & SPORTS

Pak India - Check the Sport section

Dutch Cloud TV - Check the SPORTS section. There are plenty of channels to choose from for Eredivisie & Premier League football

Use this guide for installing Stream Engine as streams on there are well maintained and usually good quality. Look in LiveTV/Sport > Sport > .Stream Engine Sports

Halow TV has a good selection of sports channels to browse through. Use this guide to install the Halow LIVE add-on.

Use this guide to install the BBTS Live TV add-on. In there launch the SPORTSsection.

Use my guide to Install Navi-X and then come back to this page.
After installing Navi-X you want to open the Navi-X add-on and select the first box marked Navi-Xtreme Portal - Select Search - Select Search Navi-Xtreme - SelectNew Search - Type hammy - Select HAMMY 40

Check out my other Kodi posts; you'll find plenty to improve your Kodi experience

Between Now & Jan 6th 2016 there is an offer for 15% off any VPN deal using the promo code "PREMIER2015" from IPVanish. They offer a great service with a great selection of servers around the world that run at top speeds; a true tier 1 VPN solution. This stop sources from being blocked in Kodi and allows access to geo-restricted content from anywhere. Clients available for OS X, iOS, Android & Windows. 7 day money back guarantee too. OpenVPN option available.
Remember to Check Out with the Code PREMIER2015

Thursday, October 15, 2015

Share folder from Ubuntu hyper-v guest to Windows host

Ref: http://internetpanda.fi/en/2014/06/share-folder-from-ubuntu-12-04-hyper-v-guest-to-windows-host/

Share folder from ubuntu 12.04 hyper-v guest to Windows host

  1. Open home folder in GUI for the Ubuntu guest
  2. Add new folder
  3. Right click on folder and select “sharing options”
  4. Click “share this folder”
  5. Install the network sharing service (samba smbclient) when asked
  6. Install libpam-smbpass when asked
  7. Restart session when asked
  8. Select sharing options again for the folder
  9. Chcek the checkbox “share this folder”
  10. Check the checkbox “allow others to create and delete files in this folder”
  11. Check the checkbox “guest access”
  12. Click “create share”
  13. Add permissions when asked (nautilus)
  14. Open terminal
  15. Write “ifconfig” to get your IP address
  16. Connect to shared folder from Windows host by setting “\\IP-address\sharedfoldername” in Windows explorer, e.g. \\192.168.0.101\myfolder
Tips
  • Ubuntu firewall might block connections from Windows host, message like “Windows cannot access”. Do this to allow access in ufw “sudo ufw allow Samba”.

Wednesday, July 8, 2015

MQTT 101 – How to Get Started with the lightweight IoT Protocol

Ref: http://www.hivemq.com/how-to-get-started-with-mqtt/

MQTT 101 – How to Get Started with the lightweight IoT Protocol

Introduction

Everybody talks about the Internet of Things nowadays. Increasingly affordable micro controllers like Arduino and Raspberry Pi are enabling cheap devices that measure sensor data and send it over the internet. The goal of this post is to introduce the lightweight protocol MQTT and its capabilities to send data between devices and other systems and to demonstrate them by implementing two clients with Eclipse Paho.
The term Internet of Things was first used by Kevin Ashton in 2009 for interconnecting physical devices over the internet. The basic idea is very simple: Physical devices can exchange data between each other or being controlled by others. Examples of such devices would be a refrigerator, a car, a building or basically any other electronic device. One of the most common use cases is the collection, transmission, consolidation and displaying of sensor data. The results could be a web dashboard with the aggregated values or an alarm, when a threshold is exceeded.
The application scenarios are almost unlimited. Imagine your alarm clock would know that your train to work is 15 minutes late and adjust itself accordingly. Also your coffee maker is switched on automatically 15 minutes later to make you a hot cup of coffee before you leave for work. Sounds like the future ? All that is already possible today. Ericsson predicts that in 2020 50 billion devices are connected over the internet. The communication between the huge amount of devices is enabled by IPv6 and lightweight communication protocols like MQTT.

MQTT

MQTT was developed by Andy Stanford-Clark (IBM) and Arlen Nipper (Eurotech; now Cirrus Link) in 1999 for the monitoring of an oil pipeline through the desert. The goals were to have a protocol, which is bandwidth-efficient and uses little battery power, because the devices were connected via satellite link and this was extremely expensive at that time.
The protocol uses a publish/subscribe architecture in contrast to HTTP with its request/response paradigm. Publish/Subscribe is event-driven and enables messages to be pushed to clients. The central communication point is the MQTT broker, it is in charge of dispatching all messages between the senders and the rightful receivers. Each client that publishes a message to the broker, includes a topic into the message. The topic is the routing information for the broker. Each client that wants to receive messages subscribes to a certain topic and the broker delivers all messages with the matching topic to the client. Therefore the clients don’t have to know each other, they only communicate over the topic. This architecture enables highly scalable solutions without dependencies between the data producers and the data consumers.
MQTT Publish/Subscribe
MQTT Publish/Subscribe Architecture
The difference to HTTP is that a client doesn’t have to pull the information it needs, but the broker pushes the information to the client, in the case there is something new. Therefore each MQTT client has a permanently open TCP connection to the broker. If this connection is interrupted by any circumstances, the MQTT broker can buffer all messages and send them to the client when it is back online.
As mentioned before the central concept in MQTT to dispatch messages are topics. A topic is a simple string that can have more hierarchy levels, which are separated by a slash. A sample topic for sending temperature data of the living room could behouse/living-room/temperature. On one hand the client can subscribe to the exact topic or on the other hand use a wildcard. The subscription to house/+/temperature would result in all message send to the previously mention topic house/living-room/temperature as well as any topic with an arbitrary value in the place of living room, for example house/kitchen/temperature. The plus sign is a single level wild card and only allows arbitrary values for one hierarchy. If you need to subscribe to more than one level, for example to the entire subtree, there is also a multilevel wildcard (#). It allows to subscribe to all underlying hierarchy levels. For example house/# is subscribing to all topics beginning with house.

Eclipse Paho

Now with the concept of topics explained, it is time to jump right into the first implementation and to show how the publishing and subscribing can be done using source code. But first a quick introduction of Eclipse Paho, the MQTT implementation used in this example. It has been founded under the umbrella of the Eclipse Foundation at the beginning of 2012 with the goal to provide open IoT protocol implementations. The implementation of MQTT is the de-facto reference implementation and available in Java, C, C++, JavaScript, Lua, Python and soon also C#. The origin of most of the implementations is the codebase of IBM and Eurotech, who have used them in many internal projects in production.

Use Case

In order to make the subsequent code more understandable, we will use the transferring of sensor data from a temperature and brightness sensor to a control center over the internet as an example. The sensors will be connected to a Raspberry Pi, which acts as gateway to the MQTT broker, which resides in the cloud. On the other side is a second device, the control center, that also has an MQTT client and receives the data. Additionally we will implement a notification, which alerts the control center if the sensor is disconnected.
Use Case Communication Flow
Communication between the sensor client and the control center over MQTT

Implementation

First we will implement the sensor client, which is simulating a thermometer and a brightness sensor. It should send a current value every second to the MQTT broker. In this case we are using the HiveMQ public broker on the MQTT Dashboard. The first step is to create an instance of the MqttClient class.
As parameters for the constructor it is necessary to specify the URL of the broker (tcp://broker.mqttdashboard.com:1883) and also the client id. The latter is an unique identifier overall the broker. A good choice for the client id is the MAC address of the computer, because that is automatically unique. In the example -pub is added to the mac address, because otherwise it wouldn’t work starting both clients on the same machine for testing. After creating the instance, it is possible to try to connect to the broker with calling client.connect(). Apart from a simple connect, it is also possible to hand over more parameters. One example is the clean session flag. When it is set to true, the broker will wipe the session every time the client disconnects, otherwise it will keep the subscription and buffer the messages sent with Quality of Service 1 and 2 (more on this later). The session is assigned to the client id, therefore it is truly important to have it unique. Another option is Last Will and Testament (LWT), which helps detecting failures of other clients. As stated above every client has an open connection, so when the client disconnects ungracefully the broker can detect that. If the client has set a LWT topic and message on connect, the broker will send that to the specified topic, which allows the client to notify others about its failure.
Now we have to implement the business logic to retrieve the values and send them every second, therefore we use an infinite loop and the methods publishTemperature and publishBrightness. Each method creates a MqttTopic object and a random value, which will then be published. The complete examples of both clients can be found on GitHub.
Each message can be published with one of three quality of service levels (QoS). These levels are associated with different guarantees. A message send with level 0 doesn’t have a guarantee at all, it implies fire and forget. Level 1 guarantees that the message will at least arrive once, but can arrive more than once. Level 2 is the most sophisticated choice, which guarantees that the message arrives at the destination exactly once. The choice of QoS is a trade-off, between protocol overhead and the guarantee that the message arrives, because ensuring QoS 2 is using more bandwidth than QoS 0.
The next step is implementing the subscribing client, which is reading the values on the topics home/temperature and “home/brightness”, plus observes the home/LWT topic for the last will message to detect a failure of the sensor client. The initialization of the MqttClient instance is almost the same, except we use -sub as a suffix for the client id. For receiving the messages sent by the sensor simulator, it is necessary to implement the MqttCallback interface. The MqttCallback interface defines three methods that need to implemented: connectionLost, messageArrived and deliveryComplete. connectionLost is called when the connection is unexpectedly closed form the MQTT broker. This method is the best place for a reconnect logic. The method messageArrived is called when the broker sends a new message to this particular client. Finally, there is the deliveryComplete method that is called after a message with QoS 1 or 2 reaches the broker. For our use case implementing the messageArrived method is enough. All arriving messages should be print out with topic and payload and if it is sent on the home/LWT topic, we additionally print out Sensor gone!.
After implementing the callback, we have to make it known to the MqttClient before connecting. Also after the successful connection is established, it is necessary to subscribe to all topics, which should be sent to the client. In this case it should be everything that starts with home, so the usage of a multi-level wildcard saves us from subscribing to 3 different topicshome/#.

Run both clients

Now that the sensor client and the Control Center are implemented, it is time to run both applications. We start the Control Center first and then the sensor client. Once the sensor client starts, messages arrive at the Control Center. If you will now exit the sensor client ungracefully, this is recognized by the Control Center immediately through the Last Will and Testament message.
Congratulations, you have now build your first Internet of Things application with MQTT!

Summary

This simple application is just an example and can be easily adapted and reused for more advanced purposes. You could simply extend the existing code so that multiple clients in different rooms measure the temperature and brightness, and the Control Center also indicates that. Another possibility would be to replace the Control Center through a web dashboard where the values are displayed in several charts using the Paho JavaScript library.
As we have seen, it is possible with very little effort to create application that communicates over MQTT. The Eclipse Paho library implements all the functionality that is described in the MQTT specification and MQTT should be a tool in the repertoire of every developer, who deals with the Internet of Things or the requirement of connecting mobile devices.