LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-06-2009, 06:53 AM   #1
lwhat
LQ Newbie
 
Registered: Nov 2009
Posts: 15

Rep: Reputation: 0
program with frame buffer


Ubuntu 9.10, I have /dev/fb0.
I try a tutorial c source code, and it works on the
embedded board, and works on the PC in my lab as well,
but on my own PC (Ubuntu 9.10) I met the following problem

fd=open("/dev/fb0",O_RDWR); is OK

ioctl(fd,FBIOGET_VSCREENINFO,&vinfo); always fails
My task is to draw a point or line,
and I know something about frame buffer.

Last edited by lwhat; 11-06-2009 at 07:19 AM.
 
Old 11-06-2009, 08:47 AM   #2
JohnGraham
Member
 
Registered: Oct 2009
Posts: 467

Rep: Reputation: 138Reputation: 138
Quote:
Originally Posted by lwhat View Post
fd=open("/dev/fb0",O_RDWR); is OK

ioctl(fd,FBIOGET_VSCREENINFO,&vinfo); always fails
My task is to draw a point or line,
and I know something about frame buffer.
I don't know much about using the framebuffer in this way, but it'd sure help if you could show the output of perror() when ioctl() fails - just do something like:

Code:
if (ioctl(fd, FBIOGET_VSCREENINFO, &info) < 0)
{
    perror("ioctl on framebuffer");
    exit(1);
}
John G
 
Old 11-06-2009, 11:34 PM   #3
lwhat
LQ Newbie
 
Registered: Nov 2009
Posts: 15

Original Poster
Rep: Reputation: 0
Thanks, and here is the output of perror()


Error reading fixed information.
: Bad file descriptor

Then I added printf("fbfd=%d\n",fbfd);
it returned fbfd=-1;
so open() fails ,
I wondered why open() fails, as I said
I have /dev/fb0, so it lacks the right device driver?

$lsmod|grep fb
vga16fb 12456 0
vgastate 9628 1 vga16fb
fbcon 36640 72
tileblit 2460 1 fbcon
font 8124 1 fbcon
bitblit 5372 1 fbcon
vesafb 5696 1

sorry for my English, this is the first time I post on an English bbs

Last edited by lwhat; 11-06-2009 at 11:46 PM.
 
Old 11-07-2009, 01:04 AM   #4
lwhat
LQ Newbie
 
Registered: Nov 2009
Posts: 15

Original Poster
Rep: Reputation: 0
I change to root, and it works.

$ ls -l /dev/fb0
crw-rw---- 1 root video 29, 0 2009-11-07 21:21 /dev/fb0
 
Old 11-08-2009, 05:32 AM   #5
JohnGraham
Member
 
Registered: Oct 2009
Posts: 467

Rep: Reputation: 138Reputation: 138
Quote:
Originally Posted by lwhat View Post
fd=open("/dev/fb0",O_RDWR); is OK
Quote:
Originally Posted by lwhat View Post
Then I added printf("fbfd=%d\n",fbfd);
it returned fbfd=-1;
so open() fails
You always, always need to check the return value of any function you call - now that you can run the program as root you might get away with it, but put a check in for the return value of the open() command, or later on you might get led up another garden path.

On another note, you can still open the file if you add yourself to the group 'video' by placing your name on the 'video' line of /etc/group. For example, to add myself to 'video' on my system, the following line:

Code:
video:x:44:
should be changed to:

Code:
video:x:44:john
you can then make sure you're in that group by running the command 'groups', which will show you all the groups you're in.

This is a much, much safer option than running your program as root, lest you do any permanent damage to your system.

John G
 
Old 11-10-2009, 01:27 AM   #6
lwhat
LQ Newbie
 
Registered: Nov 2009
Posts: 15

Original Poster
Rep: Reputation: 0
Thanks a lot.
Now I can draw a point, a line and a circle both on the arm board in my lab and on my own computer.
That afternoon I added myself to video group but still failed, so I turned to use sudo .
Today I ran the program without root and succeeded.
And by running the command 'groups', I see 'video'.
I add a new user ,lwhat, and add him to video group, and run 'groups', I cannot see video.
Then I log off and login ,and lwhat is in the group video and of course is able to run the frame buffer program.
I guess I should exit and login to allow the changes to happen.
 
Old 03-10-2010, 08:18 AM   #7
richman1234
LQ Newbie
 
Registered: Mar 2010
Distribution: Fedora12 & Angstrom
Posts: 22

Rep: Reputation: 0
This is exactly what I want to do. Iwhat, can you provide some more information on how you drew a point, line and circle on the arm and PC?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
frame buffer screenshot cold Linux - Desktop 3 03-20-2007 03:44 PM
about frame buffer yugandhar Linux - Kernel 2 06-03-2006 05:07 PM
Frame Buffer problem sureshraju Programming 0 06-29-2005 08:14 AM
Frame buffer bkeating Linux - Newbie 6 04-22-2003 06:09 PM
lilo (frame buffer maybe??) watashiwaotaku7 Linux - Software 6 03-10-2003 04:25 PM


All times are GMT -5. The time now is 11:38 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration