辉煌仪奇 2022-03-30 13:29 采纳率: 48.1%
浏览 158
已结题

python调用dll内函数,如何接受返回函数

c++生成动态dll,python调用该dll如何传参
这是dll链接


下面是c++函数代码

double* disp11(unsigned char* rev)
{
    union gyro
    {
        char ch[4];
        float f;
        int si;
    };
    union gyro Gyrox[4];
    unsigned short int data_temp1;
    int i, j;
    static double angleRT[16];
    unsigned short int YearMonth;     //年
    unsigned short int Product_ID_T; //产品编号

    i = 2;
    Product_ID_T = rev[2] + rev[3] * 256; //产品编号
    YearMonth = rev[4] + rev[5] * 256;      //年

    i = 11;
    j = 0;
    Gyrox[0].ch[0] = rev[i++]; //经度
    Gyrox[0].ch[1] = rev[i++];
    Gyrox[0].ch[2] = rev[i++];
    Gyrox[0].ch[3] = rev[i++];
    angleRT[0] = Gyrox[0].f;

    i = 15;
    j = 0;
    Gyrox[0].ch[j++] = rev[i++]; //纬度
    Gyrox[0].ch[j++] = rev[i++];
    Gyrox[0].ch[j++] = rev[i++];
    Gyrox[0].ch[j++] = rev[i++];
    angleRT[1] = Gyrox[0].f;
    i = 19;
    j = 0;
    Gyrox[0].ch[j++] = rev[i++]; //高度,m
    Gyrox[0].ch[j++] = rev[i++];
    Gyrox[0].ch[j++] = rev[i++];
    Gyrox[0].ch[j++] = rev[i++];
    angleRT[2] = Gyrox[0].f;

    i = 23;
    j = 0;
    Gyrox[0].ch[j++] = rev[i++]; //航向
    Gyrox[0].ch[j++] = rev[i++];
    Gyrox[0].ch[j++] = rev[i++];
    Gyrox[0].ch[j++] = rev[i++];
    angleRT[3] = Gyrox[0].f;

    i = 27;
    j = 0;
    Gyrox[0].ch[j++] = rev[i++]; //步数
    Gyrox[0].ch[j++] = rev[i++];
    Gyrox[0].ch[j++] = rev[i++];
    Gyrox[0].ch[j++] = rev[i++];
    angleRT[4] = Gyrox[0].f;

    //步幅度,低字节
    data_temp1 = rev[32] * 256 + rev[31];
    angleRT[5] = (double)data_temp1;

    angleRT[6] = (double)rev[33];       //卫星数
    angleRT[7] = (double)rev[34];       //状态字1
    angleRT[8] = (double)rev[35];       //状态字2
    angleRT[9] = (double)Product_ID_T; //状态字2

    angleRT[10] = (double)YearMonth; //年
    angleRT[11] = (double)rev[6];     //月
    angleRT[12] = (double)rev[7];     //日
    angleRT[13] = (double)rev[8];     //时
    angleRT[14] = (double)rev[9];     //分
    angleRT[15] = (double)rev[10];     //秒

    return angleRT;
}

这是我使用python调用的代码

from ctypes import *
dll = CDLL('./Dll1.dll')
print(dir(dll))
print(dll.disp11([0xAA,0x55,0xAD,0x02,0xBC,0x08,0x01,0x06,0x08,0x00,0x00,0x08,0x33,0xD6,0x42,0xF0,0x97,0xEF,0x41,0x24,0x18,0xB7,0x43,0xEF,0x69,0x56,0x43,0x00,0x00,0x50,0x41,0xA8,0x02,0x00,0x00,0x01,0xEF]))

img

返回应该是个数组,但是接受到却是一个整数,我该如何取出dll返回参数

  • 写回答

8条回答

      报告相同问题?

      相关推荐 更多相似问题

      问题事件

      • 系统已结题 4月9日
      • 已采纳回答 4月1日
      • 创建了问题 3月30日

      悬赏问题

      • ¥20 苹果app名字侵权商标,我投诉了,但是苹果一直没回怎么办
      • ¥15 Android studio运行不成功总是报错
      • ¥15 pycharm 加载软件包列表时出错connect timed out
      • ¥15 和您碰到了同一个问题
      • ¥15 如何在微信支付V3PHP版请求中添加header?
      • ¥15 在数字信号处理中用MATLAB显示波形。
      • ¥15 keil MDK软件进行仿真调试的局限
      • ¥15 关于gateway产生临时文件夹的问题
      • ¥15 Java Broken Pipe以及OOM
      • ¥20 请问有没有RTL8211FS的参考原理图