使用visual studio 2019进行Linux系统编程

上篇说到一个简单模块如何直接在ubuntu下进行linux 模块驱动程序开发测试,这次讲如何用c操作模块?

使用visual studio 2019进行Linux系统编程

首先打开:

修改、安装Linux工具:

新建Linux工程、远程连接Linux服务器、配置编译器:

扫描二维码关注公众号,回复: 11850225 查看本文章

 项目属性配置:

Ubuntu系统安装工具: 

 目标 Linux 系统必须安装 openssh-server、g++、gdb 和 make 。 仅 CMake 项目需要 ninja-build 。

sudo apt-get install openssh-server g++ gdb make ninja-build rsync zip

 启动ssh:

sudo service ssh start

模块加载位置:/sys/module

 测试:断点记得打上(不然不能调式)

测试程序: 

#include <unistd.h>
#include <sys/ioctl.h>
#include <stdlib.h>
#include <stdio.h>
int main() {
	int fd = 0;
	char* hello_node = "/sys/module/day";

	/*O_RDWR只读打开,O_NDELAY非阻塞方式*/
	if ((fd = open(hello_node, O_RDONLY)) < 0) {
		printf("APP open failed %d\n", fd);
	}
	else {
		printf("APP open success\n");
	}

	close(fd);
	return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_41865104/article/details/107949770