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

    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
    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
    Last edited by bpa; 2022-01-22, 20:34. Reason: typos and attribute source of prog.

    Comment


      #3
      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.

      Comment


        #4
        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:
        [email protected]:~$ 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

        Comment


          #5
          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.

          Comment


            #6
            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
            Attached Files
            Last edited by bpa; 2022-01-23, 10:58.

            Comment


              #7
              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:
              [email protected]:~$ 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 [email protected]:root/

              [email protected]'s password:

              It's not raspberry not piCore...

              Comment


                #8
                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

                Comment


                  #9
                  Originally posted by PaulH View Post
                  With the new file:
                  [email protected]:~$ 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 [email protected]:root/

                  [email protected]'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.

                  Comment


                    #10
                    Assuming you can build a simple C program on PCP - example of a simple telnet program which will do similar to socat / netcat

                    SimpleTelnet is a small telnet client suitable for embedded systems. Implemented in C, it works on any POSIX platform. The project is released under GPL version 2 license. News October 2013, versio…

                    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

                    Comment


                      #11
                      Sorry bpa, I'm fully lost!

                      Should I download pyserial. If yes how ?

                      I tried:
                      nc 192.168.1.120 9090 </dev/ttyUSB1 >/dev/ttyUSB1
                      -sh: can't open /dev/ttyUSB1: no such file

                      probably the USB name is not the same. How to get the right name?

                      Sorry for the basic questions... Thanks!

                      Comment


                        #12
                        Usb serial drivers are not included in pCP by default.

                        Install the extension usb-serial-KERNEL.tcz. Where kernel matches the kernel you are running.
                        piCorePlayer a small player for the Raspberry Pi in RAM.
                        Homepage: https://www.picoreplayer.org

                        Please donate if you like the piCorePlayer

                        Comment


                          #13
                          Originally posted by PaulH View Post
                          Sorry bpa, I'm fully lost!

                          Should I download pyserial. If yes how ?
                          No.
                          Try the simpler suggestion first.


                          I tried:
                          nc 192.168.1.120 9090 </dev/ttyUSB1 >/dev/ttyUSB1
                          -sh: can't open /dev/ttyUSB1: no such file

                          probably the USB name is not the same. How to get the right name?

                          Sorry for the basic questions... Thanks!
                          Get back to basics.

                          In the thread you started - you asked about Raspi and UART https://forums.slimdevices.com/showt...=1#post1043487

                          There are two choices
                          (i) use Pi some GPIO as serial (https://forums.raspberrypi.com/viewtopic.php?t=17360 )
                          or
                          (ii) use a USB serial adaptor.

                          I stated all examples I give are tested on Ubuntu.
                          I can't help you about serial port on PCP except for the general advice about USB serial port. I don't know if GPIO serial works under PCP nor how it can be setup.

                          You need to get a serial port setup and working under PCP before you trying any of the solutions I suggested.

                          Comment


                            #14
                            Originally posted by bpa View Post
                            N

                            There are two choices
                            (i) use Pi some GPIO as serial (https://forums.raspberrypi.com/viewtopic.php?t=17360 )
                            or
                            (ii) use a USB serial adaptor.
                            it seems more logical using the embedded GPIO TxD/RxD instead of a USB-Serial adapter; no ?

                            Comment


                              #15
                              Originally posted by PaulH View Post
                              it seems more logical using the embedded GPIO TxD/RxD instead of a USB-Serial adapter; no ?
                              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.

                              Comment

                              Working...
                              X