本站首页    管理页面    写新日志    退出


HMP学习-srl相关函数-sr_getevtdatap( )
zhu_ruixian 发表于 2007/1/9 16:10:02

函数原型: Linux: void *sr_getevtdatap( )Windows: void *sr_getevtdatap(ehandle) 参数:Linux 无。Windows上sr_waitevtEx( )返回的事件句柄。 返回值:指向数据块的指针 作用:返回与该事件相关的变量数据块的地址。 示例函数: #include <srllib.h>#include <dxxxlib.h>long int dx_handler(void*){        printf( "Got event with event data 0x%s\n",(char*)(sr_getevtdatap()));        /* Tell SRL to keep the event */        return( 1 );}int main(){        int dxxxdev;        int mode = SR_POLLMODE;        /* Set SRL to run in polled mode */        if( sr_setparm( SRL_DEVICE, SR_MODEID, &mode ) == -1 )        {                printf( "Cannot set SRL to polled mode\n" );                exit( 1 );        }        /* open the device */        if(( dxxxdev = dx_open( "dxxxB1C1", 0 )) == -1 )        {                printf( "failed to open device\n" );                exit( 1 );        }        /* Enable handlers */        if( sr_enbhdlr( dxxxdev, EV_ANYEVT, dx_handler ) == -1 )        {        printf( "Could not enable handler: error = %s\n", ATDV_ERRMSGP( SRL_DEVICE ));        exit( 1 );        }        /* Generate events via async calls */        if( dx_sethook( dxxxdev, DL_ONHOOK, EV_ASYNC ) == -1 )        {                printf( "dx_sethook failed: error = %s\n", ATDV_ERRMSGP( dxxxdev ));                exit( 1 );        }        /*        * Wait forever while handlers deal with events        * All handlers return 0 except the one for the last        * event returns 1 telling SRL to leave the event to wake up        * sr_waitevt().        */        (void)sr_waitevt( -1 );        /* Cleanup */}

阅读全文(3773) | 回复(0) | 编辑 | 精华

发表评论:
昵称:
密码:
主页:
标题:
验证码:  (不区分大小写,请仔细填写,输错需重写评论内容!)

 
«August 2025»
12
3456789
10111213141516
17181920212223
24252627282930
31

  公告
欢迎大家留言!既然来了,多少说两句!呵呵!

 


  我的分类(专题)
  最近日志

  最新评论

  留言板

  链接


  Blog信息
blog名称:
日志总数:33
评论数量:61
留言数量:-8
访问次数:235206
建立时间:2006年4月27日



站点首页 | 联系我们 | 博客注册 | 博客登陆

Sponsored By W3CHINA
W3CHINA Blog 0.8 Processed in 0.031 second(s), page refreshed 144779209 times.
《全国人大常委会关于维护互联网安全的决定》  《计算机信息网络国际联网安全保护管理办法》
苏ICP备05006046号