Announcement

Collapse
No announcement yet.

Uart RaspPi

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Uart RaspPi

    I move my question from HW to SW thread:

    Hi,


    The Raspberry has TxD and RxD lines. Is it possible to control the player (play, next, pause,...) from the serial line (RS232) ?

    Is it possible get the metadata outputs (title, track, artist) on this line ?

    Thanks

    #2
    RPi not RS232 ... and if you connected the serial port pins directly to RS232 device then you could damage the RPi.
    The RPi pins are 3.3v and RS232 is 5V and 12V ... expect major problems if you simply wire them together.

    You can get an adapter or connect via USB.

    However, I do not know of a built-in way to control or get song info out of that port.

    I expect that it could be done if you write some software (or find someone to do it for you).
    Paul Webster
    Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
    and, via the extra "Radio Now Playing" plugin lots more - see https://forums.slimdevices.com/showt...Playing-plugin

    Comment


      #3
      I don't know specific about Pi but generally serial on Linux

      To use a serial interface on a Linux box - 2 option.
      1. Dumb async terminals mode tty.
      2. PPP - TCP/IP over a serial link. (edit PPP not SLIP https://www.instructables.com/Connec...rk-using-UART/ )

      I think dumb terminal would be simplest.

      Serial line could be setup so user could then login with a shell.

      Then user could any of the usual command line stuff to communicate with LMS (e.g. CURL command to POST/GET JSON request to get info / do command)
      Alternative could be to use CLI interface to LMS (i.e. telnet localhost 9090) but I think is is deprecated so may have limited functionality.

      Look at LMS WebUI Help -> Technical Information > The Logical Media Command Line interface

      The help provides details (maybe a bit out of date) on CLI and JSON.

      For CLI it says
      the Logitech Media Server provides a command-line interface to the players via TCP/IP. After starting the server, commands and queries may be sent by connecting to a specific TCP/IP port. The server will reply echoing the request (for commands) or by returning the requested data (for queries). By default, the server will listen for connections on TCP/IP port 9090. This format is designed for ease of integration into AMX, Crestron and other automation systems.

      The end of line separator is line feed (<LF> ASCII decimal 10, hexadecimal 0x0A). The server accepts LF, CR or 0x00 (or any combination thereof) as end of line, and replies with whatever was used for the command. For strings, Logitech Media Server uses the UTF-8 character-set encoding.

      To use the command line interface interactively, use the telnet command from your system's command prompt: telnet localhost 9090 and when it connects, you can start typing commands. Beware that the server expects parameters to be encoded using percent-style escaping (see below); " and \ are not supported as in shell-like environments.
      Better options may be available, if more info on what is on the other end of the serial line is supplied.
      Last edited by bpa; 2022-01-14, 15:11.

      Comment


        #4
        Originally posted by Paul Webster View Post
        RPi not RS232 ... and if you connected the serial port pins directly to RS232 device then you could damage the RPi.
        The RPi pins are 3.3v and RS232 is 5V and 12V ... expect major problems if you simply wire them together.

        You can get an adapter or connect via USB.

        However, I do not know of a built-in way to control or get song info out of that port.

        I expect that it could be done if you write some software (or find someone to do it for you).
        Thanks Paul but I did not explain myself well. I would like to control the picoreplayer (play/pause,next,...) and to get metadata output via UART.

        Of course Paul, I'm fully aware about HW interfacing (3,3V/12V, MAX232...). I'm totally new about Linux, but no problem about HW !


        I founded this thread about connecting an HD44780 LCD display to show metadatas. if we could redirect the datas into the UART instead of LCD...
        https://forums.slimdevices.com/showt...layer-%A32-LCD


        Thanks

        Comment


          #5
          Originally posted by PaulH View Post
          I founded this thread about connecting an HD44780 LCD display to show metadatas. if we could redirect the datas into the UART instead of LCD...
          https://forums.slimdevices.com/showt...layer-%A32-LCD
          IIRC the LCD display is done using a small python script which talks to LMS on the CLI port using telnet. The script then converts the metadata into pixel etc for display using Pi GPIO.

          look at readsq.py

          Comment


            #6
            I discovered that there is a RS232 plugin in the LMS plugin
            But I didn't find any documentation.
            Could this do the trick?

            Comment


              #7
              Originally posted by PaulH View Post
              I discovered that there is a RS232 plugin in the LMS plugin
              But I didn't find any documentation.
              Could this do the trick?
              IIRC = No. I think it was about control of amps - LMS to device - you want a device to LMS.

              Look at the readsq.py application - it deal with CLI commands - you can rip out the text to graphics stuff or just use a reverse telnet application or maybe minicom

              There is a copy (no sure which version as it is posted in many threads)) attached to this post https://forums.slimdevices.com/showt...l=1#post816678

              All the "self.request" seem to be CLI command to LMS via telnet (i.e a serial link) - such as poweron, etc. All detailed in the WebGUI Help pager I posted earlier.

              Comment


                #8
                Click image for larger version

