从C/C++程序Debian激活驱动程序

Activate driver from C/C++ program Debian

本文关键字:Debian 激活 驱动程序 程序 C++      更新时间:2023-10-16

尝试从BeagleBone Black Debian的C/C++程序中激活GPIO驱动程序。我没有激活驱动程序,而是收到了错误消息"sh:1:无法创建/sys/devices/bone_capemgr./slots:Directory不存在"。如果我直接在SSH终端中键入"echo-cape bone iio>/sys/devices/bone_cappemgr./spots",它可以正常工作。任何见解都将不胜感激。

#include <stdio.h>
#include <stdlib.h>
int main()
  {
  printf( "Activate Analog GPIO drivern" );
  system( "echo cape-bone-iio > /sys/devices/bone_capemgr.*/slots" );
  printf( "donen" );
  return 0;
  }

这就成功了,仍然不确定echo为什么不起作用。

FILE *ain;
ain = fopen("/sys/devices/bone_capemgr.9/slots", "w");
fseek(ain,0,SEEK_SET);
fprintf(ain,"cape-bone-iio");
fflush(ain);
fclose(ain);
return 0;