ts-7000
[Top] [All Lists]

Re: [ts-7000] PLD registers, still not getting access to memory regs

To:
Subject: Re: [ts-7000] PLD registers, still not getting access to memory regs
From: "Don W. Carr" <>
Date: Fri, 1 Sep 2006 08:38:18 -0500
You proplem is this line:

if ((int)pld_regs=-1) {

should be:

if ((int)pld_regs == -1) {

Your line asignes -1 to pld regs (overwriting the pointer you recieved), then, anything non-zero is true in C.

But, better yet, and more readable:

if ((MAP_FAILED == pld_regs) {

Never do dangerous casts that you might not understand if you do not have to. Also, put the constant always on the left, that way if you put = instead of ==, the compiler will complain about asigning to a constant. Take the time to write good, readable code. You will spend less time in the long run and end up with a more reliable product.

Hope this helps.

Don.




On 9/1/06, mattsaintdev <> wrote:

Hi,
posted a similar request a few weeks ago but after help still not
getting a handle to the PLD registers of the video card.

Once problem was that i needed to be SU to do an open on "dev/mem"
but still the pointer to "pld_regs=(unsigned char *)mmap(" is
returning a -1. Checked page size btw which is 4096.

I dont have a problem mapping the video buffer though?

Code below, any suggestions?

Thanks

Matt

#include <unistd.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>

volatile unsigned char *pld_regs;

int main(int argc, char **argv)
{

char base7;
int mem_handle=open("/dev/mem", O_RDWR | O_SYNC);
//
// 0x11E0_0000 = PLD Register base address

printf("mem handle = %d\n", mem_handle);

pld_regs=(unsigned char *)mmap(0, 4096 , PROT_READ|PROT_WRITE,
MAP_SHARED, mem_handle, 0x11E00000);

if ((int)pld_regs=-1) {
printf("MMap failed.\n Page size = %d\n",getpagesize() );
exit(1);
}
//
//
//
//
printf("TS-7KV Register settings probe \n");
printf("------------------------------ \n\n");
printf("BASE+0 Board ID #1 = %X (documented as 0x41)\n", pld_regs
[0xE0] );
printf("BASE+1 Board ID #2 = %X (documented as 0x20)\n", pld_regs
[0xE1] );

base7=pld_regs[0xE7];
if (base7 & 0x80) printf("ADC option is installed\n");
if (base7 & 0x40) printf("CAN option is installed\n");
if (base7 & 0x20) printf("J5 Set\n");
if (base7 & 0x10) printf("J4 Set\n");
if (base7 & 0x08) printf("J3 Set\n");
if (base7 & 0x04) printf("J2 Set\n");
if (base7 & 0x02) printf("J1 Set\n");
//
//
return 0;
}




--
Dr. Don W. Carr
J. G. Montenegro 2258
Guadalajara, Mexico
+52-333-630-0704
+52-333-836-4500 ext 2930 __._,_.___


SPONSORED LINKS
Single board computer Hardware Computer running slow
Linux os Single board


YAHOO! GROUPS LINKS

  •  Visit your group "ts-7000" on the web.
     
  •  To unsubscribe from this group, send an email to:
     =Unsubscribe
     
  •  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



__,_._,___
<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU