文章目录
前言
本文主要介绍如何编写一个 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;<