Internetové radio - Raspberry pi - problém s lcdproc

marty

Internetové radio - Raspberry pi - problém s lcdproc
« kdy: 24. 12. 2017, 17:41:59 »
Ahoj, stavím internetové radio z raspberry pi zero w ke kterému mám připojený klasický 1602 LCD s i2c modulem. Přehrávání rádia chci mít řešené přes mpd jako v tomto návodu : https://andypi.co.uk/2013/09/19/andypi-lcd-with-raspyfi/

Bohužel jsem ztroskotal na nastavení zobrazení právě přehrávané skladby/rádia pomocí lcdproc a mpdlcd

Všechny potřebné ovladače mám nainstalované (respektive, postupoval jsem krok po kroku podle návodu).

Pokud zadám
Kód: [Vybrat]
sudo mpdlcd --no-syslog vyleze hláška

Kód: [Vybrat]
WARNING mpdlcd Connection failed: [Errno 111] Connection refused
WARNING mpdlcd Connection failed: [Errno 111] Connection refused
WARNING mpdlcd Connection failed: [Errno 111] Connection refused
ERROR mpdlcd Unable to connect to lcdproc localhost:13666.

Máte někdo zkušenost s tímhle programem ?

Přikládám svoje nastavení.

LCDd.conf
Kód: [Vybrat]
## This file was written by cme command.
## You can run 'cme edit lcdproc' to modify this file.
## You may also modify the content of this file with your favorite editor.

# LCDd.conf -- configuration file for the LCDproc server daemon LCDd
#
# This file contains the configuration for the LCDd server.
#
# The format is ini-file-like. It is divided into sections that start at
# markers that look like [section]. Comments are all line-based comments,
# and are lines that start with '#' or ';'.
#
# The server has a 'central' section named [server]. For the menu there is
# a section called [menu]. Further each driver has a section which
# defines how the driver acts.
#
# The drivers are activated by specifying them in a driver= line in the
# server section, like:
#
#   Driver=curses
#
# This tells LCDd to use the curses driver.
# The first driver that is loaded and is capable of output defines the
# size of the display. The default driver to use is curses.
# If the driver is specified using the -d <driver> command line option,
# the Driver= options in the config file are ignored.
#
# The drivers read their own options from the respective sections.
# Andy Pi version2 with GPIO14 and GPIO18 swapped to enable same pins for use with Raspbian


[server]
# Tells the driver to bind to the given interface
Bind=127.0.0.1
# Tells the server to load the given drivers. Multiple lines can be given.
# The name of the driver is case sensitive and determines the section
# where to look for further configuration options of the specific driver
# as well as the name of the dynamic driver module to load at runtime.
# The latter one can be changed by giving a File= directive in the
# driver specific section.
#
# The following drivers are supported:
#   bayrad, CFontz, CFontz633, CFontzPacket, curses, CwLnx, ea65,
#   EyeboxOne, g15, glcdlib, glk, hd44780, icp_a106, imon, imonlcd,
#   IOWarrior, irman, joy, lb216, lcdm001, lcterm, lirc, lis, MD8800,
#   mdm166a, ms6931, mtc_s16209x, MtxOrb, mx5000, NoritakeVFD, picolcd,
#   pyramid, sed1330, sed1520, serialPOS, serialVFD, shuttleVFD, sli,
#   stv5730, svga, t6963, text, tyan, ula200, xosd
Driver=hd44780
# Where can we find the driver modules ?
# IMPORTANT: Make sure to change this setting to reflect your
#            specific setup! Otherwise LCDd won't be able to find
#            the driver modules and will thus not be able to
#            function properly.
# NOTE: Always place a slash as last character !
DriverPath=/home/pi/lcdproc/
NextScreenKey=Right
# Listen on this specified port; defaults to 13666.
Port=13666
PrevScreenKey=Left
ReportToSyslog=yes
# If set to no, LCDd will start with screen rotation disabled. This has the
# same effect as if the ToggleRotateKey had been pressed. Rotation will start
# if the ToggleRotateKey is pressed. Note that this setting does not turn off
# priority sorting of screens. [default: on; legal: on, off]
# AutoRotate=no
# If yes, the the serverscreen will be rotated as a usual info screen. If no,
# it will be a background screen, only visible when no other screens are
# active. The special value 'blank' is similar to no, but only a blank screen
# is displayed. [default: on; legal: on, off, blank]
ServerScreen=on
# Set master backlight setting. If set to 'open' a client may control the
# backlight for its own screens (only). [default: open; legal: off, open, on]
# Backlight=open
# Set master heartbeat setting. If set to 'open' a client may control the
# heartbeat for its own screens (only). [default: open; legal: off, open, on]
# Heartbeat=open
# set title scrolling speed [default: 10; legal: 0-10]
# TitleSpeed=10
# The "...Key=" lines define what the server does with keypresses that
# don't go to any client. The ToggleRotateKey stops rotation of screens, while
# the PrevScreenKey and NextScreenKey go back / forward one screen (even if
# rotation is disabled.
# Assign the key string returned by the driver to the ...Key setting. These
# are the defaults:
ToggleRotateKey=Enter
# Sets the reporting level; defaults to 2 (warnings and errors only).
# ReportLevel=3
# Should we report to syslog instead of stderr ? [default: no; legal: yes, no]
# ReportToSyslog=yes
# User to run as.  LCDd will drop its root privileges, if any,
# and run as this user instead.
User=any
# The server will stay in the foreground if set to true.
# Foreground=no
# Hello message: each entry represents a display line; default: builtin
# Hello="  Welcome to"
# Hello="   LCDproc!"
# GoodBye message: each entry represents a display line; default: builtin
# GoodBye="Thanks for using"
# GoodBye="   LCDproc!"
# Sets the default time in seconds to displays a screen.
WaitTime=5

[hd44780]
# Set brightness of the backlight (lcd2usb only) [default: 0; legal: 0 - 1000]
# Brightness=1000
# OffBrightness=0
# If you have a switchable backlight.
Backlight=yes
Brightness=800
# For multiple combined displays: how many lines does each display have.
# Vspan=2,2 means both displays have 2 lines.
# vspan=2,2
# If you have an HD66712, a KS0073 or another 'almost HD44780-compatible',
# set this flag to get into extended mode (4-line linear).
# ExtendedMode=yes
# In extended mode, on some controllers like the ST7036 (in 3 line mode)
# the next line in DDRAM won't start 0x20 higher. [default: 0x20]
# LineAddress=0x10
# Character map to to map ISO-8859-1 to the LCD's character set
# [default: hd44780_default; legal: hd44780_default, hd44780_euro, ea_ks0073,
# sed1278f_0b, hd44780_koi8_r, hd44780_cp1251, hd44780_8859_5, upd16314 ]
# (hd44780_koi8_r, hd44780_cp1251, hd44780_8859_5 and upd16314 are possible if
# compiled with additional charmaps)
CharMap=hd44780_default
# Select what type of connection. See documentation for types.
ConnectionType=rpi
# Set the initial contrast (bwctusb and lcd2usb) [default: 500; legal: 0 - 1000]
Contrast=800
# If your display is slow and cannot keep up with the flow of data from
# LCDd, garbage can appear on the LCDd. Set this delay factor to 2 or 4
# to increase the delays. Default: 1.
# DelayMult=2
# Some displays (e.g. vdr-wakeup) need a message from the driver to that it
# is still alive. When set to a value bigger then null the character in the
# upper left corner is updated every <KeepAliveDisplay> seconds. Default: 0.
# KeepAliveDisplay=0
# If you experience occasional garbage on your display you can use this
# option as workaround. If set to a value bigger than null it forces a
# full screen refresh <RefreshDiplay> seconds. Default: 0.
# RefreshDisplay=5
# You can reduce the inserted delays by setting this to false.
# On fast PCs it is possible your LCD does not respond correctly.
# Default: true.
DelayBus=true
# Device of the serial interface [default: /dev/lcd]
Device=/dev/i2c
# If you have a keypad you can assign keystrings to the keys.
# See documentation for used terms and how to wire it.
# For example to give directly connected key 4 the string "Enter", use:
#   KeyDirect_4=Enter
# For matrix keys use the X and Y coordinates of the key:
#   KeyMatrix_1_3=Enter
KeyMatrix_4_1=Enter
KeyMatrix_4_2=Up
KeyMatrix_4_3=Down
KeyMatrix_4_4=Escape
# If you have a keypad connected.
# You may also need to configure the keypad layout further on in this file.
Keypad=no
# If you have the additional output port ("bargraph") and you want to
# be able to control it with the lcdproc OUTPUT command
OutputPort=no
# Port where the LPT is. Usual value are: 0x278, 0x378 and 0x3BC
Port=0x27
# Specifies if the last line is pixel addressable (yes) or it controls an
# underline effect (no). [default: yes; legal: yes, no]
# Lastline=yes
# Specifies the size of the LCD.
# In case of multiple combined displays, this should be the total size.
Size=16x2
# Bitrate of the serial port (0 for interface default)
Speed=0

# ScrollUpKey=Up
# ScrollDownKey=Down
[menu]
DownKey=Down
EnterKey=Enter
# You can configure what keys the menu should use. Note that the MenuKey
# will be reserved exclusively, the others work in shared mode.
# Up to six keys are supported. The MenuKey (to enter and exit the menu), the
# EnterKey (to select values) and at least one movement keys are required.
# These are the default key assignments:
MenuKey=Escape
UpKey=Up

lcdproc.conf
Kód: [Vybrat]
# LCDproc client configuration file

## general options ##
[lcdproc]
# address of the LCDd server to connect to
Server=localhost

# Port of the server to connect to
Port=13666

# set reporting level
ReportLevel=2

# report to to syslog ?
ReportToSyslog=false

# run in foreground [default: false; legal: true, false]
#Foreground=true

# PidFile location when running as daemon [default: /var/run/lcdproc.pid]
#PidFile=/var/run/lcdproc.pid

# slow down initial announcement of modes (in 1/100s)
#delay=2

# display name for the main menu [default: LCDproc HOST]
#DisplayName=lcdproc


## screen specific configuration options ##

[CPU]
# Show screen
Active=True
OnTime=1
OffTime=2
ShowInvisible=false


[Iface]
# Show screen
Active=True

# Show stats for Interface0
Interface0=eth0
# Interface alias name to display [default: <interface name>]
Alias0=LAN

# Show stats for Interface1
#Interface1=eth1
#Alias1=WAN

# Show stats for Interface2
#Interface2=eth2
#Alias2=MGMT

# for more than 3 interfaces change MAX_INTERFACES in iface.h and rebuild

# Units to display [default: byte; legal: byte, bit, packet]
unit=bit

# add screen with transferred traffic
#transfer=TRUE


[Memory]
# Show screen
Active=True


[Load]
# Show screen
Active=True
# Min Load Avg at which the backlight will be turned off [default: 0.05]
LowLoad=0.05
# Max Load Avg at which the backlight will start blinking [default: 1.3]
HighLoad=1.3


[TimeDate]
# Show screen
Active=True
# time format [default: %H:%M:%S; legal: see strftime(3)]
TimeFormat="%H:%M:%S"
# date format [default: %x; legal: see strftime(3)]
DateFormat="%x"


[About]
# Show screen
Active=false


[SMP-CPU]
# Show screen
Active=false


[OldTime]
# Show screen
Active=false
# time format [default: %H:%M:%S; legal: see strftime(3)]
TimeFormat="%H:%M:%S"
# date format [default: %x; legal: see strftime(3)]
DateFormat="%x"
# Display the title bar in two-line mode. Note that with four lines or more
# the title is always shown. [default: true; legal: true, false]
#ShowTitle=false


[BigClock]
# Show screen
Active=false


[Uptime]
# Show screen
Active=false


[Battery]
# Show screen
Active=false


[CPUGraph]
# Show screen
Active=false


[ProcSize]
# Show screen
Active=false


[Disk]
# Show screen
Active=false


[MiniClock]
# Show screen
Active=True
# time format [default: %H:%M; legal: see strftime(3)]
TimeFormat="%H:%M"


# EOF

Případně jestli máte nějaké jiné funkční řešení jak zobrazovat názvy skladeb/rádia taky je mile rád uvítám.

Děkuji za případné odpovědi a přeji krásné prožití svátků Vánočních.


JardaP .

  • *****
  • 11 064
    • Zobrazit profil
    • E-mail
Re:Internetové radio - Raspberry pi - problém s lcdproc
« Odpověď #1 kdy: 24. 12. 2017, 18:58:22 »
ERROR mpdlcd Unable to connect to lcdproc localhost:13666.

Chce se pripojit na localhost, port 13666, asi se zamerem na nem poslouchat, ale nezdarilo se. Ten port uz ma neco otevrene. Co to je, najdete v netstat -naptu | grep :13666. Pocitam, ze uz vam tam visi jeden mpdlcd, takze druhy uz si nepustite.

marty

Re:Internetové radio - Raspberry pi - problém s lcdproc
« Odpověď #2 kdy: 24. 12. 2017, 20:42:19 »
Napoprvé to LCD detekovalo, každopádně LCD pořád nic nezobrazuje.

Co sem mám poslat, aby se z toho dalo něco vyčíst ?




Tomáš Bláha

Re:Internetové radio - Raspberry pi - problém s lcdproc
« Odpověď #3 kdy: 24. 12. 2017, 22:19:13 »
A máš spuštěného LCDproc démona? Všechny ty ostatní programy, které chtějí na displeji zobrazovat, se znaží ke spuštěnému LCDproc připojit a ta chybová hláška by znamenala, ze démon neběží, tudíž není otevřený port pro komunikaci s ním. I pouhý samotný spuštěný démon zobrazuje nějaké základní info. Tedy nejprve rozběhni démona a až pak řes mpdlcd...

marty

Re:Internetové radio - Raspberry pi - problém s lcdproc
« Odpověď #4 kdy: 24. 12. 2017, 23:17:02 »
Jestli mas na mysli
Kód: [Vybrat]
service LCDd start tak mam. Opravdu ten program neznam a v dokumentaci jsem nic kloudneho nenasel.


marty

Re:Internetové radio - Raspberry pi - problém s lcdproc
« Odpověď #5 kdy: 25. 12. 2017, 01:39:57 »
Trochu jsem pátral a víc se mi zamlouvá tahle metoda. V podstatě potřebuju zobrazit jeno název rádia a přehrávanou skladbu

Čili můžu použít příkaz
Kód: [Vybrat]
echo "currentsong" | nc localhost 6600 | grep -e "^Title: "
-e "^Name: "

To mi vyhodí např.

Kód: [Vybrat]
Title: ANETA LANGEROVÁ - Voda živá
Name: Radio BLANIK CZ

A teď jak ten výstup dostat přes i2c do LCD ?


dustin

Re:Internetové radio - Raspberry pi - problém s lcdproc
« Odpověď #6 kdy: 25. 12. 2017, 10:06:17 »
Poslat to po síti tomu správně nakonfigurovanému lcdproc démonovi. Který ti pravděpodobně po startu hned končí.

Běží? Koukal ses do logů? Poslouchá na portu? Chce to trochu základní diagnostiky, věci obvykle samy napoprvé nefungují.

Tomáš Bláha

Re:Internetové radio - Raspberry pi - problém s lcdproc
« Odpověď #7 kdy: 25. 12. 2017, 10:17:48 »
Ano, myslím LCDd start. Otázka je, jestli skutečně běží, takže ps axf|grep LCD by mělo vypsat něco jako:

Kód: [Vybrat]
2683 ?        Ss     0:00 /usr/sbin/LCDd -s 1 -f

Pokud běží, tak by měl poslouchat na portu, zkus příkaz netstat -anp|grep 13666:

Kód: [Vybrat]
tcp        0      0 localhost:13666         0.0.0.0:*               NASLOUCHÁ  2683/LCDd
tcp        0      0 localhost:13666         localhost:55712         SPOJENO     2683/LCDd
tcp        0      0 localhost:55712         localhost:13666         SPOJENO     3204/kodi.bin

Zde bys měl vidět, že LCDd naslouchá a případně jací klienti jsou k displeji připojeni. V mém případě jednak LCDd samotný, který generuje střídající se systémové informace a pak Kodi, který nahradí základní výpis za svoje informace o spuštěném videu.

Pokud nenaslouchá, je to divné. Můžeš také ověřit pomocí nmap localhost, zda je port otevřen či ne, příp. jestli není filtrován firewallem, což by na localhostu neměl.

Co se týče nápadu s nc localhost 6600, tak pokud jsem si dohledal, tak port 6600 je poskytován přehrávačem MPD, takže to seš pořád na začátku - nejprve ti musí správně fungovat LCDd, potom se k němu může připojit MPD a potom můžeš říci MPD, aby něco zobrazil. Tedy nejdříve ti musí fungovat LCDd.

Co se týče rozběhání LCDd, pak je také otázka, jestli ho máš správně nakonfigurovaný. V příkladu vidím, že používáš Driver=hd44780, potom je důležitý obsah sekce [hd44780] dále v konfiguračním souboru. Tam vidím, že máš napsáno mj. ConnectionType=rpi. Neznám tento konkrétní displej, ale když kouknu na https://andypi.co.uk/2013/09/19/andypi-lcd-with-raspyfi/ tak tam odkazují https://www.raspberrypi.org/forums/viewtopic.php?f=44&t=100066&p=723632&hilit=lcdproc%2braspberry%2b2#p723632, kde se píše, že správně je ConnectionType=raspberrypi. Zkus si prosím projít všechny rady, které tam píší a obecně LCDd loguje do systémového logu, tak se podívej, co při startu říká, to je důležité.

marty

Re:Internetové radio - Raspberry pi - problém s lcdproc
« Odpověď #8 kdy: 25. 12. 2017, 12:59:54 »
Ještě malinko odbočím, než se vrátím k tomuhle nefungujícímu řešení.

Mám script v pythonu, který mi funguje a zobrazuje data na LCD v pořádku.
Kód: [Vybrat]
import smbus
import time

# Define some device parameters
I2C_ADDR  = 0x27 # I2C device address, if any error, change this address to 0x3f
LCD_WIDTH = 16   # Maximum characters per line

# Define some device constants
LCD_CHR = 1 # Mode - Sending data
LCD_CMD = 0 # Mode - Sending command

LCD_LINE_1 = 0x80 # LCD RAM address for the 1st line
LCD_LINE_2 = 0xC0 # LCD RAM address for the 2nd line
LCD_LINE_3 = 0x94 # LCD RAM address for the 3rd line
LCD_LINE_4 = 0xD4 # LCD RAM address for the 4th line

LCD_BACKLIGHT  = 0x08  # On
#LCD_BACKLIGHT = 0x00  # Off

ENABLE = 0b00000100 # Enable bit

# Timing constants
E_PULSE = 0.0005
E_DELAY = 0.0005

#Open I2C interface
#bus = smbus.SMBus(0)  # Rev 1 Pi uses 0
bus = smbus.SMBus(1) # Rev 2 Pi uses 1

def lcd_init():
  # Initialise display
  lcd_byte(0x33,LCD_CMD) # 110011 Initialise
  lcd_byte(0x32,LCD_CMD) # 110010 Initialise
  lcd_byte(0x06,LCD_CMD) # 000110 Cursor move direction
  lcd_byte(0x0C,LCD_CMD) # 001100 Display On,Cursor Off, Blink Off
  lcd_byte(0x28,LCD_CMD) # 101000 Data length, number of lines, font size
  lcd_byte(0x01,LCD_CMD) # 000001 Clear display
  time.sleep(E_DELAY)

def lcd_byte(bits, mode):
  # Send byte to data pins
  # bits = the data
  # mode = 1 for data
  #        0 for command

  bits_high = mode | (bits & 0xF0) | LCD_BACKLIGHT
  bits_low = mode | ((bits<<4) & 0xF0) | LCD_BACKLIGHT

  # High bits
  bus.write_byte(I2C_ADDR, bits_high)
  lcd_toggle_enable(bits_high)

  # Low bits
  bus.write_byte(I2C_ADDR, bits_low)
  lcd_toggle_enable(bits_low)

def lcd_toggle_enable(bits):
  # Toggle enable
  time.sleep(E_DELAY)
  bus.write_byte(I2C_ADDR, (bits | ENABLE))
  time.sleep(E_PULSE)
  bus.write_byte(I2C_ADDR,(bits & ~ENABLE))
  time.sleep(E_DELAY)

def lcd_string(message,line):
  # Send string to display

  message = message.ljust(LCD_WIDTH," ")

  lcd_byte(line, LCD_CMD)

  for i in range(LCD_WIDTH):
    lcd_byte(ord(message[i]),LCD_CHR)

def main():
  # Main program block

  # Initialise display
  lcd_init()

  while True:

    # Send some test
    lcd_string("Nejaky text",LCD_LINE_1)
    lcd_string("Nejaky text",LCD_LINE_2)

    time.sleep(3)
 
    # Send some more text
    lcd_string("Nejaky text",LCD_LINE_1)
    lcd_string("Nejaky text",LCD_LINE_2)

    time.sleep(3)

if __name__ == '__main__':

  try:
    main()
  except KeyboardInterrupt:
    pass
  finally:
    lcd_byte(0x01, LCD_CMD)

Je nějaká možnost do tohohle scriptu dostat zmíněný
Kód: [Vybrat]
echo "currentsong" | nc localhost 6600 | grep -e "^Title: "
-e "^Name: "

Tím by se to všechno vyřešilo a nemusel bych u toho sedět další dva dny.

Tomáš Bláha

Re:Internetové radio - Raspberry pi - problém s lcdproc
« Odpověď #9 kdy: 25. 12. 2017, 13:13:07 »
Jasně, že můžeš v Pythonu spustit externí příkaz a něco pak udělat s textovým výstupem, který yprodukuje, viz např. https://stackoverflow.com/questions/89228/calling-an-external-command-in-python, ale to už je takové LMGTFY, to zvládneš sám...

marty

Re:Internetové radio - Raspberry pi - problém s lcdproc
« Odpověď #10 kdy: 25. 12. 2017, 13:24:59 »
Tak tohle vypadá ještě složitější, než rozchodit to původní řešení.

Vrátím se k tomu a pošlu ten výstup.

marty

Re:Internetové radio - Raspberry pi - problém s lcdproc
« Odpověď #11 kdy: 25. 12. 2017, 13:56:01 »
ps axf | grep LCD
Kód: [Vybrat]
27465 pts/0    S+     0:00          |           \_ grep --color=auto LCD
Druhy prikaz nevypise nic.

Dustin

Re:Internetové radio - Raspberry pi - problém s lcdproc
« Odpověď #12 kdy: 25. 12. 2017, 14:11:11 »
Vzdyt ti rikame, ze ten lcdproc nebezi. Musis zjistit proc - logy, spustit jej naprimo apod.

marty

Re:Internetové radio - Raspberry pi - problém s lcdproc
« Odpověď #13 kdy: 25. 12. 2017, 14:22:15 »
Kam to ukládá logy ?

marty

Re:Internetové radio - Raspberry pi - problém s lcdproc
« Odpověď #14 kdy: 25. 12. 2017, 14:50:57 »
Když zadám
Kód: [Vybrat]
sudo service lcdproc start
vyhodí

Kód: [Vybrat]
Failed to start lcdproc.service: Unit lcdproc.service not found.
Nic jiného