This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pypilot_hat makes 100% cpu load if 'none' LCD configured
#1
Hi

In case if 'none' lcd configured pypilot_hat application consumes 100% CPU.

In class LCD,  function create(self)  gets in dead cycle without sharing CPU time.
To fix problem around line 304 of hat.py  I added sleep(0.1) to let app to share CPU time.

However I do not think we need to run LCD process at all, but simple fix works too.

def create(self):
        def process(pipe, config):
            import lcd
            print('lcd process on', os.getpid())
            self.lcd = lcd.LCD(self.hat.config)
            self.lcd.pipe = pipe

            if self.lcd.use_glut:
                from OpenGL.GLUT import glutMainLoop, glutIdleFunc
                glutIdleFunc(self.lcd.poll)
                glutMainLoop()
            else:
                while True:                     <<<<<<<<<<<<<<<<<<<<<
                    self.lcd.poll()               <<<<<<<<<<<<<<<<<<<<<
                    time.sleep(0.1)           <<<< line I have added to resolve 100% CPU dead loop
           
        super(LCD, self).create(process)
Reply
#2
I will look into this.

Yes the lcd process should not need to run at all in this case. I will look into it.

The pypilot_hat would still process remote controls or io pins for control, but most users who have the pypilot_hat have an lcd attached, which explains why this problem is unusual.

I am curious, what use case is this?
Reply
#3
(2024-07-11, 05:55 PM)seandepagnier Wrote: I will look into this.

Yes the lcd process should not need to run at all in this case.  I will look into it.

    The pypilot_hat would still process remote controls or io pins for control, but most users who have the pypilot_hat have an lcd attached, which explains why this problem is unusual.

I am curious, what use case is this?

I have full scale OP4 system (with LCD, touch e.t.c) but I still want to have physical buttons to control Pypilot in simple way. Looks pypilot_hat is promising to help me with.
Maybe you know better approach?

Actually I want to use only GPIO part of pypilot_hat.

I have other issue, _hat "reserve" almost all GPIOs even if  logically  no sense. For example if no IR sensor connected it still register for GPIO4 and conflict with OP4 GPIO package for W1 interface.
Could you point me on place where hat catching DSPLAY , lircd and other ports. I will likely found, but if you point me it will save a lot of time for me.

I get it work on my setup with RPi5 using rpi-lgpio package instead  python3-rpi.gpio [little tricky to install, but works great]
Reply
#4
I understand what you are doing. There is a ~/.pypilot/hat.conf file.

It should be possible to ensure "pi.ir" is set to "false" to disable lircd, but normally gpio4 is set up for lirc in /boot/config.txt so to avoid using that io pin, you would simply not load the ir overlay there.

The gpio pins to use are set in gpio.py. I can make it possible to avoid using certain pins, perhaps the config should define which pins to use.

Thanks for the feedback.
Reply
#5
Question 
(2024-07-12, 05:45 AM)seandepagnier Wrote: I understand what you are doing.    There is a ~/.pypilot/hat.conf file. 

It should be possible to ensure "pi.ir" is set to "false" to disable lircd, but normally gpio4 is set up for lirc in /boot/config.txt so to avoid using that io pin, you would simply not load the ir overlay there.

The gpio pins to use are set in gpio.py.  I can make it possible to avoid using certain pins, perhaps the config should define which pins to use.

Thanks for the feedback.

Thanks for advice, will put "false" on pi.ir
For the GPIO4 I better like to use gpio 4 for 1W interface in OpenPlotter-GPIO app. I do not see reason for using IR remote in my installation.

>>> The gpio pins to use are set in gpio.py.  I can make it possible to avoid using certain pins, perhaps the config should define which pins to use.

Settings for other GPIO in gpio pi looks like , am i right?
line 54          self.pins = [17, 23, 27, 22, 18, 5, 6, 26]


But how to rid of reserving other pins by pypilot_hat

- keys with switch to ground gpio  (17, 27, 22, 18, 23, 5, 6, 26)   >>> THIS WHAT I WANT TO USE with pypilot_hat
- lirc (4)  >>>>>>>>>>>>>>>>>>>>>>>>>>this looks like I know now, thanks
- imu i2c (2, 3)  >>>>>>>>>>> Used by pypilot  application, not a hat
- uart communication (14, 15)  >>>> Used by pypilot  application, not a hat
- lcd spi (8, 9, 10, 11, 24, 25)  >>> even when screen set "none" ports are reserved to pypilot... How to drop them?
- piezo electric buzzer (12) >>> even when screen set "none" ports are reserved to pypilot... How to drop them?
- arduino mini (7, 9, 10, 11, 27)  >>> even when screen set "none" ports are reserved to pypilot... How to drop them?
Reply
#6
the spi pins are reserved from /boot/config.txt similar to lirc. You would have to disable spi there.

As for the other pins I am not sure how you find an issue. The buzzer has since been offloaded to the arduino.

So in practice none of these pins are reserved for pypilot, only those setup in config.txt and the gpio pins listed
Reply
#7
(2024-07-13, 02:41 PM)seandepagnier Wrote: the spi pins are reserved from /boot/config.txt similar to lirc.  You would have to disable spi there.

As for the other pins I am not sure how you find an issue.  The buzzer has since been offloaded to the arduino.

So in practice none of these pins are reserved for pypilot, only those setup in config.txt and the gpio pins listed
Thanks for your answers, will look deeper.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)