Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
basic c program implementation to get driver working
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
archieb7
n00b
n00b


Joined: 09 Jul 2007
Posts: 7

PostPosted: Fri Nov 02, 2007 2:15 am    Post subject: basic c program implementation to get driver working Reply with quote

Hello.

I'm having a problem starting a driver for a SpacePilot 3d motion controller.

According to the following link, this basic c program fixes the bug in other distros:

http://www.3dconnexion.com/forum/viewtopic.php?t=1039

Code:
#include <stdio>
#include <string>
#include <stdlib>
#include <utmpx>

int
main(int argc, char ** argv) {
  if (argc != 2) {
    fprintf(stderr, "Need a name to put in the structure\n");
    exit(1);
  }
  struct utmpx u;
  memset(&u, 0, sizeof(u));
  u.ut_type = USER_PROCESS;
  u.ut_pid = getpid();
  strcpy(u.ut_id, ":0");
  strcpy(u.ut_line, ":0");
  strcpy(u.ut_user, argv[1]);
  setutxent();
  pututxline(&u);
  endutxent();
}


I'm new to linux and not sure how to compile and run this properly.

I tried just:

Code:
gcc script3d.c
where script3d.c is the source file

the output file is a.out and when I run this from the same directory it exits and prints "need a name to put in structure" so its not doing what i need it to do.

Any suggestions on how I can implement this so I can start my driver? Thanks for your help!
Back to top
View user's profile Send private message
Genone
Retired Dev
Retired Dev


Joined: 14 Mar 2003
Posts: 9237
Location: beyond the rim

PostPosted: Fri Nov 02, 2007 4:19 am    Post subject: Reply with quote

It seems that you have to call it with your username as first argument.
Back to top
View user's profile Send private message
archieb7
n00b
n00b


Joined: 09 Jul 2007
Posts: 7

PostPosted: Fri Nov 02, 2007 4:45 am    Post subject: Reply with quote

Hey thanks Genone! My device works now.

Wow, such a simple answer too. I just wasn't sure how to pass an argument to an executable in linux; I'm still really new to it.

Code:
./a.out root
works, thanks again!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum