QNX 字符设备 resource manager 实例

时间: 2023-11-15 admin 维修知识

QNX 字符设备 resource manager 实例

QNX 字符设备 resource manager 实例

文章目录

  • 前言
  • 一、普通的 resource managers
  • 二、字符设备 resource managers
    • 1. 字符设备节点
    • 2. 字符设备 devctl cmd 参数
      • 1. devctl cmd 参数的构成
      • 2. devctl 字符设备实例
  • 总结
  • 参考资料


前言

本文主要介绍如何编写一个 qnx 下 的 char device resource managers (字符设备驱动)
软件环境:qnx7.1


一、普通的 resource managers

如下代码是 qnx 官网的 resource managers 实例, 会生成一个 /dev/sample 节点

#include <errno.h>
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/iofunc.h>
#include <sys/dispatch.h>static resmgr_connect_funcs_t    connect_funcs;
static resmgr_io_funcs_t         io_funcs;
static iofunc_attr_t             attr;int main(int argc, char **argv)
{/* declare variables we'll be using */resmgr_attr_t        resmgr_attr;dispatch_t           *dpp;dispatch_context_t   *ctp;int                  id;/* initialize dispatch interface */dpp = dispatch_create_channel(-1, DISPATCH_FLAG_NOLOCK );if (dpp == NULL) {fprintf(stderr,"%s: Unable to allocate dispatch handle.\n",argv[0]);return EXIT_FAILURE;<