⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rtai_scope.c

📁 rtai-3.1-test3的源代码(Real-Time Application Interface )
💻 C
字号:
/*COPYRIGHT (C) 2003  Roberto Bucher (roberto.bucher@die.supsi.ch)This library is free software; you can redistribute it and/ormodify it under the terms of the GNU Lesser General PublicLicense as published by the Free Software Foundation; eitherversion 2 of the License, or (at your option) any later version.This library is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNULesser General Public License for more details.You should have received a copy of the GNU Lesser General PublicLicense along with this library; if not, write to the Free SoftwareFoundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.*/#include <stdio.h>#include <rtai_netrpc.h>#include <rtai_msg.h>#include <rtai_mbx.h>#include <string.h>#include "rtmain.h"#include "devstruct.h"#define MAX_RTAI_SCOPES               1000#define MBX_RTAI_SCOPE_SIZE           5000extern char *TargetMbxID;extern devStr outDevStr[];void out_rtai_scope_init(int port,int nch,char * sName,char * sParam,double p1,			 double p2, double p3, double p4, double p5){    MBX * mbx;    outDevStr[port-1].nch=nch;    strcpy(outDevStr[port-1].IOName,"Scope");    char name[7];    int nt=nch + 1;    rtRegisterScope(sName,nch);    get_a_name(TargetMbxID,name);    mbx = (MBX *) RT_typed_named_mbx_init(0,0,name,(5000/(nt*sizeof(float)))*(nt*sizeof(float)),FIFO_Q);    if(mbx == NULL) {      fprintf(stderr, "Cannot init mailbox\n");      exit_on_error();    }    outDevStr[port-1].ptr1 = (void *) mbx;}void out_rtai_scope_output(int port, double * u, double t){    MBX *mbx = (MBX *) outDevStr[port-1].ptr1;    int ntraces=outDevStr[port-1].nch;    struct {	float t;	float u[ntraces];    } data;    int i;    data.t=(float) t;    for (i = 0; i < ntraces; i++) {	data.u[i] = (float) u[i];    }    RT_mbx_send_if(0, 0, mbx, &data, sizeof(data));}void out_rtai_scope_end(int port){  MBX *mbx = (MBX *) outDevStr[port-1].ptr1;  RT_named_mbx_delete(0, 0, mbx);  printf("%s closed\n",outDevStr[port-1].IOName);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -