Author Archives: foreglance

Flutter – Android and iOS mobile applications framework

Flutter is created by Google as a framework for development of Android and iOS mobile (and desktop) applications with the same code-base (GitHub repository, install Flutter). It lets using Material Design and Cupertino (iOS-flavor) widgets with native performance. Flutter is free and open source, it is already used by Google, Alibaba and other companies and developers.

Flutter uses Dart as a programming language. Dart is created by Google as well, it is also open source (GitHub repository). Read more about Dart.

Continue reading

Dart programming language and frameworks with it

Dart is an Open Source programming language (GitHub repository), created by Google. It is used in some of Google applications (e.g. AdWords). Google also created:

  • SDK – includs the VM, dart2js, core libraries, and more
  • Flutter – for mobile application development
  • AngularDart – for web application development
  • Dart tools – IDE plugins, server script tools, and more

Continue reading

CPU-CPU-MCU…

I bought a cheap notebook in 2008 with an Intel Celeron processor. It served to my home-baked software development pet-projects during three years. Then I bought on E-bay for few dollars couple of Intel Dual Core CPUs to upgrade the notebook. I did not notice significant performance, but it warmed my heart with budged upgrade price.

This notebook serves now only as a Skype workstation, even though it straggles with its performance. Recently I found those CPUs in my drawer and made a little memorial to those CPUs efforts, with adding an Atmel Atmega 16 8-bit MCU (which I use in my DIY projects):

Amazon Alexa functionality on Raspberry Pi

Alexa (wiki) is Amazon’s cloud-based voice service available on number of devices. It provides a natural voice experiences for interaction, playing music and other options. There are devices, produced by Amazon, as well, as supported by other vendors.

There is an Alexa Skill Kit to create custom products, based on the Amazon Alexa services. It is also available API and SDKs to integrate Alexa into own connected products.

This article walks through one of such option – to build own device, connected to Amazon Alexa, using Raspberry Pi single board PC.

Different projects

Following options require an powered speaker and a USB microphone. It is recommended to use Raspberry Pi3, however Raspberry Pi2 should work as well.

  • An option on Python github.com/devicehive/AlexaDevice – “the project allows to launch Alexa on any Linux devices, even on embedded devices like Raspberry Pi (with usb headset)”. A guideline to set it up.
  • An option on Python github.com/alexa-pi/AlexaPi “a client for Amazon’s Alexa service. It is intended and tested to run on a wide range of platforms, such as Raspberry Pi, Orange Pi, CHIP and ordinary Linux or Windows desktops“. A guideline to set it up.
  • An option github.com/alexa/alexa-avs-sample-app/wiki/Raspberry-Pi – the project provides step-by-step instructions for setting up Alexa Voice Service (AVS) on a Raspberry Pi and using wake word engines from Sensory or KITT.AI”. Discontinued – authors has put their project “into maintenance mode. To leverage the latest Alexa features, please use the AVS Device SDK C++ Sample App
  • An option, used in this article – github.com/alexa/avs-device-sdk , mentioned earlier as “AVS Device SDK C++ Sample App”.

AVS Device SDK C++ Sample App

Prepare Raspberry Pi

sudo apt-get update
sudo apt install xfce4 xfce4-goodies tightvncserver
vncserver
In case errors, related locale
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
 LANGUAGE = (unset),
 LC_ALL = (unset),
 LC_CTYPE = "UTF-8",
 LANG = "en_GB.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_GB.UTF-8").

Fix locale

sudo locale-gen "en_US.UTF-8"
sudo dpkg-reconfigure locales

Resize the CF card

Run a command resize2fs as shown below. “/dev/sda2” is a volume name of the CF card, which can be found with a command lsblk

resize2fs -p /dev/sda2

Another option (only in GUI mode) is to use a graphics tool for disk, volumes and partition management: GParted

sudo apt-get install gparted
sudo gparted

Follow the guideline Raspberry Pi Quick Start Guide with Script – step-by-step instructions to set up the Alexa Voice Service (AVS) Device SDK on a Raspberry Pi.

Issues within a step, when starting startsample.sh

 

...
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'defaults.bluealsa.device'
...
#####################################
#       Client not connected!       #
#####################################
...
Failed to initialize SampleApplication
...
Failed to create to SampleApplication!

Solutions from Alsa lib conf issue #105

1. Not connected USB microphone

  • Check out this guideline of follow the next brief instruction
  • Check available recording devices
arecord -l

If the respond is as following – there is no recording devices available

**** List of CAPTURE Hardware Devices ****
  • Connect a USB microphone or a USB headset to the Raspberry Pi and check again. Example of a connected UCS headset
**** List of CAPTURE Hardware Devices ****
card 1: LX3000 [Microsoft LifeChat LX-3000], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Set the USB audio device as default

pri-connected-usb-headset-gui

  • Try to record audio and play it back – the command records audio from the default recording device to the specified file during 10 seconds
arecord -d 10 test-mic.wav
  • It might be an error related to not supported format
Recording WAVE 'test-mic.wav' : Unsigned 8 bit, Rate 8000 Hz, Mono
arecord: set_params:1299: Sample format non available
Available formats:
- S16_LE
  • Specifying the format will lett make record – example
arecord -f S16_LE -d 10 test-mic.wav

However this may lead to the other issues. So follow the further steps to change the ~/.asoundrc

  • Check available asound cards
    cat /proc/asound/cards

    available-asound-cards

    Check which one is selected as current for playback and for capture. In this example: “ALSA” is a card #0, it is used for playback, “USB-Audio – Microsoft LifeChat LX-3000” is a card #1, it is used for capture. So the file ~/.asoundrc should be like following

pcm.!default {
  type asym
   playback.pcm {
     type plug
     slave.pcm "hw:0,0"
   }
   capture.pcm {
     type plug
     slave.pcm "hw:1,0"
   }
}
  • If file has been created – check it, replaying it with the command
aplay test-mic.wav
  • Note: changes of the default (or current) audio in the GUI will change this file ~/.asoundrc

2. Not licensed Sensory engine

Is the Sensory library you are using licensed? If not, there is a script in the Sensory project you downloaded from Github under bin/license.sh that you can use to license to the project. You may not may not have to re-link the Sensory library.

cd FOLDER-WHERE-ALEXARPI-HAS-BEEN-DOWNLOADED
./third-party/alexa-rpi/bin/license.sh

If everything has been setup well – there will be following information and a option’s info displayed (i+Enter – shows this option’s info).

rpi-alexapi-sample-started

Press “q” (end “Enter”) to quit the sample.

There are some advises in the troubleshooting guide. One of them – to test the issue “No audio output from the SDK“. To do the testing – install GStreamer

sudo apt-get install libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-doc gstreamer1.0-tools

 

Useful resources:

Microservices – short reference

Microservices

In contrast to the monolithic applications, microservices approach split business functionality to independent external parts, implemented with individual services (from few to hundreds).

Following aspects are essential for implementation of microservices:

  • API Gateway
  • API Management
  • Monitoring
  • Logging
  • Service registry and discovery
  • Database separation and synchronisation (MDM – Master Data Management)
  • Service balancing
  • Messaging
  • Data transfer format
  • Protocols
  • Versionning
  • Automatisation of deployment
  • Caching

Continue reading

Setup C++ IDE CLion on Raspberry Pi with Ubuntu Mate

CLion is a crossplatform IDE for C++ made by JetBrains. CLion is not free but it is really helpful – with all its intentions, hints and refactorings. CLion has 30 days free trial license. Find out more on video introductions.

Eclipse is a free alternative but with less automation, assistance and features (this article describes the installation of Eclipse on Ubuntu).

Known issues on Raspberry Pi with Ubuntu Mate

  • Debugging does not work – because of not supported GDB version
  • On basic “Hello world” example there are issues with running the code – one of native terminal libraries fails. Compiled executable works fine. More complex example also works.

Continue reading

Program remotely on Raspberry Pi

Major advantage of such tiny computers as Raspberry Pi (RPi) is ability to work on small autonomous platforms like mobile robots. However computer, moving with a robot, is a challenge as well – during development it is not easy to change the code. Remote connection to the computer via SSH or VNC, using Wi-Fi, might help in such cases.

Continue reading

Install FTDI driver for USB-to-serial-port adapter or Arduino board

Some USB-to-serial port adapters and Arduino board (or its clones) with FTDI chips are not recognized by the operation system automatically.

For example when Arduino board is connected to the computer, menu Tools of the Arduino IDE has its Port menu item disabled – when the FTDI driver is not properly recognized.

Install-FTDI-driver-for-usb-to-serial-port-adapter-or-arduino-01_1

This article shows how to install FTDI drivers.

Continue reading