Friday, September 18, 2015

Setup docker for RSyslog

I'm going to talk about setup RSync for python (api_hour) application. But it is also related to any languages, actually I will build my article on docker for php. So you can use it for any service with logging.

As you maybe know docker team decide (??? needed link ???) that it is not good to have more than 1 service inside of docker so if you decide to use well known syslog inside of you app you should launch it separately. Because usually none of docker images comes with syslog inside.

I was playing with brand new engine for async python - api_hour and realize that it requires syslog.

So I have stared from one article that bind mount hosts of syslog docker with your server docker. But there other more easer solution it based on entrypoint, shared volumes and soft links (issue #4).

So in my case I have such launch script (shorten for example case):

echo '###########################################################################'
echo '# run syslog docker #'
echo '###########################################################################'
docker rm -f syslog
docker run --detach=true --name syslog helder/rsyslog
echo '###########################################################################'
echo '# run server docker #'
echo '###########################################################################'
docker run -i -t \
-p 8000:8000 \
--rm \
--volumes-from syslog \
--name web-server \
agg-web-server
logger -p local1.notice "This is a notice!"
view raw launch.sh hosted with ❤ by GitHub

you also should change

args=('/dev/log', handlers.SysLogHandler.LOG_LOCAL6)
view raw logging.org.ini hosted with ❤ by GitHub

to

args=('/dev/log', handlers.SysLogHandler.LOG_LOCAL1)
view raw logging.ini hosted with ❤ by GitHub

in etc/aggregator/api_hour/logging.ini.

After that you can check log output by

docker logs syslog
view raw run.sh hosted with ❤ by GitHub

Thanks all.

Monday, September 7, 2015

Untouched TouchScreen for Raspberry PI 2 pt1


And finally I have got a time to setup TouchScreen for my Rpi2. And I shat say that it wasn't easy.

What I have had:
- Rpi2
- 3.5" TFT LCD Touch Screen Module 320*480 RGB Display Board with logo of WaveShare SpotPear
http://www.wvshare.com/product/3.5inch-RPi-LCD-A.htm


I have found one article with tutorial http://www.circuitbasics.com/setup-lcd-touchscreen-raspberry-pi/. It uses common custom driver for Touch LCDs https://github.com/notro/fbtft/. But author of this article has different module with different controller.

But my module has XPT2046 controller and it requires slightly different setup command. Lets see those differences

$ sudo nano /etc/modules


#original
fbtft_device name=waveshare32b gpios=dc:22,reset:27 speed=48000000
waveshare32b width=320 height=240 buswidth=8 init=-1,0xCB,0x39,0x2C,0x00,0x34,0x02,-1,0xCF,0x00,0XC1,0X30,-1,0xE8,0x85,0x00,0x78,-1,0xEA,0x00,0x00,-1,0xED,0x64,0x03,0X12,0X81,-1,0xF7,0x20,-1,0xC0,0x23,-1,0xC1,0x10,-1,0xC5,0x3e,0x28,-1,0xC7,0x86,-1,0x36,0x28,-1,0x3A,0x55,-1,0xB1,0x00,0x18,-1,0xB6,0x08,0x82,0x27,-1,0xF2,0x00,-1,0x26,0x01,-1,0xE0,0x0F,0x31,0x2B,0x0C,0x0E,0x08,0x4E,0xF1,0x37,0x07,0x10,0x03,0x0E,0x09,0x00,-1,0XE1,0x00,0x0E,0x14,0x03,0x11,0x07,0x31,0xC1,0x48,0x08,0x0F,0x0C,0x31,0x36,0x0F,-1,0x11,-2,120,-1,0x29,-1,0x2c,-3
#my version
fbtft_device debug=3 rotate=90 name=flexfb speed=30000000 gpios=reset:25,dc:24
flexfb width=320 height=480 regwidth=16 init=-1,0xb0,0x0,-1,0x11,-2,250,-1,0x3A,0x55,-1,0xC2,0x44,-1,0xC5,0x00,0x00,0x00,0x00,-1,0xE0,0x0F,0x1F,0x1C,0x0C,0x0F,0x08,0x48,0x98,0x37,0x0A,0x13,0x04,0x11,0x0D,0x00,-1,0xE1,0x0F,0x32,0x2E,0x0B,0x0D,0x05,0x47,0x75,0x37,0x06,0x10,0x03,0x24,0x20,0x00,-1,0xE2,0x0F,0x32,0x2E,0x0B,0x0D,0x05,0x47,0x75,0x37,0x06,0x10,0x03,0x24,0x20,0x00,-1,0x36,0x28,-1,0x11,-1,0x29,-3
view raw modules hosted with ❤ by GitHub

$ sudo nano /boot/cmdline.txt

# original
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait fbtft_device.custom fbtft_device.name=waveshare32b fbtft_device.gpios=dc:22,reset:27 fbtft_device.bgr=1 fbtft_device.speed=48000000 fbcon=map:10 fbcon=font:ProFont6x11 logo.nologo dma.dmachans=0x7f35 console=tty1 consoleblank=0 fbtft_device.fps=50 fbtft_device.rotate=0
# my version
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait fbcon=map:1 fbcon=font:ProFont6x11
view raw cmdline.txt hosted with ❤ by GitHub

$ sudo nano /boot/config.txt

we use config.txt and device tree overlays because in actually firmware of Rpi2 no longer uses ads7846_device.
https://github.com/raspberrypi/firmware/blob/master/boot/overlays/README

# my version
dtdebug=on
dtoverlay=ads7846,penirq=17,speed=500000,swapxy=1
view raw config.txt hosted with ❤ by GitHub

so with those changes LCD screen works fine. But touch interface still doesn’t work I will do more investigations later, when I will get more free time. but if you have had same problem but now fixed it, please put comment here with right solution.

Links

http://www.waveshare.com/wiki/3.5inch_RPi_LCD_(A) - FAQ on site of

Tuesday, September 1, 2015

Live streaming of International Space Station video on Raspberry PI

Few days ago I found that there live streaming from International Space Station that available 24h 7 days in a week. It shows earth from a space and looks like brilliant screen saver that you can watch all day long or at least 45 minutes next 45 minutes it is just black screen because it comes to the night side of the earth.

So I have connected my Raspberry PI to TV and setup streaming. There a lot instructions how to archive it:

#!/bin/bash
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install rtmpdump python-pip
sudo pip install livestreamer
# to get best resolution
sudo apt-get install python-dev
sudo apt-get install libffi-dev
sudo apt-get install librtmp-dev
sudo pip install cffi
sudo pip install python-librtmp
livestreamer ustream.tv/channel/iss-hdev-payload best -np 'omxplayer -o hdmi -live'

And maybe because of slow connection my app was always stops playing. But luckily there easy way to fix it (just increase timeout):

#!/bin/bash
livestreamer --stream-segment-timeout 100000 --stream-timeout 100000 --http-timeout 100000 ustream.tv/channel/iss-hdev-payload best -np 'omxplayer -o hdmi -live --timeout 100000'