LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-30-2009, 09:08 AM   #1
payu21
LQ Newbie
 
Registered: Apr 2009
Location: australia
Posts: 12

Rep: Reputation: 0
Do i need integer to hex conversion, if yes how???


hie all,

-------------------------------------------------
void Clear_ControlPort_bit(int a)

{
int t;
printf("a=%i\n",a);

if(a<8)

{

if(a==0||a==1||a==3)
{
printf("reading controlport\n");
printf("identifier = %d \n",_BV(a));
printf("p = %d \n",p);
a = p|_BV(a);

/* not going to read loop but taking p value*/
printf("a=%i\n",a);

Write_ControlPort(a);


}
//else

//Write_ControlPort(t&~_BV(a));

}
return;

-----------------------------------------------------------------*/

void Write_ControlPort(int a)

{
printf("writing to port\n");
outb(a,ControlPort);
return;

}
------------------------
Do i need to convert the value of a to hex before writing to control port??? Because its showing a segmentation fault at "outb"

please help me
 
Old 04-30-2009, 09:30 AM   #2
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
How about a little context of what you are trying to do?

I don't know what weird device you might be trying to control, so I'm a tiny bit short of 100% certain no form of conversion to hex is required before writing to its port. (That answers your explicit question).

Linux is a protected OS, so ordinary code can't ordinarily write to ports. So that is probably the source of the fault.

If you have done something to make writing to that port valid, that should have been part of the context you should have provided for your question.

If you haven't done anything to make writing to that port valid, here is the first link I found just now googling the topic:
http://www.faqs.org/docs/Linux-mini/...ing.html#ss2.1
It seems to be a good explanation of the basics.

Last edited by johnsfine; 04-30-2009 at 09:35 AM.
 
  


Reply



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
[bash] ASCII to HEX and hex to ascii ////// Programming 17 05-08-2018 09:55 PM
Hex output of a hex/ascii input string mlewis Programming 35 04-10-2008 12:05 PM
C++ string to integer conversion fatman Programming 6 06-18-2006 08:17 AM
Hex socks Linux - General 4 02-17-2005 12:05 PM
hex? Nox Solaris Linux - Newbie 3 12-07-2002 08:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:06 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration