[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] newbee med adresse problemer



Mads Bondo Dydensborg wrote:
> 
> On Wed, 22 May 2002, thomas jensen wrote:
> 
> >
> >
> > hej jeg er ved at lave et i/o kort til isa slot
> > men kan ikke få c programmet til at adressere det??
> > har prøvet med denne manual
> > http://www.tldp.org/HOWTO/mini/IO-Port-Programming-1.html
> > men jeg syntes ikke det virker
> > systemet skriver : segmentasion fault (core dump)
> > jeg har lavet programmet sådanne her:
> >
> > #define extern static
> > #include<asm/io.h>
> > #include<asm/unistd.h>
> > #undef extern
> > char hent;                        //variabler
> > int main()
> > {
> > ioperm(0x280,4,1);         //klargøring af port
> 
> Fra man siden:
> RETURN VALUE
>        On success, zero is returned.  On error, -1 is returned, and errno
> is set appropriately.
> 
> Så,
> #include <stdio.h>
> #include <errno.h>
> if (ioperm(0x280, 4, 1)) {
>   perror("Argh, jeg er nok ikke root!\n");
> }
> 
> > hent=inb(280);                //her hentes indholdet af port 280 til hent
> > printf("%d",hent);            //her skrives indholdet af hent
> > getchar();
> > return 0;
> > }
> >
> > jeg har også prøvet vor jeg ville skrive til porten og resultat blev det
> > samme
> 
> inb og venner kræver at du bruger -O for at oversætte (måske endda -O2).
> Hvordan oversatte du dit program?

Jeg ville nok også overveje seriøst at anvende en variabel til
port-adressen, så undgår man 0x280 ... 280 fejlen.
Desuden er 'hent' erklæret som en char, men udskrives som en integer.
Forslag: Erklær den som int.
Hvor er det iøvrigt helt præcist den seg-fault'er? Er det i ioperm()
eller inb()?

PS Jeg aner intet om hvordan ioperm() eller inb() fungerer, så jeg har
blot udført en simpel desk-check af programmet - en desværre ofte
undervurderet disciplin. 

/Egon


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:09 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *