Kushal Das4

FOSS and life. Kushal Das talks here.

Conference travel for speakers

In Free and Open Source Software culture, conferences became an important part of the community. Most of the projects or communities do the work over this beautiful thing known as the Internet, people are taking part from the warmth of their home. Conferences are the only time when we all get a chance to meet, discuss new ideas, share the knowledge among ourselves. Conference speakers are generally the volunteers who agree to spend a lot of time to prepare and then give the talk, do the QA session. This also involves a lot of travel, for any mid-sized to a big conference, you will always find at least couple of speakers traveling half of the world to give those talks.

We, the organizers of many of these conferences can do a few things which helps the speakers to have a trouble free mind.

Inform the talk selection result as soon as possible(aka. visa takes time)

We should inform the speakers about the talk selection result as soon as possible. International traveling still requires visa for many countries, and generally, they are difficult to obtain in less time. For example, I am an Indian, and for getting a visa for most countries, I will have to submit my last three years income tax documents, last 6 months bank statements, office leave letters, and many other documents. Obtaining the documents take time, and we should make sure that the speakers have plenty of time to get this done.

Help with the travel timings

The organizers are local to the conference host city, it is better you provide some insight about travel timings to your conference speakers. They may not want to take a redeye flight, or maybe taking that early morning will provide a much better experience by skipping all the city traffic.

Be in touch during local travel

For all the conferences we organized in Pune (FUDCon 2011, 2015, PyCon Pune 2017), many of the international speakers landed in Mumbai, and then we organized cabs to pick them up, mostly all of these are between 12-4AM. They had to travel next 4 hours in the cab, we made sure to club at least 2 of the speakers in each cab, and also making sure that the drivers can speak English. Remember the language problem, as not every country speaks English fluently, and that goes same to all speakers too. If the speakers are coming on their own from the airport, make sure that they have all the details, and please try to have someone waiting for them at the airport. It is better that you introduce your volunteer to the speakers before the conference. That way when the speakers come out of the airport, they will see a familiar face waiting for them.

One of our tactics was to operate the whole speakers travel from the same hotel speakers were staying. I was awake for the 2 nights and started talking to the speakers as soon as they entered their cabs. We also talked to them during their trip to make sure that everything is okay, and they don’t uncomfortable. Only sad part was that due to lack of light many missed the beautiful view of Mumbai-Pune expressway.

During the conference days, before or after, we make sure that we have enough local volunteers to provide any help as required to the speakers. Many times it happens that the speakers prefer to visit some of the tourist locations before or after the conferences. As hosts, it goes also to our list of responsibilities, helping with the cab booking or providing suggestions for the sightseeing.

I remember the long list of speakers, and the checkbox(s) beside their names to mark that the speaker has boarded safely in the flight for their return journey. Our job is not done till the time they reach back to their home, and we make sure to keep an eye for any emergency. Many of the ideas also go to the speakers who are coming for the first time to the city from other parts of the country. In a country like India, where we have 24 official languages, it is difficult for most of Indians to understand or speak the local language in any state other than their own.

Previously, we had experiences where someone felt sick during the conference, and we have to take them to visit doctors, and making sure to check that they are okay. Telling that we have a large conference, and we can not take care of all of the people is easy, but remember the amount of effort these speakers are putting to make your conference as their own, and providing a great experience to the conference attendees.

Event report: FOSSASIA 2017

FOSSASIA 2017 reminded me of foss.in. After a long time, finally, a conference which has the similar aspects. Similar kind of tight organizing team, the presence of upstream communities from different locations. The participation from the local Singapore tech community along with Hackerspace Singapore is a serious boost. This was my 4th FOSSASIA conference, and also 3rd time in Singapore. I should thank Mario, Hong, and rest of the organizers to make this event a very pleasant experience.

This time Sayan booked an Airbnb for Anwesha and me. Saptak + Medo + Siddhesh + Praveen Patil, and Pooja Yadav, & Pravin Kumar were also staying in the same Airbnb in the Chinatown. The conference venue was the Singapore Science Center just like last year. Having the conference in the same place helps as the MRT route is very easy to reach there on time.

The day before the conference we had a speakers meetup in the Singapore Microsoft office. We also received a tour of the office, the person in-charge also explained about how are managing an office without permanent seating positions.

Day one

The conference started at 9:24AM (as Hong asked us to remember the time). I attended the talks from Harish Pillay and Chan Cheow Hoe. The idea of having the CIO of the country coming to the conference and giving a talk on Open Source is a great feeling. In 2015 we had Minister for Foreign Affairs, Mr. Vivian Balakrishnan giving a keynote (and talking about the NodeJS code he wrote). The way govt. is taking part in the local community events is something other countries should try to learn. Of course, Singapore has the benefit of being small in size.

Though the day was full of talks related to AI and machine learning, there were two talks I was waiting to attend. After lunch, the first one was from Bunnie Huang, where he spoke about making technology more inclusive. He talked about Chibitronics. Before I traveled to Singapore, I actually asked him to get a copy of his new book, The Hardware Hacker. I got my copy signed by him after his talk :) (I already finished the book while coming back to India, more on that later in a separate blog post). I also met Xobs and found a Chibtronics Love-to-Code board in his pocket :)

Later in the day, Frank Karlitschek gave his keynote titled Protecting privacy with free software. He brought up the original idea of the Internet being decentralized. The last talk of the day was a panel discussion on Artificial Intelligence.

Day 2 & Day 3

I spent most of the time in the Python track, and in between jumping around different floors of the venue meeting people. I personally had a two-hour workshop on MicroPython and NodeMCU. Anwesha was busy in the PyLadies table along with Pooja. I forgot to show the poster of PyCon APAC in the Python track :( But you can still submit talks and attend the conference. Sadly this will clash with another conference for me.

Anwesha had her talk on day 3, and her laptop’s display decided to crash just before the talk. But finally the slides came back :) I also attended the SELinux workshop from Jason Zaman. He and few BSD friends convinced me to try out ZFS, and then build a new home storage with FreeNAS.

Now I have to wait for the next edition of FOSSASIA. It is a great place where I can meet my friends from different parts of the world, and share ideas :)

Building IoT enabled power-strip with MicroPython and NodeMCU

This was on my TODO list for a long time. But, never managed to time to start working on it, I was also kind of scared of doing the AC wiring without adult supervision :).

Items used

  • Power-strip
  • USB power plug (any standard mobile phone charger)
  • wires
  • NodeMCU Amica
  • Relay board
  • MicroPython
  • Mosquitto server on my home network

I ordered double relay boards (this one was marked for Arduino) from Amazon, and they were laying in the boxes in the Pune Hackerspace for a long time.

Yesterday, we had a Raspberry Pi workshop in the hackerspace as part of the Python Pune monthly meetup. Nikhil was present in the meetup, and I asked for help from him as he is a real hardware expert.

We took one of the existing power-strip from the hackerspace, and also a mobile phone charger. After taking out 2 of the power sockets we had enough space to plug-in the rest of the system inside of it. Of course, Nikhil did all the hard work of soldering the wires in the proper manner.

The relay board is connected to a NodeMCU Amica running MicroPython. It has a code like the following example:

import time
from machine import Pin
from umqtt.simple import MQTTClient

# Received messages from subscriptions will be delivered to this callback
def sub_cb(topic, msg):
    led1 = Pin(14,Pin.OUT)
    if msg == b"on_msg":
        led1.low()
    elif msg == b"off_msg":
        led1.high()

def main(server="SERVER_IP"):
    c = MQTTClient("umqtt_client", server)
    c.set_callback(sub_cb)
    c.connect()
    c.subscribe(b"your_topic")
    while True:
        c.wait_msg()
    c.disconnect()

if __name__ == "__main__":
    try:
        time.sleep(10)
        main()
    except:
        pass

I will have to cover up the holes with something, and also push the code to a proper repository. Meanwhile this was the first usable thing I made with help from friends in the Hackerspace Pune. Come and join us to have more fun and build new things.

Btw, remember to have a password protected mosquitto server :)

Running MicroPython on 96Boards Carbon

I received my Carbon from Seedstudio a few months back. But, I never found time to sit down and work on it. During FOSSASIA, in my MicroPython workshop, Siddhesh was working to put MicroPython using Zephyr on his Carbon. That gave me the motivation to have a look at the same after coming back home.

What is Carbon?

Carbon is a 96Boards IoT edition compatible board, with a Cortex-M4 chip, and 512KB flash. It currently runs Zephyr, which is a Linux Foundation hosted project to build a scalable real-time operating system (RTOS).

Setup MicroPython on Carbon

To install the dependencies in Fedora:

$ sudo dnf group install "Development Tools"
$ sudo dnf install git make gcc glibc-static \
      libstdc++-static python3-ply ncurses-devel \
      python-yaml python2 dfu-util

The next step is to setup the Zephyr SDK. You can download the latest binary from here. Then you can install it under your home directory (you don’t have to install it system-wide). I installed it under ~/opt/zephyr-sdk-0.9 location.

Next, I had to check out the zephyr source, I cloned from https://git.linaro.org/lite/zephyr.git repo. I also cloned MicroPython from the official GitHub repo. I will just copy paste the next steps below.

$ source zephyr-env.sh
$ cd ~/code/git/
$ git clone https://github.com/micropython/micropython.git
$ cd micropython/zephyr

Then I created a project file for the carbon board specially, this file is named as prj_96b_carbon.conf, and I am pasting the content below. I have submitted the same as a patch to the upstream Micropython project. It disables networking (otherwise you will get stuck while trying to get the REPL).

# No networking for carbon
CONFIG_NETWORKING=n
CONFIG_NET_IPV4=n
CONFIG_NET_IPV6=

Next, we have to build MicroPython as a Zephyr application.

$ make BOARD=96b_carbon
$ ls outdir/96b_carbon/
arch     ext          isr_tables.c  lib          Makefile         scripts  tests       zephyr.hex  zephyr.map           zephyr.strip
boards   include      isr_tables.o  libzephyr.a  Makefile.export  src      zephyr.bin  zephyr.lnk  zephyr_prebuilt.elf
drivers  isrList.bin  kernel        linker.cmd   misc             subsys   zephyr.elf  zephyr.lst  zephyr.stat

After the build is finished, you will be able to see a zephyr.bin file in the output directory.

Uploading the fresh build to the carbon

Before anything else, I connected my Carbon board to the laptop using an USB cable to the OTG port (remember to check the port name). Then, I had to press the *BOOT0 button and while pressing that one, I also pressed the Reset button. Then, left the reset button first, and then the boot0 button. If you run the dfu-util command after this, you should be able to see some output like below.

$ sudo dfu-util -l
dfu-util 0.9
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2016 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/
Found DFU: [0483:df11] ver=2200, devnum=14, cfg=1, intf=0, path="2-2", alt=3, name="@Device Feature/0xFFFF0000/01*004 e", serial="385B38683234"
Found DFU: [0483:df11] ver=2200, devnum=14, cfg=1, intf=0, path="2-2", alt=2, name="@OTP Memory /0x1FFF7800/01*512 e,01*016 e", serial="385B38683234"
Found DFU: [0483:df11] ver=2200, devnum=14, cfg=1, intf=0, path="2-2", alt=1, name="@Option Bytes /0x1FFFC000/01*016 e", serial="385B38683234"
Found DFU: [0483:df11] ver=2200, devnum=14, cfg=1, intf=0, path="2-2", alt=0, name="@Internal Flash /0x08000000/04*016Kg,01*064Kg,03*128Kg", serial="385B38683234"

This means the board is in DFU mode. Next we flash the new application to the board.

$ sudo dfu-util -d [0483:df11] -a 0 -D outdir/96b_carbon/zephyr.bin -s 0x08000000
dfu-util 0.9
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2016 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/
dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
Opening DFU capable USB device...
ID 0483:df11
Run-time device DFU version 011a
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuERROR, status = 10
dfuERROR, clearing status
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 2048
DfuSe interface name: "Internal Flash "
Downloading to address = 0x08000000, size = 125712
Download [=========================] 100% 125712 bytes
Download done.
File downloaded successfully

Hello World on Carbon

The hello world of the hardware land is the LED blinking code. I used the on-board LED(s) for the same, the sample code is given below. I have now connected the board to the UART (instead of OTG).

$ screen /dev/ttyUSB0 115200
>>>
>>> import time
>>> from machine import Pin
>>> led1 = Pin(("GPIOD",2), Pin.OUT)
>>> led2 = Pin(("GPIOB",5), Pin.OUT)
>>> while True:
... led2.low()
... led1.high()
... time.sleep(0.5)
... led2.high()
... led1.low()
... time.sleep(0.5)

Having emojis in your Ubiquiti SSID

Ubiquiti management interface does not allow to have emojis in the network SSID. After asking over twitter about it, Donald Stufft pointed me to a hack in their forum.

First, create a second wifi network, and then you will have to copy the /tmp/system.cfg file from the access point.

scp yourusername@192.168.1.IP:/tmp/system.cfg .

After this open up the system.cfg in your favorite editor, replace the newly created network name with the emoji text you want. Copy it back to the access point. After this ssh into the access point, it will give you a busybox prompt. Type save command in the prompt, and then reboot the access point from the web-console. This will give you the SSID you were looking for :)

Testing Fedora MariaDB layered image using gotun

Testing Fedora MariaDB layered image testing using gotun

Yesterday Adam Miller announced the availability of the latest Fedora Layered Image release. The following container images are available in the Fedora registry:

  • registry.fedoraproject.org/f25/cockpit:130-1.3.f25docker
  • registry.fedoraproject.org/f25/cockpit:130
  • registry.fedoraproject.org/f25/cockpit
  • registry.fedoraproject.org/f25/kubernetes-node:0.1-3.f25docker
  • registry.fedoraproject.org/f25/kubernetes-node:0.1
  • registry.fedoraproject.org/f25/kubernetes-node
  • registry.fedoraproject.org/f25/mariadb:10.1-2.f25docker
  • registry.fedoraproject.org/f25/mariadb:10.1
  • registry.fedoraproject.org/f25/mariadb
  • registry.fedoraproject.org/f25/kubernetes-apiserver:0.1-3.f25docker
  • registry.fedoraproject.org/f25/kubernetes-apiserver:0.1
  • registry.fedoraproject.org/f25/kubernetes-apiserver
  • registry.fedoraproject.org/f25/kubernetes-master:0.1-5.f25docker
  • registry.fedoraproject.org/f25/kubernetes-master:0.1
  • registry.fedoraproject.org/f25/kubernetes-master
  • registry.fedoraproject.org/f25/flannel:0.1-3.f25docker
  • registry.fedoraproject.org/f25/flannel:0.1
  • registry.fedoraproject.org/f25/flannel
  • registry.fedoraproject.org/f25/kubernetes-proxy:0.1-3.f25docker
  • registry.fedoraproject.org/f25/kubernetes-proxy:0.1
  • registry.fedoraproject.org/f25/kubernetes-proxy
  • registry.fedoraproject.org/f25/etcd:0.1-5.f25docker
  • registry.fedoraproject.org/f25/etcd:0.1
  • registry.fedoraproject.org/f25/etcd
  • registry.fedoraproject.org/f25/toolchain:1-2.f25docker
  • registry.fedoraproject.org/f25/toolchain:1
  • registry.fedoraproject.org/f25/toolchain

Now, I am going to show how we can add a set of tests for the MariaDB container under gotun on a Fedora Atomic host. I will be firing up the job in the Fedora Infra Cloud.

Because of the nature of the Atomic host, I decided to write a set of tests in golang and build a static binary which can be executed inside of the Atomic host. This way we do not have to worry about any dependency in the host.

$ ldd tunirtests.test
	not a dynamic executable

Source code of the test

The following is the source for mysql_test.go.

package main

import (
	"testing"
	"database/sql"
	 _ "github.com/go-sql-driver/mysql"
)

func TestMariadb(t *testing.T) {
	db, err := sql.Open("mysql", "user:password@/dbname")
	if err != nil {
		t.Fatal("Can not connect to mariadb", err.Error())
	}
	defer db.Close()
	stmt := "CREATE TABLE IF NOT EXISTS funny (id int(5) NOT NULL AUTO_INCREMENT, name varchar(250), PRIMARY KEY(id))"
	_, err = db.Exec(stmt)
	if err != nil {
		t.Fatal("Can not create table", err.Error())
	}

	_, err = db.Exec("INSERT INTO funny VALUES (?,?)",1,"kushal")
	if err != nil {
		t.Fatal("Can not insert data", err.Error())
	}
	_, err = db.Exec("INSERT INTO funny VALUES (?,?)",2,"Python")
	if err != nil {
		t.Fatal("Can not insert data", err.Error())
	}
	rows, err := db.Query("SELECT * from funny")
	for rows.Next() {
		var uid int
		var name string
		err := rows.Scan(&uid, &name)
		if err != nil {
			t.Fatal("Error in selecting data", err.Error())
		}
		if uid == 1 {
			if name != "kushal" {
				t.Fatal("Oops, data mismatch", name)
			}
		}
	}

}

As you can see above that I have hardcoded username, password and dub name in the source. This is because while starting the Mariadb container, I can pass those values to the container using environment variables.

I am creating a table, inserting 2 rows in it. Then selecting those rows back to the tool.

the gotun job test file

The following is the content of the mariadb.txt file.

curl -O https://kushal.fedorapeople.org/tunirtests.test
sudo docker run -d --name mariadb_database -e MYSQL_USER=user -e MYSQL_PASSWORD=password -e MYSQL_DATABASE=dbname -p 3306:3306 registry.fedoraproject.org/f25/mariadb
SLEEP 30
chmod +x tunirtests.test
./tunirtests.test -test.run TestMariadb -test.v

At first, I am downloading the binary test file from my Fedora people space. We can also push it to the VM from the host using COPY directive. Next, I am running the docker command to fire up the container with all the required environment variables. After that, I am sleeping for 30 seconds as it takes time to get that container ready for usage. In the last line, I am executing the binary to test the container. Now, we can add more fancy command line arguments to the docker run command (like a data volume), and then test those too. But, I am going to keep those as an exercise for the reader :)

If you have any comment, feel free to drop me a mail, or tweet to @kushaldas.

The final output from the test is also given below.

./gotun --job mariadb
Starts a new Tunir Job.

Server ID: 9c4168ae-d8c4-4534-a53c-c2a291d4f6c5
Let us wait for the server to be in running state.
Time to assign a floating pointip.
Polling for a successful ssh connection.

Polling for a successful ssh connection.

Polling for a successful ssh connection.

Polling for a successful ssh connection.

Polling for a successful ssh connection.

Executing:  curl -O https://kushal.fedorapeople.org/tunirtests.test
Executing:  sudo docker run -d --name mariadb_database -e MYSQL_USER=user -e MYSQL_PASSWORD=password -e MYSQL_DATABASE=dbname -p 3306:3306 registry.fedoraproject.org/f25/mariadb
Sleeping for  30
Executing:  chmod +x tunirtests.test
Executing:  ./tunirtests.test -test.run TestMariadb -test.v
---------------


Result file at: /tmp/tunirresult_586858839


Job status: true


command: curl -O https://kushal.fedorapeople.org/tunirtests.test
status:true

  %!T(MISSING)otal    %!R(MISSING)eceived %!X(MISSING)ferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 4347k  100 4347k    0     0  3722k      0  0:00:01  0:00:01 --:--:-- 3725k


command: sudo docker run -d --name mariadb_database -e MYSQL_USER=user -e MYSQL_PASSWORD=password -e MYSQL_DATABASE=dbname -p 3306:3306 registry.fedoraproject.org/f25/mariadb
status:true

Unable to find image 'registry.fedoraproject.org/f25/mariadb:latest' locally
Trying to pull repository registry.fedoraproject.org/f25/mariadb ... 
sha256:9a2c3bc162b6b1a1c286302c3e635d77c6e31cbca5d354ed0a839c659e1ecfdc: Pulling from registry.fedoraproject.org/f25/mariadb
be44cf43edd1: Pull complete 
a87762b3425a: Pull complete 
Digest: sha256:9a2c3bc162b6b1a1c286302c3e635d77c6e31cbca5d354ed0a839c659e1ecfdc
Status: Downloaded newer image for registry.fedoraproject.org/f25/mariadb:latest
e9c72f1f41b1ec763418f969359c3319bdc4c95d8123fc3b5e6617768b90d00f


command: chmod +x tunirtests.test
status:true



command: ./tunirtests.test -test.run TestMariadb -test.v
status:true

=== RUN   TestMariadbConnect
--- PASS: TestMariadbConnect (0.20s)
PASS


Total Number of Tests:4
Total NonGating Tests:0
Total Failed Non Gating Tests:0

Success.