Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Hi and thanks, I changed the for loop for your neat shortcut so thanks.

Re inline C, I was going to try this, but when I tried to install the modules I got several errors. Searching for the errors I found that some suggest that cpan dosent run well if at all on the pi because of the limited memory. There are alternatives (cpanm for one IIRC) but I didn't go that path yet. Because of the way that the C functions need the memory mapped addresses and I don't see a way to get these out of the perl module, I guess I would have to implment it all myself inline, which seems like reinventing the wheel a bit, which put me off. That said, I might do this as I have never used inline C with perl before and it seems like a good learning excercise.

On the other note, I tried the example code initially, and just silently exits as it does with all values I have yet tried with peri_write. I strace it to produce this output:

open("/dev/mem", O_RDWR|O_SYNC) = 3 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, 3, 0x20200) = 0xb6 +f05000 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, 3, 0x2020c) = 0xb6 +f04000 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, 3, 0x20101) = 0xb6 +f03000 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, 3, 0x20100) = 0xb6 +edb000 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, 3, 0x20204) = 0xb6 +eda000 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, 3, 0x20205) = 0xb6 +ed9000 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, 3, 0x20804) = 0xb6 +ed8000 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, 3, 0x20003) = 0xb6 +ed7000 close(3) = 0 --- SIGSEGV (Segmentation fault) @ 0 (0) --- +++ killed by SIGSEGV +++
I'm no expert in understanding the output of strace but I found (with print statements etc) that the mmaps are from the gpio_fsel statements, but theres no further info once execution hits the peri_write line unfortunately.

I tried the print suggestion you made, but the results are maybe not of much help, unless I am not doing it right. The C program uses mmap and inputs the base address of the hw, and gets a memory location back, which changes every time the program is executed. In the peri_write function, I am sending the same base address as the C version, but theres no memory mapping going on that I can see (whether this is my problem and I need to somehow get the mmap address back out of the perl module I am not sure). The perl version as far as I can tell keeps the mmap location hidden and internal, and just asks the user to provide the hardware address which it internally translates itself, having stored the offset after making the mmap call - I believe. But am not sure.

If you can see that I am interpreting this wrong and I have to get that mmap location myself and use it, that must be my problem. But I can't see any functions in the module which return that location.

Thanks, Pete

In reply to Re^2: Device::BCM2835, hardware access on a pi, SIGSEGV by Peterpion
in thread Device::BCM2835, hardware access on a pi, SIGSEGV by Peterpion

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-19 21:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found