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

  • bpa
    replied
    Originally posted by PaulH View Post
    Ok, I will decode that on my HA.
    If it is Arduino based - there are many example C solution for URL decoding / percent decoding already available.

    Leave a comment:


  • PaulH
    replied
    Originally posted by bpa View Post
    I told you about readsq.py a many post ago.
    It uses the Python library to deocde the HTML encoded string into the internal Pyhtoin string (which supports UTF8).

    You're going in circles.
    Output from a modified readsq has to go out on the serial port but as discussed earlier PCP micropython doesn't support threading or perhaps pyserial. Which is why "nc" is being used.
    Ok, I will decode that on my HA.

    Leave a comment:


  • bpa
    replied
    Originally posted by PaulH View Post
    I saw this thread about the LCD display, but in German. https://forums.slimdevices.com/showt...l=1#post816678
    But it seems that into the readsq.py an UTF8/HTML decoding is done.
    Is it possible to adapt it ?
    I told you about readsq.py a many post ago.
    It uses the Python library to decode the HTML encoded string into the internal Python string (which supports UTF8).

    You're going in circles.
    Output from a modified readsq has to go out on the serial port but as discussed earlier PCP micropython doesn't support threading or perhaps pyserial. Which is why "nc" is being used.
    Last edited by bpa; 2022-01-25, 13:56. Reason: typos

    Leave a comment:


  • PaulH
    replied
    Originally posted by bpa View Post
    It is known HTML encoding, HTML escaping, HTML URL encoding or percent encoding. [url]https://www.w3schools.com/tags/ref_urlencode.asp[/url
    I saw this thread about the LCD display, but in German. https://forums.slimdevices.com/showt...l=1#post816678
    But it seems that into the readsq.py an UTF8/HTML decoding is done.
    Is it possible to adapt it ?

    Thanks

    Leave a comment:


  • bpa
    replied
    Originally posted by PaulH View Post
    The output is a little strange;
    What does dc%3Aa6%3A32%3A75%3A45%3A0a mean ?
    MAC address of ther player - %3A is a colon
    dc%3Aa6%3A32%3A75%3A45%3A0a = dc:a6:32:75:45:0a

    Code:
    title ?
    
    dc%3Aa6%3A32%3A75%3A45%3A0a title WOULD%20I%20LIE%20TO%20YOU
    Response syntax - <MAC address><SP><responsetype><SP><VALUE>
    dc:a6:32:75:45:0a title WOULD I LIE TO YOU


    See in WebUI - Help (bottom Left) - Technical Information - Command line Reference
    Last edited by bpa; 2022-01-24, 17:14.

    Leave a comment:


  • bpa
    replied
    Originally posted by PaulH View Post
    dc%3Aa6%3A32%3A75%3A45%3A0a title WOULD%20I%20LIE%20TO%20YOU[/CODE]

    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 ?
    It is known HTML encoding, HTML escaping, HTML URL encoding or percent encoding. https://www.w3schools.com/tags/ref_urlencode.asp

    Two reason
    1. Spaces are significant as a separator of keyword/parameters to distinguish from LMS values returned
    2. Data from LMS is UTF8 and so non ASCII with accented/foreign characters (e.g. chinese ) are in values returned.

    So HTML encoding so spaces and UTF8 characters in LMS returned values can be passed on accurately.

    Ga%C3%ABtan = Gaƫtan
    Last edited by bpa; 2022-01-24, 16:38. Reason: clarify 2nd point

    Leave a comment:


  • Paul Webster
    replied
    Originally posted by PaulH View Post
    it is also curious to see how the spaces are managed with %20 !
    URL-encoding - very common when you do not want embedded spaces to confuse the parsing of data.

    Accented chars also: Ga%C3%ABtan
    What kind of coding is it ?
    UTF-8 - from 2nd paragraph in the built-in documentation in LMS
    "For strings, Logitech Media Server uses the UTF-8 character-set encoding."

    Is it possible to configure it to ASCII ?
    No. I expect you will be able to find a UTF8 handling library - or just map the few accented characters that you know you will see if you do not plan to make this available to anyone else.
    Last edited by Paul Webster; 2022-01-24, 16:54.

    Leave a comment:


  • PaulH
    replied
    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.

    Leave a comment:


  • bpa
    replied
    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.

    Leave a comment:


  • PaulH
    replied
    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

    Leave a comment:


  • bpa
    replied
    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 ?

    Leave a comment:


  • PaulH
    replied
    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)

    Leave a comment:


  • bpa
    replied
    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.

    Leave a comment:


  • PaulH
    replied
    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 ???

    Leave a comment:


  • bpa
    replied
    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

    Leave a comment:

Working...
X