Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5949707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:17:17+00:00 2026-05-22T17:17:17+00:00

I have to control some hardware, which is controlled by a C interface. The

  • 0

I have to control some hardware, which is controlled by a C interface.
The C interface is C++ header file, which contains some functions, one -called set_mirror()- which i need. This C file has also a int array, called voltage, which is used by set_mirror.
I am trying to use cython to build a python function, which implements a set_mir(volt) function. To do that, i have to set the voltage array, but i don’t know how to access it:

My pxy file:

cdef extern from 'mmdm_lin38usb.h':
    int voltage[40]
    int init_dac()
    void close_dac()
    void set_mirror()


init_dac()

def set_mir(volt):
    for i in range(40):
# Only for testing, how to access to int array.
        print voltage[i]

    if len(volt)!=40:
        raise "Need 40 values"
    else:
        volt=map(round,volt)
        volt=map(int,volt)
        voltage=volt
        set_mirror()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:17:17+00:00Added an answer on May 22, 2026 at 5:17 pm

    Is unclear what the final operation is : do you want to set 40 values from a volt python list
    into an array of 40 ints ? I would suggest something like the following. If possible
    don’t modify the global int array. Watch out the voltage array is local.

    import clib
    
    cdef extern from 'mmdm_lin38usb.h':
        int init_dac()
        void close_dac()
        void set_mirror(int *voltage)
    
    init_dac()
    
    cpdef set_mir(volt):
        cdef int voltage[40]
    
        if len(volt) != 40:
            raise ValueError("Need 40 values")
    
        for i from 0 <=  i < 40:
            print voltage[i]
            voltage[i] = int(clib.round(volt[i]))
    
        set_mirror(voltage)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a FrameLayout view which contains one (MapView-like) control and some additional buttons
Let's say I have some Control that has been disabled. It contains a bunch
I have a datalist control which some controls(ex: button) are in it. I want
I have a repeater control outputting some HTML. I want a table which outputs
I have a user control which does some validation in the ValidateChildren method which
I have a user control which uses objects as inner properties (some code is
we have to control some hardware, due to driver's limitation all calls shall comes
I am looking for a way to have some control over the shape of
I am working for an intranet application. Therefore I have some control on the
I have a control that goes inactive under some conditions in my iPhone app.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.