Name:	Capture d’écran 2022-01-15 à 12.16.00.jpg
Views:	1
Size:	86.5 KB
ID:	1574180
                Originally posted by bpa View Post
                IIRC = No. I think it was about control of amps - LMS to device - you want a device to LMS.
                You are right it's to control the Logitech Transporter (I never saw this unit)


                Otherwise I'm not able to write any program on Linux :-(. Maybe I can use an RS232 -> IP converter. It's probably working to send any basic commands (play, stop,....). For metadata, probably some programming skills is necessary!

                Comment


                  #9
                  Originally posted by PaulH View Post
                  [ATTACH]36836[/ATTACH]

                  You are right it's to control the Logitech Transporter (I never saw this unit)


                  Otherwise I'm not able to write any program on Linux :-(. Maybe I can use an RS232 -> IP converter. It's probably working to send any basic commands (play, stop,....). For metadata, probably some programming skills is necessary!
                  You have not described your use case.

                  I think you are over complicating things.

                  If the Pi running has a TCP/IP connection - just telnet to the LMS system portr 9090 and try a fewe of the LMS CLI command

                  Example on my LMS - telnet from a Ubuntu system - but it can be Windows, Android etc.
                  Red Command . All command ended with LF = CTRL/J and not Carriage Return (CTRL/M).
                  Code:
                  [color=red]$ telnet localhost 9090[/color]
                  Trying 127.0.0.1...
                  Connected to localhost.
                  Escape character is '^]'.
                  [color=red]status[/color]
                  7c%3A9e%3Abd%3A2b%3A52%3A94 status   player_name%3AMyDAC32 player_connected%3A1 player_ip%3A192.168.0.143%3A59045 power%3A1 signalstrength%3A0 mode%3Astop mixer%20volume%3A50 playlist%20repeat%3A0 playlist%20shuffle%3A0 playlist%20mode%3Aoff seq_no%3A0 playlist_tracks%3A0 digital_volume_control%3A1
                  [color=red]player count ?[/color]
                  player count 2
                  [color=red]player name 1 ?[/color]
                  player name 1 Squeezebox%20Receiver
                  [color=red]albums 0 4[/color]
                  albums 0 4 id%3A2 album%3A20th%20Century%20Blues id%3A12 album%3AAlright%2C%20Still id%3A4 album%3AAtlantic%20Soul%20-%20CD1 id%3A3 album%3ABetty%20Blue%2037%C2%B02%20Le%20Matin count%3A15

                  Comment


                    #10
                    Originally posted by bpa View Post
                    You have not described your use case.

                    I think you are over complicating things.

                    [/code]
                    Your are right, I had to explain first how I would like to use Picoreplayer.

                    I would like to integrate it on my small home made home automation. It's using Arduino, that's why it doesn't speak ethernet. But it speaks serial. 

                    I would like to control (start, stop, next, select a radio,...) the picoreplayer from it by sending an RS232 strings as "PLAY" for exemple.

                    My HA has a display and I can display some informations (temperature,...) also title and tracks. It could be perfect if the picore send a string when new metadata are coming (the same string displayed on the LCD is perfect for me).

                    I hope I have made myself clearer. I should have started there!

                    Comment


                      #11
                      Originally posted by PaulH View Post
                      I hope I have made myself clearer. I should have started there!
                      Much clearer.

                      I don't know about PCP and as you are doing development, I'd start with LMS on a full Raspbian/Max2play system to have full flexibility rather than cut down piCore.
                      Once you have a workign system, then figure a way to get it goingon on PCP as you may need to do a custom build if an extension is not available.

                      Simplest scenario:

                      Enable serial console on pi (e.g. https://medium.com/@sarala.saraswati...e-44d7df95f03e )

                      Then using arduino - login into Pi (i.e.codes wait for "Login:" prompt, code replies with userid and then wait for "password:" prompt and replied with password. Once in run telnet command.

                      If this is too complicated then a reverse telnet or maybe socat can connect serial port direct to LMS port 9090. You'd have to find out how to get the /dev/tty type driver running on GPIO pins to acts as serial port on the Pi for "reverse telnet" or socat to access (e.g. https://spellfoundry.com/2016/05/29/...luding-pi-3-4/) although probably much easier to buy a cheap USB-serial adaptor.

                      Comment


                        #12
                        Originally posted by bpa View Post
                        Much clearer.

                        I don't know about PCP and as you are doing development, I'd start with LMS on a full Raspbian/Max2play system to have full flexibility rather than cut down piCore.
                        I'm ok with C but not with Linux.

                        PCP is perfect for me. Restart perfectly after power supply failure, easy to use and efficient!

                        What about using an Hardware RS232-Ethernet adapter ? It should be possible to send any commands?

                        Comment


                          #13
                          Originally posted by PaulH View Post
                          I'm ok with C but not with Linux.
                          if you can do C - python P erl , bash etc. is just a bit of reading.

                          PCP is perfect for me. Restart perfectly after power supply failure, easy to use and efficient!
                          Limited.
                          I reckon if you could build socat for PCP a single command line would do what you need. However you'd need to build socat for PCP which may be possible as there is a socat extension for Tinycore (http://www.tinycorelinux.net/9.x/armv7/tcz/)

                          What about using an Hardware RS232-Ethernet adapter ? It should be possible to send any commands?
                          What do you mean
                          * something that implements TCP/IP over a serial line such as PPP - doesn't solve your problem.
                          * a serial server (e.g. nc601b type) - probably works but only if device is supported by PCP kernel but may need an extension for it. Still would need code on Arduino to login and issue CLI commands - same as my earlier suggestion

                          Comment


                            #14
                            Originally posted by bpa View Post
                            i* a serial server (e.g. nc601b type) - probably works but only if device is supported by PCP kernel but may need an extension for it. Still would need code on Arduino to login and issue CLI commands - same as my earlier suggestion
                            After looking at LMS CLI code - it just connects to a TCP port and expected line by line of text on a TCP port. The CLI code does not connect to a tty/serial device
                            An RS232-Ethernet connection usually creates tty devices and this is irrelevant to the CLI plugin and nothing gained in using it as application access the rs232 line will still have to issue "telnet" command to talk to CLI application or run something like socat to connect serial line to CLI's TCP port..

                            Comment


                              #15
                              Originally posted by bpa View Post
                              After looking at LMS CLI code - it just connects to a TCP port and expected line by line of text on a TCP port. The CLI code does not connect to a tty/serial device
                              An RS232-Ethernet connection usually creates tty devices and this is irrelevant to the CLI plugin and nothing gained in using it as application access the rs232 line will still have to issue "telnet" command to talk to CLI application or run something like socat to connect serial line to CLI's TCP port..
                              To summarize (with the knowledge I have) , external communication it's not so easy as I thought :-(

                              No issue for metadatas output.

                              The only issue I founded to control the player is using the SqueezeButtonPi. Instead buttons I could connect it to digital outputs from my Arduino.

                              Comment

                              Working...
                              X