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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
11-06-2009, 06:53 AM
|
#1
|
|
LQ Newbie
Registered: Nov 2009
Posts: 15
Rep:
|
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.
|
|
|
|
11-06-2009, 08:47 AM
|
#2
|
|
Member
Registered: Oct 2009
Posts: 451
Rep: 
|
Quote:
Originally Posted by lwhat
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
|
|
|
|
11-06-2009, 11:34 PM
|
#3
|
|
LQ Newbie
Registered: Nov 2009
Posts: 15
Original Poster
Rep:
|
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.
|
|
|
|
11-07-2009, 01:04 AM
|
#4
|
|
LQ Newbie
Registered: Nov 2009
Posts: 15
Original Poster
Rep:
|
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
|
|
|
|
11-08-2009, 05:32 AM
|
#5
|
|
Member
Registered: Oct 2009
Posts: 451
Rep: 
|
Quote:
Originally Posted by lwhat
fd=open("/dev/fb0",O_RDWR); is OK
|
Quote:
Originally Posted by lwhat
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:
should be changed to:
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
|
|
|
|
11-10-2009, 01:27 AM
|
#6
|
|
LQ Newbie
Registered: Nov 2009
Posts: 15
Original Poster
Rep:
|
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.
|
|
|
|
03-10-2010, 08:18 AM
|
#7
|
|
LQ Newbie
Registered: Mar 2010
Distribution: Fedora12 & Angstrom
Posts: 21
Rep:
|
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?
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 10:42 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|