4

I have a raspberry pi, connected to HDMI monitor.

I am trying to run a simple gui (created in qt), and I'm using mpi library for interprocess communication. I want to get this application working on raspberry pi, and on my laptop using something like this

$ mpiexec -f machinefile -n 2 ./mpi_gui

where the machinefile contains the ip addresses for my pi, and for the laptop.

I am following this tutorial. The thing is that this communication is over ssh and I get an "cannot connect to x server" error. I tried

$ mpiexec -enable-x -f machinefile -n 2 ./mpi_gui

to get the raspberry pi gui on my laptop, and it works ok.

Is it possible to run the gui of the raspberry pi on the hdmi monitor to which is connected?

Later edit:

I don't know if I explained well what I want to obtain. I want the process running on the raspberry pi to put the gui on the HDMI monitor connected to it. And the process running on my laptop, to output the gui on the laptop's monitor.

But I can't see how this can be achieved.

1) Using ssh to connect to pi, I enter the command:

sh-4.2$ ssh pi@192.168.1.186
pi@192.168.1.186's password: 
pi@raspberrypi ~/mpi_testing/mpi_with_gui/mpi_with_gui/mpi_gui $ DISPLAY=:0 mpiexec -n 2 ./mpi_gui
Greetings from process 0 of 2!
Greetings from process 1 of 2!

This starts both processes on the raspberry, both gui's are displayed on the hdmi monitor connected to pi. (not what I want)

2) I run on my laptop the command bellow:

sh-4.2$ mpiexec -n 2 ./mpi_gui
Greetings from process 0 of 2!
Greetings from process 1 of 2!

Both processes are running on my laptop, as expected, I got those 2 gui's on the laptop's display. (still, not what I want)

3) I run from my laptop the command below:

sh-4.2$ DISPLAY=:0 mpiexec -f machinefile -n 2 ./mpi_gui
pi@192.168.1.186's password: 
mpi_gui: cannot connect to X server

It would be nice to start the laptop process with the gui displayed on the laptop's screen, and the raspberry pi process with the gui displayed on its hdmi screen. Though, there should be a way to tell mpiexec that each process should use it's own X server (or is this ssh job?)

Ghanima
  • 15,837
  • 15
  • 61
  • 119
Adrian
  • 75
  • 1
  • 2
  • 6
  • 2
    try prepending your command like this DISPLAY=:0 mpiexec ... – Krzysztof Adamski Apr 02 '13 at 18:05
  • still got cannot connect to X server – Adrian Apr 03 '13 at 07:33
  • And X server is started on your RasbperryPi? – Krzysztof Adamski Apr 03 '13 at 07:36
  • Yes, it is. I will try to run the application, but this time from the raspberry pi (i tried the above commands from my laptop). – Adrian Apr 03 '13 at 07:42
  • Could you please paste the whole commandline that you are using and all the error messages you get? – Krzysztof Adamski Apr 03 '13 at 07:56
  • Here is the output from the command i enter: sh-4.2$ DISPLAY=:0 mpiexec -f machinefile -n 2 ./mpi_gui pi@192.168.1.186's password: mpi_gui: cannot connect to X server – Adrian Apr 03 '13 at 08:03
  • You may try adding -x DISPLAY=:0 to your mpiexec command instead of prepeding it with environment variable definition. – Krzysztof Adamski Apr 03 '13 at 08:12
  • I tried with this, still can't get it working. sh-4.2$ mpiexec -f machinefile -n 2 ./mpi_gui -display 192.168.1.181:0.0 pi@192.168.1.181's password: mpi_gui: cannot connect to X server 192.168.1.181:0.0 . I can assure you that x server is started on the rpi. Anyway, i don't think that i need mpi for my app (a server-client should do it), but it would have been a nice exercise using mpi. – Adrian Apr 03 '13 at 09:15
  • Entering your command results in comments is not a good idea, they are hard to read. Pasting them in the question itself is better. The last thing that may be related is X.org security model. You could try running xhost + on raspberrypi (from some X terminal). – Krzysztof Adamski Apr 03 '13 at 09:49

1 Answers1

5

First of all, you should be able to access your Pi via its hostname, like raspberrypi.local. Second, you should make an entry in your .ssh/config file for the Pi:

Host raspberrypi
   User pi
   Hostname raspberrypi.local
   Compression yes
   ForwardX11 yes

This will enable X11 forwarding for the host with hostname raspberrypi.local (replace with IP if you like). It also enables compression, which is a good idea for X11. You could also specify an RSA key here for authentication, so you don't have to type a password.

Edit: To actually don't have the X11 connection forwarded, but to instead use the local X server, you can do the following: First, you have to run xhost +local: on your Raspberry Pi (not via ssh). Second, you have to set the display variable for your remote command to DISPLAY=:0 you can test this by running ssh interactively:

ssh pi@raspberrypi.local 'DISPLAY=:0 name-of-program-to-run'
Arne
  • 2,226
  • 2
  • 18
  • 35