Control GPIO using the new Linux user space GPIO API

From the version 4.8, the Linux kernel introduces a new user space API based on character devices for managing and controlling GPIOs ( General-Purpose Input/Output). This post presents the basic of the new interface as well as a simple tutorial/example to demonstrate how to use the new API to control GPIOs.

The hardware used in the tutorial is the Raspberry Pi 3B but the code is generic and can be used on any embedded hardware.

26/06/2020 docker, AntOS, image, container, API

Running your own AntOS VDE system using a Docker image

Update: The image is now available on Docker Hub at: https://hub.docker.com/r/xsangle/antosaio (image: xsangle/antosaio:latest). This post has been updated with the latest instructions on how to host a local instance of AntOS VDE using Docker.

Building and setting up AntOS from scratch can be complex, as it requires configuring and connecting many backend and front-end components. To simplify the use of AntOS as a self-hosted environment, I have created a Docker image layer for an all-in-one AntOS system that contains everything needed to host AntOS on your server. This layer allows you to build a minimal Docker image with a working AntOS system out-of-the-box:

  • The web server (HTTP/HTTPS depending on the server configuration) + plugins
  • AntOS server-side API
  • AntOS client-side API

The Docker images are available at: https://hub.docker.com/r/xsangle/antosaio/

How does it work?

Follow the steps below to create an AntOS instance. First, create the working directory (e.g., /tmp/antos). All user data will be stored in this location. In this example, we use /tmp/antos, but in a real scenario, you should use a permanent storage location.

# modify with your own working directory
mkdir -p /tmp/antos

Run a container with docker

docker run \
    -p 8080:80 \
    --rm \
    -v /tmp/antos:/app \
    -e ANTOS_USER=demo \
    -e ANTOS_PASSWORD=demo \
    -it xsangle/antosaio:latest

Or with docker compose: docker-compose.yml

version: '3.7'
services:
  antos:
    image: xsangle/antosaio:latest
    privileged: true
    restart: always
    ports:
      - 8080:80
    container_name: antos_demo
    deploy:
      resources:
        limits:
          memory: 200m
          cpus: '0.5'
    hostname: demo
    environment:
      - ANTOS_USER=demo
      - ANTOS_PASSWORD=demo
    volumes:
      - /tmp/antos/:/app

Run:

docker compose up

AntOS is now accessible via http://localhost:8080/os/ or using IP address http://YOUR_MACHINE_IP:8080/os/

Conclusion

The docker image provides user with a ready to go (out-of-the-box) AntOS VDE system. This is useful in many user-cases:

  • Quickly setup environment for AntOS applications development
  • Scalable multi-user cloud-base service with AntOS and Kubenetes. Alternative to Ownclod, Google Cloud, Dropbox etc, with a more intuitive and user-friendly GUI, and more applications

How to list supported ciphers suites of a server?

I run into a problem of how to check whether my SSL ciphers suites configuration works correctly on my server.
Basically, with openssl, client can verify if the server supports a particular cipher suite using the following command:

openssl s_client -cipher "$cipher" -CAfile ca/ca.crt -connect server:port
# $cipher is the cipher suite name

So it is possible to automatically test all cipher suites supported by openssl against the server using a simple snippet of Bash, i found such script in this site https://superuser.com/questions/109213/how-do-i-list-the-ssl-tls-cipher-suites-a-particular-website-offers and modify it a little bit. Below is the script:

#!/usr/bin/env bash

# OpenSSL requires the port number.
SERVER=$1
DELAY=1
ciphers=$(openssl ciphers 'ALL:eNULL' | sed -e 's/:/ /g')

echo Obtaining cipher list from $(openssl version).

for cipher in ${ciphers[@]}
do
    echo -n Testing $cipher...
    result=$(echo -n | openssl s_client -cipher "$cipher"  -connect $SERVER 2>&1)
    if [[ "$result" =~ ":error:" ]] ; then
        error=$(echo -n $result | cut -d':' -f6)
        echo NO \($error\)
    else
        if echo $result | grep -q "Verify return code: 0 (ok)"; then
            echo YES
        else
            echo UNKNOWN RESPONSE
            echo $result
         fi
    fi
sleep $DELAY
done

AntOS 1.0.0-alpha

Github: https://github.com/lxsang/antos branch antos-1.0.0a

Demo: https://app.iohub.dev/antos/ using user name and password: demo/demo

If one wants to run AntOS VDE locally in their system, a docker image is available at:
https://github.com/lxsang/antosaio

API Documentation: https://doc.iohub.dev/antos

It has been a long time since version 0.x.x and now AntOS hits a major changes in its API. From version 1.0.0, AntOS no longer depends on Riot.js in its core UI API. This version introduces a brand new AntOS UI API called AFX API which is rewritten from bottom up. The entire AntOS core API is rewritten in Typescript (from Coffeescript) for better debugging, code maintenance and documenting.

Browser support: tested on Chrome, Firefox and partly Safari. Any browser that supports custom elements API should work. May have problem with Microsoft Edge.

Rust tip: (Unix) drop the current user privileges

Brief

Rust is a modern programing language which is claimed to be blazingly fast and memory-efficient. It syntactically similar to C++, but is designed to provide better memory safety while maintaining high performance and productivity:

  • Zero cost abstraction: allow a perfect balance between performance and productivity
  • Memory efficient with no runtime or garbage collector
  • Memory safe: Rust does not permit null pointers, dangling pointers, or data races in safe code.
  • Memory management using an ownership model guarantee memory-safety and thread-safety .
  • Great documentation, easy to use compiler and integrated packages/libraries management
  • Easy to interface with other language.
  • A bit of learning curve for the variable ownership and variable lifetime features.

Meet Dolly the robot

Ladies and gentlemen, please meet "Dolly the robot", the first version of my DIY mobile robot. My goal in this DIY project is to make a low-cost yet feature-rich ROS (Robot Operating System) based mobile robot that allow me to experiment my work on autonomous robot at home. To that end, Dolly is designed with all the basic features needed. To keep the bill of material as low as possible, i tried to recycle all of my spare hardware parts.

Specification

  • Robot's chassis is 3D printed, the chassis's plate design is borrowed from the design of Turtlebot 3 which is a smart design, IMO. The other hardware parts, however, are completely different from the Turtlebot 3.
  • IMU sensor with 9 DOF (accelerometer, magnetometer and gyroscope) for robot orientation measurement
  • Two DC motors with magnetic encoders using as wheels and odometer
  • Arduino Mega 2560 for low level control of the robot
  • Raspberry PI 3B+ with embedded Linux for high level algorithm and network communication. The ROS middle-ware on top of the Linux system offers a powerful robotic software environment
  • A 360 degree Neato LiDAR (laser scanner) up to 6 m range
  • A 8 Mega pixel camera (Raspberry PI camera)
  • Adafruit Motor shield V2 for motor controlling
  • 10000 Mah battery
  • ADS1115 analog sensor to measure and monitor battery usage
  • 0.95" (128x64) mini OLED display
  • The robot can be tele-operated using a bluetooth controller such as a PS4 controller

Applications

  • Localization and mapping (SLAM)
  • Obstacle avoidance
  • Autonomous navigation
  • Robot perception algorithms with LIDAR sensor and camera
  • Much more...
18/06/2019 PhaROS, ROS, Pharo, tutorial

A first step guide to PhaROS

PhaROS is a collection of Pharo libraries that implements the ROS (Robot Operating System ) based client protocol. It allows developing robotic applications right in the Pharo environment by providing an abstract software layer between Pharo and ROS. This guide makes an assumption that readers already have some basic knowledge about ROS, if this is not the case, please check the following links before going any further on this page:

Dispatching tasks to multiple Pharo VMs using SystemProcess

Doing a research work in robotic domain using Pharo as a prototype and implementation tool (via phaROS) is a whole new experience. It is quite impressive to see how quick an implementation idea becomes a working prototype/solution in Pharo thanks to its productive development environment. Most of my robotic applications are critical tasks which require real-time performance, some of them are heavily resource-demanding (CPU). Due to the single process nature of Pharo, running these tasks on the same VM results in a performance bottleneck, thus sometime, violate the real-time requirement of the application. Common solution to this problem is to dispatch these tasks to several native system processes to boost the performance. Unfortunately, this feature is not supported in current Pharo. My goal in this case is to have something that allow to:

  • maintain the use of Pharo's productive environment, so implementation the applications in another language is not an option
  • be able do dispatch tasks to different system processes, (in this case, tasks running on different VMs using the same image), and have a simple inter-VM communication mechanism

And that is when SystemProcess plays its role.

PTerm: yet another Terminal Emulator for Pharo

PTerm

I use Unix terminal a lot in work, when i work with Pharo and ROS (PhaROS), switching regularly between Pharo and native terminal application (for ROS command line) is kind of inconvenient. I've been thinking of using a terminal emulator application for Pharo. Googling around, i found out that there is no such thing that is ready for production work on modern Pharo, except a prototype work of Pavel Krivanek available at: https://github.com/pavel-krivanek/terminal. However, that code is messy, buggy, and not ready for production work . So i decided to take my time to work on it.

WVNC: web based protocol and API for accessing VNC server from browser via websocket

This post is deprecated, WVNC now is a part of AntOS eco-system. The easiest way to setup a Web base VNC client is to used the AntOS docker image that is presented in this post.

As with AntOS and its applications, one can remotely access and edit server resources from browser in a desktop-like manner. However, sometime these web based applications are not enough for some specific tasks. For a long time, I've thinking of a web based API for controlling remote desktop right from the browser ( or AntOS application). The VNC protocol is a good starting point. After playing around with libvncserver/libvncclient, i came up with wvnc a web based protocol and API for accessing VNC servers using websocket.

Powered by antd server, (c) 2017 - 2024 Dany LE.This site does not use cookie, but some third-party contents (e.g. Youtube, Twitter) may do.