Announcement

Collapse
No announcement yet.

Search skills to create a plugin for Pcp running on Pi4.

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

    #16
    Originally posted by bpa View Post
    Not logical, perhaps more cost effective - maybe.

    Using onboard UARTs will be more complicated to setup unless you know someone has the specific knowledge of UIARTs and PCP.

    AFAICT RPi3/4 have 4 UARTs but normally only UART0/1 are enabled from config.txt. So for Raspbian systems, changes are needed to config.txt and the device tree overlay and also need to disable spawning of getty on the enabled UART0 port (usually called /dev/ttyACM0).

    You need to check what needs to be done for PCP.
    I don't care. As long as I can get serial control... ;-)

    Tried from Terminal:

    Code:
    stty -F /dev/ttyAMA0 9600
    echo "hello" > /dev/ttyAMA0
    I see on the serial line "hello"
    Last edited by PaulH; 2022-01-23, 16:32.

    Comment


      #17
      Originally posted by bpa View Post
      Not logical, perhaps more cost effective - maybe.
      Using onboard UARTs will be more complicated to setup unless you know someone has the specific knowledge of UIARTs and PCP.
      The onboard serial port is often used for serial console on the RPI, but we don't enable that by default. ttyAMA0 is pretty safe to use, provided you never enable the RPI bluetooth (It is disabled by default in pCP) If you want bluetooth, then use a USB serial device.....or use a bluetooth usb device.
      piCorePlayer a small player for the Raspberry Pi in RAM.
      Homepage: https://www.picoreplayer.org

      Please donate if you like the piCorePlayer

      Comment


        #18
        Originally posted by paul- View Post
        The onboard serial port is often used for serial console on the RPI, but we don't enable that by default. ttyAMA0 is pretty safe to use, provided you never enable the RPI bluetooth (It is disabled by default in pCP) If you want bluetooth, then use a USB serial device.....or use a bluetooth usb device.
        I'll not using Bluetooth !

        Comment


          #19
          Originally posted by PaulH View Post
          I don't care. As long as I can get serial control... ;-)

          Tried from Terminal:

          Code:
          stty -F /dev/ttyAMA0 9600
          echo "hello" > /dev/ttyAMA0
          I see on the serial line "hello"
          Good news.
          First try the command
          Code:
          nc 192.168.1.120 9090 </dev/ttyAMA0 >/dev/ttyAMA0
          If nc manages to connected your LMS CLI on port 9090 - no error.

          Make sure a player is connected to LMS. Example commands to send. Each command is ended by a <LF> CTRL/J which will tell CLI to process chars up to CTRL/J. Nothing will appear on screen as CLI does not echo char by char - only response to commands.

          player count ?<LF>
          player name 0 ?<LF>

          Comment


            #20
            Originally posted by bpa View Post
            First try the command
            Code:
            nc 192.168.1.120 9090 </dev/ttyAMA0 >/dev/ttyAMA0
            If nc manages to connected your LMS CLI on port 9090 - no error.
            Command seems to be accepted!
            Code:
            [email protected]:~$ nc 192.168.1.120 9090 </dev/ttyAMA0 >/dev/ttyAMA0
            Originally posted by bpa View Post
            Make sure a player is connected to LMS. Example commands to send. Each command is ended by a <LF> CTRL/J which will tell CLI to process chars up to CTRL/J. Nothing will appear on screen as CLI does not echo char by char - only response to commands.

            player count ?<LF>
            player name 0 ?<LF>
            Not sure what I'm doing.
            After nc...
            I write:
            player count?
            And enter (Terminal send probably <CR><LF>

            But I see neither answer on Terminal nor on RS232 side.

            Comment


              #21
              Originally posted by PaulH View Post
              And enter (Terminal send probably <CR><LF>
              No it won't, it will just send a single char <CR> which is CTRL/M

              The CLI client will not start processing (i.e no reply) until it see a <LF> i.e. CTRL/J

              Can you not use keyboard and press CTRL key simultaneously with J key ?

              Comment


                #22
                Originally posted by bpa View Post
                No it won't, it will just send a single char <CR> which is CTRL/M

                The CLI client will not start processing (i.e no reply) until it see a <LF> i.e. CTRL/J

                Can you not use keyboard and press CTRL key simultaneously with J key ?
                I wrote player count ?
                and press CTRL J.
                Nothing displayed neither on RS nor on Terminal
                Click image for larger version

Name:	Capture d’écran 2022-01-24 à 13.57.55.jpg
Views:	1
Size:	20.3 KB
ID:	1574330

                Comment


                  #23
                  Originally posted by PaulH View Post
                  I wrote player count ?
                  and press CTRL J.
                  Nothing displayed neither on RS nor on Terminal
                  OK possible problem with busybox nc or serialport or Terminal setup.
                  Need to check to see what LMS sees.

                  Use WebGUI Settings/Advanced/Logging/plugin.cli and set to DEBUG and click Apply.

                  Try to do "nc" and "player count ?" command and then look in server.log (Webui Settings/Information) - do you see something like below.

                  If "nc" works then "clock_socket_connect" and "cli_socket_read" will show.

                  Code:
                  [22-01-24 13:14:55.8967] Slim::Plugin::CLI::Plugin::cli_socket_accept (267) Accepted connection from 127.0.0.1:52242 (2 active connections)
                  [22-01-24 13:15:01.5590] Slim::Plugin::CLI::Plugin::client_socket_read (315) Begin Function
                  [22-01-24 13:15:01.5595] Slim::Plugin::CLI::Plugin::client_socket_read (349) 127.0.0.1:52242 - Buffered [[color=red]player count ?[/color]
                  ]
                  [22-01-24 13:15:01.5599] Slim::Plugin::CLI::Plugin::client_socket_buf_parse (388) 127.0.0.1:52242
                  [22-01-24 13:15:01.5604] Slim::Plugin::CLI::Plugin::client_socket_buf_parse (411) Using terminator "\r\n" for 127.0.0.1:52242
                  [22-01-24 13:15:01.5607] Slim::Plugin::CLI::Plugin::cli_process (527) player count ?
                  [22-01-24 13:15:01.5613] Slim::Plugin::CLI::Plugin::cli_process (602) Processing request [player]
                  [22-01-24 13:15:01.5616] Slim::Plugin::CLI::Plugin::cli_process (636) Dispatching [player]
                  [22-01-24 13:15:01.5621] Slim::Plugin::CLI::Plugin::cli_request_write (690) player count
                  [22-01-24 13:15:01.5625] Slim::Plugin::CLI::Plugin::client_socket_buffer (506) 127.0.0.1:52242
                  [22-01-24 13:15:01.5628] Slim::Plugin::CLI::Plugin::client_socket_write (450) 127.0.0.1:52242
                  [22-01-24 13:15:01.5631] Slim::Plugin::CLI::Plugin::client_socket_write (463) 127.0.0.1:52242 - Sending response [player count 1...]
                  [22-01-24 13:15:01.5633] Slim::Plugin::CLI::Plugin::client_socket_write (489) Sent response to 127.0.0.1:52242

                  Comment


                    #24
                    Originally posted by bpa View Post
                    Use WebGUI Settings/Advanced/Logging/plugin.cli and set to DEBUG and click Apply.
                    Yes.... but humm... where is it ???

                    Comment


                      #25
                      Originally posted by PaulH View Post
                      Yes.... but humm... where is it ???
                      Using default UI and not Material UI.

                      WebGUI = Browser Web Interface to LMS <ipaddressofp[i>:9000

                      Click Settings button - bottom right.

                      In Settings- Click the tab marked "Advanced" it is next to "Information" tab.

                      Ther si a drop down menu on LHS - click the arrow to show all the options. Select the Logging one.

                      Then find the plugin.cli drop down box - and change to DEBUG from ERROR

                      Then click button Apply at Bottom right.

                      Comment


                        #26
                        Found!! Thanks!


                        Code:
                        [22-01-24 14:42:02.0907] Slim::Utils::Timers::__ANON__ (272) Error: Timer Slim::Networking::SqueezeNetwork::__ANON__ failed: 
                        [22-01-24 14:42:17.8184] Slim::Networking::SqueezeNetwork::_error (431) Unable to login to SN: Timed out waiting for data
                        [22-01-24 14:42:17.8192] Slim::Networking::SqueezeNetwork::_init_error (156) Unable to login to mysqueezebox.com, sync is disabled: Timed out waiting for data (https://www.mysqueezebox.com)
                        [22-01-24 14:42:17.8201] Slim::Networking::SqueezeNetwork::_init_error (172) mysqueezebox.com sync init failed: Timed out waiting for data, will retry in 300 (https://www.mysqueezebox.com)
                        [22-01-24 14:45:28.2695] Slim::Plugin::CLI::Plugin::cli_socket_accept (227) Begin Function
                        [22-01-24 14:45:28.2709] Slim::Plugin::CLI::Plugin::cli_socket_accept (267) Accepted connection from 192.168.1.120:37219 (1 active connections)
                        [22-01-24 14:46:52.6578] Slim::Plugin::CLI::Plugin::client_socket_read (315) Begin Function
                        [22-01-24 14:46:52.6585] Slim::Plugin::CLI::Plugin::client_socket_read (340) Connection with 192.168.1.120:37219 half-closed by peer
                        [22-01-24 14:46:52.6591] Slim::Plugin::CLI::Plugin::client_socket_close (287) Begin Function
                        [22-01-24 14:46:52.6599] Slim::Plugin::CLI::Plugin::client_socket_close (305) Closed connection with 192.168.1.120:37219 (0 active connections)
                        [22-01-24 14:46:53.9903] Slim::Plugin::CLI::Plugin::cli_socket_accept (227) Begin Function
                        [22-01-24 14:46:53.9917] Slim::Plugin::CLI::Plugin::cli_socket_accept (267) Accepted connection from 192.168.1.120:46821 (1 active connections)

                        Comment


                          #27
                          Originally posted by PaulH View Post
                          Found!! Thanks!
                          OK - connection made - indicates that "nc" is working. So problem is CLI plugin is not processing data because it has not received a <LF>

                          My guess the issues is Terminal. I don;t know Terminal. I assumed Terminal was a "console" type applications for Mac and not a TTY simulation and so it may be filtering keystrokes.

                          You need to investigate Terminal settings. If Terminal in an an Apple system - how is Apple system connected to Pi serial line ?

                          Comment


                            #28
                            At 14:42 nc 192.168.1.120 9090 </dev/ttyAMA0 >/dev/ttyAMA0 sent with ENTER
                            At 15:02 nc 192.168.1.120 9090 </dev/ttyAMA0 >/dev/ttyAMA0 sent with CTRL J

                            After some checks it seems that terminal send CR with Enter or CTRL J
                            http://hints.macworld.com/article.ph...40107223331700

                            From my MAC, USB to serial converter. I'm using CoolTerm to receive/send serial datas.
                            It works because echo "hello" > /dev/ttyAMA0
                            CoolTerm display "Hello"

                            But I did everything wrong
                            I should send player count ? from the RS232 side not from Terminal side!! And... it works !!!

                            Code:
                            player count ?
                            
                            player count 1
                            
                            
                            player name ?
                            
                            player name %3F piCorePlayer
                            Code:
                            [22-01-24 15:22:27.8911] Slim::Plugin::CLI::Plugin::client_socket_write (463) 192.168.1.120:45781 - Sending response [...]
                            [22-01-24 15:22:27.8920] Slim::Plugin::CLI::Plugin::client_socket_write (489) Sent response to 192.168.1.120:45781
                            [22-01-24 15:22:33.6564] Slim::Plugin::CLI::Plugin::client_socket_read (315) Begin Function
                            [22-01-24 15:22:33.6570] Slim::Plugin::CLI::Plugin::client_socket_read (349) 192.168.1.120:45781 - Buffered [
                            ]
                            [22-01-24 15:22:33.6575] Slim::Plugin::CLI::Plugin::client_socket_buf_parse (388) 192.168.1.120:45781
                            [22-01-24 15:22:33.6581] Slim::Plugin::CLI::Plugin::cli_process (527) 
                            [22-01-24 15:22:33.6590] Slim::Plugin::CLI::Plugin::cli_process (602) Processing request []
                            [22-01-24 15:22:33.6595] Slim::Plugin::CLI::Plugin::cli_process (664) Request [] unknown or missing client -- will echo as is...
                            [22-01-24 15:22:33.6600] Slim::Plugin::CLI::Plugin::cli_request_write (690) 
                            [22-01-24 15:22:33.6607] Slim::Plugin::CLI::Plugin::client_socket_buffer (506) 192.168.1.120:45781
                            [22-01-24 15:22:33.6616] Slim::Plugin::CLI::Plugin::client_socket_write (450) 192.168.1.120:45781
                            [22-01-24 15:22:33.6621] Slim::Plugin::CLI::Plugin::client_socket_write (463) 192.168.1.120:45781 - Sending response [%1F%1E%08%08%08%0...]
                            [22-01-24 15:22:33.6629] Slim::Plugin::CLI::Plugin::client_socket_write (489) Sent response to 192.168.1.120:45781
                            [22-01-24 15:22:33.6636] Slim::Plugin::CLI::Plugin::client_socket_read (315) Begin Function
                            [22-01-24 15:22:33.6641] Slim::Plugin::CLI::Plugin::client_socket_read (349) 192.168.1.120:45781 - Buffered [
                            ]
                            [22-01-24 15:22:33.6646] Slim::Plugin::CLI::Plugin::client_socket_buf_parse (388) 192.168.1.120:45781
                            [22-01-24 15:22:33.6651] Slim::Plugin::CLI::Plugin::cli_process (527) 
                            [22-01-24 15:22:33.6658] Slim::Plugin::CLI::Plugin::cli_process (602) Processing request []
                            [22-01-24 15:22:33.6662] Slim::Plugin::CLI::Plugin::cli_process (664) Request [] unknown or missing client -- will echo as is...
                            [22-01-24 15:22:33.6667] Slim::Plugin::CLI::Plugin::cli_request_write (690) 
                            [22-01-24 15:22:33.6672] Slim::Plugin::CLI::Plugin::client_socket_buffer (506) 192.168.1.120:45781
                            [22-01-24 15:22:33.6679] Slim::Plugin::CLI::Plugin::client_socket_write (450) 192.168.1.120:45781
                            [22-01-24 15:22:33.6684] Slim::Plugin::CLI::Plugin::client_socket_write (463) 192.168.1.120:45781 - Sending response [...]
                            [22-01-24 15:22:33.6692] Slim::Plugin::CLI::Plugin::client_socket_write (489) Sent response to 192.168.1.120:45781
                            [22-01-24 15:22:34.8081] Slim::Plugin::CLI::Plugin::client_socket_read (315) Begin Function
                            [22-01-24 15:22:34.8086] Slim::Plugin::CLI::Plugin::client_socket_read (349) 192.168.1.120:45781 - Buffered [
                            ]
                            [22-01-24 15:22:34.8091] Slim::Plugin::CLI::Plugin::client_socket_buf_parse (388) 192.168.1.120:45781
                            [22-01-24 15:22:34.8095] Slim::Plugin::CLI::Plugin::cli_process (527) 
                            [22-01-24 15:22:34.8102] Slim::Plugin::CLI::Plugin::cli_process (602) Processing request []
                            [22-01-24 15:22:34.8106] Slim::Plugin::CLI::Plugin::cli_process (664) Request [] unknown or missing client -- will echo as is...
                            [22-01-24 15:22:34.8110] Slim::Plugin::CLI::Plugin::cli_request_write (690) 
                            [22-01-24 15:22:34.8119] Slim::Plugin::CLI::Plugin::client_socket_buffer (506) 192.168.1.120:45781
                            [22-01-24 15:22:34.8126] Slim::Plugin::CLI::Plugin::client_socket_write (450) 192.168.1.120:45781
                            [22-01-24 15:22:34.8130] Slim::Plugin::CLI::Plugin::client_socket_write (463) 192.168.1.120:45781 - Sending response [...]
                            [22-01-24 15:22:34.8137] Slim::Plugin::CLI::Plugin::client_socket_write (489) Sent response to 192.168.1.120:45781
                            [22-01-24 15:22:34.8143] Slim::Plugin::CLI::Plugin::client_socket_read (315) Begin Function
                            [22-01-24 15:22:34.8148] Slim::Plugin::CLI::Plugin::client_socket_read (349) 192.168.1.120:45781 - Buffered [
                            ]
                            [22-01-24 15:22:34.8152] Slim::Plugin::CLI::Plugin::client_socket_buf_parse (388) 192.168.1.120:45781
                            [22-01-24 15:22:34.8156] Slim::Plugin::CLI::Plugin::cli_process (527) 
                            [22-01-24 15:22:34.8162] Slim::Plugin::CLI::Plugin::cli_process (602) Processing request []
                            [22-01-24 15:22:34.8166] Slim::Plugin::CLI::Plugin::cli_process (664) Request [] unknown or missing client -- will echo as is...
                            [22-01-24 15:22:34.8170] Slim::Plugin::CLI::Plugin::cli_request_write (690) 
                            [22-01-24 15:22:34.8175] Slim::Plugin::CLI::Plugin::client_socket_buffer (506) 192.168.1.120:45781
                            [22-01-24 15:22:34.8181] Slim::Plugin::CLI::Plugin::client_socket_write (450) 192.168.1.120:45781
                            [22-01-24 15:22:34.8185] Slim::Plugin::CLI::Plugin::client_socket_write (463) 192.168.1.120:45781 - Sending response [...]
                            [22-01-24 15:22:34.8192] Slim::Plugin::CLI::Plugin::client_socket_write (489) Sent response to 192.168.1.120:45781

                            Comment


                              #29
                              Originally posted by PaulH View Post
                              I should send player count ? from the RS232 side not from Terminal side!! And... it works !!!
                              Great. Sometimes the solution is simple once it is found.

                              I think you'll now have question about how to use CLI (e.g. how to get notification of changes in metadata such as ytrack/artist etc).

                              I don't have much practical knowledge of CLI but there are users/developers who have made plugins,connections etc making a lot of use of CLI so for any CLI questions I think open a new thread with a title which contains "CLI" to make sure you catch the eyes of those users.

                              You can use this Apple setup to test & refine CLI commands/response processing before you put into your HA system.

                              Comment


                                #30
                                Originally posted by bpa View Post
                                I think you'll now have question about how to use CLI (e.g. how to get notification of changes in metadata such as ytrack/artist etc).
                                You have right!!! Notification of change will be great.

                                I thought that I must add:

                                Code:
                                nc 192.168.1.120 9090 </dev/ttyAMA0 >/dev/ttyAMA0
                                into Tweaks "User command"

                                The output is a little strange;
                                What does dc%3Aa6%3A32%3A75%3A45%3A0a mean ?

                                Code:
                                title ?
                                
                                dc%3Aa6%3A32%3A75%3A45%3A0a title WOULD%20I%20LIE%20TO%20YOU
                                it is also curious to see how the spaces are managed with %20 !
                                Accented chars also: Ga%C3%ABtan
                                What kind of coding is it ?
                                Is it possible to configure it to ASCII ?

                                Thank you very much bpa!!!
                                Last edited by PaulH; 2022-01-24, 16:06.

                                Comment

                                Working...
                                X