User avatar
mad-hatter
Posts: 419
Joined: Sun Feb 26, 2012 2:58 pm
Location: By the UK seaside

Qt4/C++ Access /dev/mem using tightvnc from Windows 7

Tue Jun 03, 2014 12:24 pm

Hello,

I've written a proram in 'C++' that accesses /dev/mem, the program works fine when run directly
on the Pi, either as root or with sudo.
I'm trying to run the program from my Windows 7 PC. When using tightvnc I get the following errors,
either as root or with sudo:-

Code: Select all

[email protected]:/home/pi# ./myprog
  X Error: BadAccess (attempt to access private resource denied) 10
  Extension:    129 (MIT-SHM)
  Minor opcode: 1 (X_ShmAttach)
  Resource id:  0x2c00001
X Error: BadShmSeg (invalid shared segment parameter) 128
  Extension:    129 (MIT-SHM)
  Minor opcode: 5 (X_ShmCreatePixmap)
  Resource id:  0x2c0000a
X Error: BadDrawable (invalid Pixmap or Window parameter) 9
  Major opcode: 62 (X_CopyArea)
  Resource id:  0x2c0000b
X Error: BadDrawable (invalid Pixmap or Window parameter) 9
  Major opcode: 62 (X_CopyArea)
  Resource id:  0x2c0000b
* this last section repeats about 20 times
I've tried, with no luck:-
sudo chown root myprog
sudo chmod 4755 myprog

sudo chown 0:0 myprog
sudo chmod u+s myprog

If I connect to the Pi with MobaXterm using RDP and connect to my Pi's root account,
it works fine, but not if I connect to a user account and use sudo or a root terminal.

I have been advised to run a daemon on the pi and talk to that (I don't know how to do that).
Is there any thing else I can do to get the progam running from my Winows 7 PC with tightvnc?

Regards

User avatar
AndyD
Posts: 2333
Joined: Sat Jan 21, 2012 8:13 am
Location: Melbourne, Australia
Contact: Website

Re: Qt4/C++ Access /dev/mem using tightvnc from Windows 7

Wed Jun 04, 2014 5:18 am

You could try using gksudo rather than sudo. You will need to install it

Code: Select all

sudo apt-get install gksu

User avatar
mad-hatter
Posts: 419
Joined: Sun Feb 26, 2012 2:58 pm
Location: By the UK seaside

Re: Qt4/C++ Access /dev/mem using tightvnc from Windows 7

Wed Jun 04, 2014 9:12 am

Hello AndyD,

I tried 'gksu' and get:-

Code: Select all

[email protected] ~/qt4/test $ gksu ./myprog
Xlib:  extension "RANDR" missing on display ":1.0".
[email protected] ~/qt4/test $
an empty window displays.

Regards

User avatar
AndyD
Posts: 2333
Joined: Sat Jan 21, 2012 8:13 am
Location: Melbourne, Australia
Contact: Website

Re: Qt4/C++ Access /dev/mem using tightvnc from Windows 7

Wed Jun 04, 2014 10:34 am

From a quick google. This may help.

User avatar
mad-hatter
Posts: 419
Joined: Sun Feb 26, 2012 2:58 pm
Location: By the UK seaside

Re: Qt4/C++ Access /dev/mem using tightvnc from Windows 7

Sun Jun 08, 2014 10:14 pm

Hello AndyD,

Thanks for the link, It might help if I understood what it all meant.
I've decided to use Windows 7 'Remote Desktop Connection' and/or 'MobaXterm' (RDP)
and log in as root. They both seem to work fine. The windows RDP seems to have the edge
on performance.

Regards

halhertani
Posts: 40
Joined: Sun Aug 19, 2012 5:02 am
Location: Ottawa, ON Canada
Contact: Website

Re: Qt4/C++ Access /dev/mem using tightvnc from Windows 7

Mon Aug 04, 2014 4:33 am

Mad-hatter,
There is a bug that causes this error whenever one attempts to run a Qt4 application as root over VNC. I was able to fix it by typing "export QT_X11_NO_MITSHM=1" into the RPi's terminal before starting the Qt4 app (from within the same terminal).
Alternatively you can type "export QT_GRAPHICSSYSTEM=native".

The first one worked in my case http://hertaville.com/2014/07/31/qt4gpio/. If you will be running Qt4 apps over VNC regularly you might want to add these (or at least the first one) to your .bashrc.

For more info on this bug check:

User avatar
mad-hatter
Posts: 419
Joined: Sun Feb 26, 2012 2:58 pm
Location: By the UK seaside

Re: Qt4/C++ Access /dev/mem using tightvnc from Windows 7

Mon Aug 04, 2014 10:37 am

Hello halhertani,
"export QT_X11_NO_MITSHM=1"
Thanks for that, works a treat.

Regards

Return to “C/C++”