
linux c应用
linux 应用常用编程
不吃辣的同学
bsp开发
展开
-
Linux 终端串口重定向
Linux 终端串口重定向#include <stdio.h>#include <stdlib.h>#include <string.h>#include <fcntl.h>#include <sys/ioctl.h>#include <unistd.h>#define LOG_FILE "seria_log.txt"int main(int argc, char *argv[]){ int tty =原创 2022-03-29 10:42:22 · 1120 阅读 · 0 评论 -
Linux event poll
Linux event poll首先使用一个东西之前至少要了解为什么要使用它,为什么需要poll这个操作,通常网络部分需要监听多个套接字,又要处理套接字,而在监听的过程中程序已经阻塞就不能去执行其他程序,所以需要引入IO复用struct epoll_event数据结构The struct epoll_event is defined as:typedef union epoll_data { void *ptr; int fd; uint32_t u32;原创 2022-02-17 14:40:58 · 852 阅读 · 0 评论 -
Linux 系统IO函数
Linux 系统IO函数1.open函数//头文件#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>//定义//open 返回文件的描述符,pathname : 需要打开的文件 flags: 以读写或者其他方式打开int open(const char *pathname, int flags);int open(const char *pathname, int flags, m原创 2022-02-14 16:30:58 · 927 阅读 · 0 评论 -
Linux 动态库和GDB的使用
Linux 动态库和GDB的使用1.动态库的定义在大型的嵌入式软件中,一般会分模块的进行开发,最终某个模块的部分会以动态库的方式给出来给需要的人调用,一般有动态库和静态库的方式,但是静态库的占用内存太大,我们一般用动态库的方式开发。2.动态库的生成和使用gcc demo.c -o demo.o -fPICgcc -shared demo.o -o libdemo.so //生成 libdemo.so动态库文件mkdir include ; mkdir lib ; mv demo.h inc原创 2022-02-12 20:41:23 · 1163 阅读 · 0 评论 -
getopt_long命令解析
命令行解析命令解析常用的函数getopt、getopt_long、getopt_long_only能够解析长短命令和带参数的命令getopt函数定义头文件#include <unistd.h>#include <getopt.h>/*paramargc:main()函数传递过来的参数的个数argv:main()函数传递过来的参数的字符串指针数组optstring:选项字符串,告知 getopt()可以处理哪个选项以及哪个选项需要参数return如果选项成功找到原创 2022-01-19 11:08:41 · 655 阅读 · 0 评论