Home of the Squeezebox™ & Transporter® network music players.
Page 1 of 4 123 ... LastLast
Results 1 to 10 of 37
  1. #1
    Senior Member
    Join Date
    Jan 2022
    Location
    Switzerland
    Posts
    146

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

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

    I'm a complete beginner in Pi and I'll need help.

    I can pay something or offer some electronic components in exchange.

    What I would need:

    - Output the metadatas (title, artist,...) on the GPIO14 TX uart line. (the same that are displayed on the LCD screen).
    Programs that display these metadatas on a 5x7 display (HD44780) exist. Could we redirect the output not to the LCD but to the UART?
    (ex:
    https://github.com/MartyTremblay/piC...yer-i2c-LCD.py
    https://forums.slimdevices.com/showt...layer-%A32-LCD
    )

    - Send commands (play, stop, .... (maybe the same commands as those used for IR)) through the GPIO15 RX line.

    Can someone make me a proposal?

    Thanks in advance.

  2. #2
    Senior Member
    Join Date
    Oct 2005
    Location
    Ireland
    Posts
    21,898
    Attached is a python program (an example from PySerial) which acts as a relay between a TCP port and a serial line. It works on Ubuntu - don't know about PCP

    Since the python prog readsq.py is used for the HD44780 display - I presume a version of python is available on pcp. However the python Serial module may not be on PCP so that would need to be checked.

    To run - example below:
    LMS is on same host as python prog - IP address is 192.168.0.126
    LMS CLI is configured on port 9090 - same as for the HD44780 utility.
    The serial port below is on /dev/ttyUSB2

    Serial line option such as speed etc are available as command line option use "-h" to find out syntax.

    Code:
    python3 tcp_serial_redirect.py -c 192.168.0.126:9090 /dev/ttyUSB2
    When it runs - data from serial port is relayed to LMS CLI port 9090 and output send back to serial port.
    CLI commands end with ASCII <LF> 0x0A or CTRL/J

    A CLI command to test whether it works would be
    Code:
    player id ?<LF>
    To control players, enable notification of metadata etc. - look at readsq.py.
    Attached Files Attached Files
    Last edited by bpa; 2022-01-22 at 12:34. Reason: typos and attribute source of prog.

  3. #3
    Senior Member
    Join Date
    Oct 2005
    Location
    Ireland
    Posts
    21,898
    Quote Originally Posted by bpa View Post
    I presume a version of python is available on pcp. However the python Serial module may not be on PCP so that would need to be checked.
    There is a python extension for pcp and there is also a pip extension which I presume it is Python's pip repository tool. If that is the case, you can install pyserial using pip.
    It looks like you know how to get serial port workiogn opn PCP - the python prog expects a standard Linux serial device port driver.

    After installation you'll need to make installed programs them persistent using pcp's documented methods.

  4. #4
    Senior Member
    Join Date
    Jan 2022
    Location
    Switzerland
    Posts
    146
    Quote Originally Posted by bpa View Post
    Attached is a python program (an example from PySerial) which acts as a relay between a TCP port and a serial line. It works on Ubuntu - don't know about PCP
    Thanks a lot bpa.

    PcP use microPython.

    I tried a get this message:
    Code:
    tc@pCP:~$ micropython serial.py
    Traceback (most recent call last):
      File "serial.py", line 11, in <module>
      File "/home/tc/serial.py", line 12, in <module>
    ImportError: no module named 'serial.threaded'
    Thanks

  5. #5
    Senior Member
    Join Date
    Oct 2005
    Location
    Ireland
    Posts
    21,898
    Quote Originally Posted by PaulH View Post
    PcP use microPython.
    I don't know but there may also be a full pytnon available as an extension if required. Pi memory is the problem when running full python.

    Code:
    ImportError: no module named 'serial.threaded'
    Need to install pyserial.

  6. #6
    Senior Member
    Join Date
    Oct 2005
    Location
    Ireland
    Posts
    21,898
    If pyserial was installed but does not have the serial.threaded part (i.e. old version of pyserial) then perhaps the legacy version of example (attached) may work as it does not use serial.threaded.

    If micropython does not support "threading" - not sure but you may be able to rewrite using _thread ?

    edit:

    No real possibility of python on PCP see
    https://forums.slimdevices.com/showt...l=1#post973773
    Attached Files Attached Files
    Last edited by bpa; 2022-01-23 at 02:58.

  7. #7
    Senior Member
    Join Date
    Jan 2022
    Location
    Switzerland
    Posts
    146
    Quote Originally Posted by bpa View Post
    If pyserial was installed but does not have the serial.threaded part (i.e. old version of pyserial) then perhaps the legacy version of example (attached) may work as it does not use serial.threaded.

    If micropython does not support "threading" - not sure but you may be able to rewrite using _thread ?

    edit:

    No real possibility of python on PCP see
    https://forums.slimdevices.com/showt...l=1#post973773
    With the new file:
    tc@pCP:~$ micropython serial2.py
    Traceback (most recent call last):
    File "serial2.py", line 63
    SyntaxError: invalid syntax

    I downloaded the pyserial-3.5.tar.gz but how to tranfer it from my download directory to the pi ?
    I tried
    iMac-480:downloads ph$ scp pyserial-3.5.tar.gz pi@192.168.1.120:root/

    pi@192.168.1.120's password:

    It's not raspberry not piCore...

  8. #8
    Senior Member
    Join Date
    Oct 2005
    Location
    Ireland
    Posts
    21,898
    Before going further.

    Did you check out the suggestion of using netcat aka nc ?

    I did a very very quick test on Ubuntu and it seem to work.

    Example.

    Code:
     nc 192.168.0.98 9090 </dev/ttyUSB1 >/dev/ttyUSB1

  9. #9
    Senior Member
    Join Date
    Oct 2005
    Location
    Ireland
    Posts
    21,898
    Quote Originally Posted by PaulH View Post
    With the new file:
    tc@pCP:~$ micropython serial2.py
    Traceback (most recent call last):
    File "serial2.py", line 63
    SyntaxError: invalid syntax
    Works ok on my Ubuntu Python 3.8 - Looks like a micropython limitation or possibly some sort of tab/space indentation problem.

    I downloaded the pyserial-3.5.tar.gz but how to tranfer it from my download directory to the pi ?
    I tried
    iMac-480:downloads ph$ scp pyserial-3.5.tar.gz pi@192.168.1.120:root/

    pi@192.168.1.120's password:

    It's not raspberry not piCore...
    No point looking for newer pyserial - micropytHon is cut down PytHon - so fewer features, so you want older not newer, which is why 2nd file is "legacy". 1st example program came from 3.5 - nothing to be gained messing with separate download.

  10. #10
    Senior Member
    Join Date
    Oct 2005
    Location
    Ireland
    Posts
    21,898
    Assuming you can build a simple C program on PCP - example of a simple telnet program which will do similar to socat / netcat

    https://l3net.wordpress.com/projects...elnet-project/
    source on sf https://sourceforge.net/projects/simpletelnet/


    After building the following worked on Ubuntu
    Code:
    stelnet 192.168.0.98 9090 </dev/ttyUSB1 >/dev/ttyUSB1
    Maybe needs some additions to provide better control on shutdown and change "printf" messages to STDERR rather than STDOUT

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •