Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot run with only example data on Raspberry Pi 3 #44

Closed
razgr1z912 opened this issue Feb 17, 2023 · 8 comments
Closed

Cannot run with only example data on Raspberry Pi 3 #44

razgr1z912 opened this issue Feb 17, 2023 · 8 comments

Comments

@razgr1z912
Copy link

I have set it up using the instructions in TronView/docs/rpi_setup.md.

I have two issues that prevent me from running the application with the example data. When I run the main.py file, the screen shows the example display correctly, but it is a static image as the python file hits an exception and does not continue to run.

(1) During setup.sh, when trying to install python-pygame and python-serial, they are not available. See below:

Errors installing python-pygame and python-serial:
pi@raspberrypi:~/efis_to_hud $ util/rpi/setup.sh
Setup Pi for running HUD software? (y or n)
 y
Enabling serial port
disable splash image
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package python-pygame is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

Package python-serial is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'python-serial' has no installation candidate
E: Package 'python-pygame' has no installation candidate
E: Unable to locate package python-pyaudio

(2) When trying to run main.py with example data, I get an exception in Thread-1.

pi@raspberrypi:~/efis_to_hud $ sudo python main.py -i serial_d100 -e
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
Creating DataRecorder dir: /flightlog/
armv7l
Running on RaspberryPi
Input data module 0: serial_d100
armv7l
Opening Logfile: lib/inputs/_example_data/dynon_d100_data1.txt
speed distance format: mph 
temperature format: C 
Loading screen module: Default
pygame-menu 4.3.6
No protocol specified
No protocol specified
sys.platform:linux
platform.machine:armv7l
default to XDisplay :10.0
Init Screen: Default 1920x1080
Init Mod: ArtificalHorz 1920x1080
Init Mod: Horizon 1920x1080
HUD x degree_per_pixel: 0.006771
Init Mod: HUD AOA 120x1070
Init Mod: Slip Skid 250x50
Init Mod: Menu 400x300
Init Mod: Traffic Scope 400x400
SmartDisplay drawable offset: 0,0 to 1920,1080
SmartDisplay New screen width/height: 1920,1080
SmartDisplay center x/y: 960,540
SmartDisplay real center x/y: 960,540
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner
    self.run()
  File "/home/pi/efis_to_hud/main.py", line 52, in run
    shared.aircraft = shared.CurrentInput.readMessage(shared.aircraft)
  File "/home/pi/efis_to_hud/lib/inputs/serial_d100.py", line 108, in readMessage
    self.ser.flushInput()  # flush the serial after every message else we see delays
AttributeError: '_io.TextIOWrapper' object has no attribute 'flushInput'

This was all being done on a fresh install of Raspberry Pi OS (32 bit), kernel 5.15, debian version 11.

Any help would be great! I would love to get this up and running to pull EFIS and EMS data from my Dynon D100 series device in real time.

@TopherTimeMachine
Copy link
Collaborator

hey @razgr1z912 looks like the setup.sh script is using apt-get to install those python packages. And maybe they are no longer in the apt-get repos.

You might try installing those packages using pip3? try running these from the command line.

sudo pip3 install pyserial
sudo pip3 install pygame
sudo pip3 install pyaudio

Also not sure if the script stopping after failing, but after that it trys to install a few more things.

sudo pip3 install pygame_menu
sudo pip3 install geographiclib
sudo apt install libsdl2-ttf-2.0-0

@TopherTimeMachine
Copy link
Collaborator

@razgr1z912 hmmmm... pyserial may be the wrong package.. if that doesn't work try removing that package and running.

sudo pip3 install serial

@razgr1z912
Copy link
Author

Sorry if I am a bit lost. All of my programming experience is in Java, VB.NET, and PHP. Not used to Python or the Raspberry Pi. The only package it needed to install using those commands was pyaudio. The error now is a bit different.

pi@raspberrypi:~ $ sudo pip3 install pyserial
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: pyserial in /usr/lib/python3/dist-packages (3.5b0)
pi@raspberrypi:~ $ sudo pip3 install pygame
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: pygame in /usr/lib/python3/dist-packages (1.9.6)
pi@raspberrypi:~ $ sudo pip3 install pyaudio
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting pyaudio
  Downloading https://www.piwheels.org/simple/pyaudio/PyAudio-0.2.13-cp39-cp39-linux_armv7l.whl (56 kB)
     |████████████████████████████████| 56 kB 252 kB/s 
Installing collected packages: pyaudio
Successfully installed pyaudio-0.2.13
pi@raspberrypi:~ $ sudo pip3 install serial
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting serial
  Downloading https://www.piwheels.org/simple/serial/serial-0.0.97-py2.py3-none-any.whl (40 kB)
     |████████████████████████████████| 40 kB 270 kB/s 
Collecting iso8601>=0.1.12
  Downloading https://www.piwheels.org/simple/iso8601/iso8601-1.1.0-py3-none-any.whl (9.9 kB)
Requirement already satisfied: future>=0.17.1 in /usr/lib/python3/dist-packages (from serial) (0.18.2)
Requirement already satisfied: pyyaml>=3.13 in /usr/lib/python3/dist-packages (from serial) (5.3.1)
Installing collected packages: iso8601, serial
Successfully installed iso8601-1.1.0 serial-0.0.97
pi@raspberrypi:~ $ sudo pip3 install pygame_menu
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: pygame_menu in /usr/local/lib/python3.9/dist-packages (4.3.6)
Requirement already satisfied: typing-extensions in /usr/lib/python3/dist-packages (from pygame_menu) (3.7.4.3)
Requirement already satisfied: pyperclip in /usr/local/lib/python3.9/dist-packages (from pygame_menu) (1.8.2)
Requirement already satisfied: pygame>=1.9.3 in /usr/lib/python3/dist-packages (from pygame_menu) (1.9.6)
pi@raspberrypi:~ $ sudo pip3 install geographiclib
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: geographiclib in /usr/local/lib/python3.9/dist-packages (2.0)
pi@raspberrypi:~ $ sudo apt install libsdl2-ttf-2.0-0
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
libsdl2-ttf-2.0-0 is already the newest version (2.0.15+dfsg1-1).
The following package was automatically installed and is no longer required:
  raspinfo
Use 'sudo apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
pi@raspberrypi:~ $ cd TronView
pi@raspberrypi:~/TronView $ sudo python main.py -i serial_d100 -e
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
armv7l
Running on RaspberryPi
Input data module 0: serial_d100
armv7l
Opening Logfile: lib/inputs/_example_data/dynon_d100_data1.txt
speed distance format: mph 
temperature format: C 
Loading screen module: Default
pygame-menu 4.3.6
No protocol specified
No protocol specified
sys.platform:linux
platform.machine:armv7l
default to XDisplay :10.0
Init Screen: Default 1920x1080
Init Mod: ArtificalHorz 1920x1080
Init Mod: Horizon 1920x1080
HUD x degree_per_pixel: 0.006771
Init Mod: HUD AOA 120x1070
Init Mod: Slip Skid 250x50
Init Mod: Menu 400x300
Init Mod: Traffic Scope 400x400
SmartDisplay drawable offset: 0,0 to 1920,1080
SmartDisplay New screen width/height: 1920,1080
SmartDisplay center x/y: 960,540
SmartDisplay real center x/y: 960,540
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/home/pi/TronView/lib/inputs/serial_d100.py", line 108, in readMessage
    self.ser.flushInput()  # flush the serial after every message else we see delays
AttributeError: '_io.TextIOWrapper' object has no attribute 'flushInput'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner
    self.run()
  File "/home/pi/TronView/main.py", line 52, in run
    shared.aircraft = shared.CurrentInput.readMessage(shared.aircraft)
  File "/home/pi/TronView/lib/inputs/serial_d100.py", line 124, in readMessage
    except serial.serialutil.SerialException:
AttributeError: module 'serial' has no attribute 'serialutil'

Could any packages be conflicting with each other? Right now I just have installed as many packages as possible and have not removed any packages.

@TopherTimeMachine
Copy link
Collaborator

@razgr1z912 ok. Looks like its the wrong python serial library. It's trying to use flushInput() method but that isn't found.

Looking around I see
https://pyserial.readthedocs.io/en/latest/pyserial_api.html

Looks like they renamed the method.
reset_input_buffer() Changed in version 3.0: renamed from flushInput()

Looks like you are using a different version of the python library? Probably a newer better one then we are using because I haven't tried installing it in a while :)

Do you know how to branch and create a Pull Request in GitHub? If you want to update the code and submit it.

@razgr1z912
Copy link
Author

It still is throwing an error with reset_input_buffer() instead of the depricated flushInput().

Interestingly, the G3X example works perfectly and has that flushInput() line commented out. I commented out both times that was being called and now the example seems to work. I am not sure if it will affect the accuracy of the serial data or not, but it seems to be working with just those two lines commented out. I have not used GitHub much but if that is an acceptable solution, I can try to update that file.

@TopherTimeMachine
Copy link
Collaborator

ok. I'll have to look into that more. We may not need the flush input methods anymore.

@hpmicrowave
Copy link
Collaborator

hpmicrowave commented Feb 18, 2023 via email

@brightproject
Copy link

brightproject commented Apr 18, 2024

Hello @TopherTimeMachine
I'm running the script on a PC in Windows 10.
For me, command:
python3 main.py -i serial_d100 -e
Gives next result:

pygame 2.5.2 (SDL 2.28.3, Python 3.11.4)
Hello from the pygame community. https://www.pygame.org/contribute.html
AMD64
Input data module 0: serial_d100
AMD64
Opening Logfile: lib/inputs/_example_data/dynon_d100_data1.txt
speed distance format: mph
temperature format: C
Loading screen module: Default
pygame-menu 4.4.3
sys.platform:win32
platform.machine:AMD64
Init Screen: Default 2560x1440
Init Mod: ArtificalHorz 2560x1440
Init Mod: Horizon 2560x1440
HUD x degree_per_pixel: 0.005078
Init Mod: HUD AOA 120x1430
Init Mod: Slip Skid 250x50
Init Mod: Menu 400x300
Init Mod: Traffic Scope 400x400
SmartDisplay drawable offset: 0,0 to 2560,1440
SmartDisplay New screen width/height: 2560,1440
SmartDisplay center x/y: 1280,720
SmartDisplay real center x/y: 1280,720
Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1264.0_x64__qbz5n2kfra8p0\Lib\threading.py", line 1038, in _bootstrap_inner
    self.run()
  File "G:\Need_Projects\HUD_SynteticVision\TronView_HUD\main.py", line 52, in run
    shared.aircraft = shared.CurrentInput.readMessage(shared.aircraft)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "G:\Need_Projects\HUD_SynteticVision\TronView_HUD\lib\inputs\serial_d100.py", line 108, in readMessage
    self.ser.flushInput()  # flush the serial after every message else we see delays
    ^^^^^^^^^^^^^^^^^^^
AttributeError: '_io.TextIOWrapper' object has no attribute 'flushInput'

The image appears in full screen.
Start_yes_no
As far as I understand, I'm running DEMO mode and it should take data from the file and display it on the screen, but it doesn't.
When you press the T on keyboard, the image window closes and an empty terminal appears.
Terminal_empty
Pressing any key does this.
Terminal_exit
Command:
python3 main.py --in1 serial_mgl --playfile1 stratux_1.dat
Gives next result:

pygame 2.5.2 (SDL 2.28.3, Python 3.11.4)
Hello from the pygame community. https://www.pygame.org/contribute.html
Input1 playing log file: stratux_1.dat
AMD64
Input data module 0: serial_mgl
AMD64
Opening Logfile: lib/inputs/_example_data/stratux_1.dat
speed distance format: mph
temperature format: C
Loading screen module: Default
pygame-menu 4.4.3
sys.platform:win32
platform.machine:AMD64
Init Screen: Default 2560x1440
Init Mod: ArtificalHorz 2560x1440
Init Mod: Horizon 2560x1440
HUD x degree_per_pixel: 0.005078
Init Mod: HUD AOA 120x1430
Init Mod: Slip Skid 250x50
Init Mod: Menu 400x300
Init Mod: Traffic Scope 400x400
SmartDisplay drawable offset: 0,0 to 2560,1440
SmartDisplay New screen width/height: 2560,1440
SmartDisplay center x/y: 1280,720
SmartDisplay real center x/y: 1280,720
MGL file reset
MGL file reset
MGL file reset
MGL file reset
MGL file reset
MGL file reset
MGL file reset
MGL file reset
MGL file reset
Traceback (most recent call last):
  File "G:\Need_Projects\HUD_SynteticVision\TronView_HUD\main.py", line 235, in <module>
    graphic_mode.main_graphical()  # start main graphical loop
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "G:\Need_Projects\HUD_SynteticVision\TronView_HUD\lib\common\graphic\graphic_mode.py", line 98, in main_graphical
    shared.aircraft.traffic.dropTargetBuoy(shared.aircraft,speed=-1, direction="ahead")
  File "G:\Need_Projects\HUD_SynteticVision\TronView_HUD\lib\aircraft.py", line 466, in dropTargetBuoy
    solve = Geodesic.WGS84.Direct(aircraft.gps.LatDeg,aircraft.gps.LonDeg,aircraft.mag_head,distance)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\admin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\geographiclib\geodesic.py", line 1082, in Direct
    a12, lat2, lon2, azi2, s12, m12, M12, M21, S12 = self._GenDirect(
                                                     ^^^^^^^^^^^^^^^^
  File "C:\Users\admin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\geographiclib\geodesic.py", line 1060, in _GenDirect
    line = GeodesicLine(self, lat1, lon1, azi1, outmask)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\admin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\geographiclib\geodesicline.py", line 99, in __init__
    self.lat1 = Math.LatFix(lat1)
                ^^^^^^^^^^^^^^^^^
  File "C:\Users\admin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\geographiclib\geomath.py", line 105, in LatFix
    return math.nan if abs(x) > 90 else x
                       ^^^^^^
TypeError: bad operand type for abs(): 'NoneType'
MGL file reset

Stratux1
Stratux2
You can switch between screens with the mouse wheel or the H key.
Am I working wrong with the script or is it a matter of the python version or the modules and code?
P.S.
I slightly changed the example script, according to the documentation
At first I tried to substitute it as advised above

# self.ser.flushInput()  # flush the serial after every message else we see delays
self.ser.reset_input_buffer()  # flush the serial after every message else we see delays

But there was a similar error in the console

line 109, in readMessage
     self.ser.reset_input_buffer() # flush the serial after every message else we see delays
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: '_io.TextIOWrapper' object has no attribute 'reset_input_buffer'

Then I wrote a replacement like this
self.ser.flush()
And the example came to life and became

Alive_Tron.mp4

But text mode
python3 main.py --in1 serial_d100 -e -t
Still doesn't work and the screen is blank...
All that remains is to figure out how to fix the text log output.
Otherwise the playback seems to be working without errors.

python3 main.py --in1 serial_mgl -e

MGL_demo.mp4
pygame 2.5.2 (SDL 2.28.3, Python 3.11.4)
Hello from the pygame community. https://www.pygame.org/contribute.html
AMD64
Input data module 0: serial_mgl
AMD64
Opening Logfile: lib/inputs/_example_data/MGL_Flight1.bin
speed distance format: mph
temperature format: C
Loading screen module: Default
pygame-menu 4.4.3
sys.platform:win32
platform.machine:AMD64
Init Screen: Default 2560x1440
Init Mod: ArtificalHorz 2560x1440
Init Mod: Horizon 2560x1440
HUD x degree_per_pixel: 0.005078
Init Mod: HUD AOA 120x1430
Init Mod: Slip Skid 250x50
Init Mod: Menu 400x300
Init Mod: Traffic Scope 400x400
SmartDisplay drawable offset: 0,0 to 2560,1440
SmartDisplay New screen width/height: 2560,1440
SmartDisplay center x/y: 1280,720
SmartDisplay real center x/y: 1280,720
fastForward->mgl
fastForward->mgl
fastBackwards->mgl
fastBackwards->mgl
fastForward->mgl
fastForward->mgl
fastForward->mgl
Playback Paused!
Plaback resumed.
fastForward->mgl
fastBackwards->mgl
fastForward->mgl
fastForward->mgl
fastForward->mgl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants