void PortW32::PClose() { ClosePortTalk(); CloseSerialPort(); CloseGPUSB(); CloseLXUSB(); }
PORTOBJ::~PORTOBJ() { int t,i=0; for (t=0;t<GLOBAL.objects;t++) if (objects[t]->type==OB_PORT_IO) i++; if (i==1) ClosePortTalk(); }
void __cdecl mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { double *port; int mrows, ncols; double *val; /* Check for proper number of arguments. */ if (nrhs != 1) { mexErrMsgTxt("One input argument required."); } else if (nlhs != 1) { mexErrMsgTxt("One output argument required."); } /* The input must be noncomplex scalar double.*/ mrows = mxGetM(prhs[0]); ncols = mxGetN(prhs[0]); if (!mxIsDouble(prhs[0]) || mxIsComplex(prhs[0]) || !(mrows == 1 && ncols == 1)) { mexErrMsgTxt("Input must be noncomplex scalar double."); } /* Assign pointers to the input. */ port = mxGetData(prhs[0]); plhs[0] = mxCreateScalarDouble(0); val = mxGetPr(plhs[0]); OpenPortTalk(); *val = inportb(*port); ClosePortTalk(); }
SDR1000::~SDR1000() { delete pio_ic01; delete pio_ic03; if(rfe) { delete rfe_ic07; delete rfe_ic09; delete rfe_ic10; delete rfe_ic11; } delete dds; if(!usb) { init_count--; if(init_count == 0) ClosePortTalk(); } }
void __cdecl mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { double *port, *value; int mrows, ncols, arg; /* Check for proper number of arguments. */ if (nrhs != 2) { mexErrMsgTxt("Two input arguments required."); } else if (nlhs > 0) { mexErrMsgTxt("Too many output arguments."); } /* The input must be noncomplex scalar double.*/ for (arg = 0; arg < 2; arg++) { mrows = mxGetM(prhs[arg]); ncols = mxGetN(prhs[arg]); if (!mxIsDouble(prhs[arg]) || mxIsComplex(prhs[arg]) || !(mrows == 1 && ncols == 1)) { mexErrMsgTxt("Input must be noncomplex scalar double."); } } /* Assign pointers to each input and output. */ port = mxGetData(prhs[0]); value = mxGetData(prhs[1]); OpenPortTalk(); outportb(*port, *value); ClosePortTalk(); /* This is where the new code begins */ //Dynamically load the DLL at runtime (not linked at compile time) HINSTANCE hInpOutDll; hInpOutDll = LoadLibrary("InpOutx64.DLL"); //The 32bit DLL. If we are building x64 C++ //applicaiton then use InpOutx64.dll if (hInpOutDll != NULL) { gfpOut32 = (lpOut32)GetProcAddress(hInpOutDll, "Out32"); gfpInp32 = (lpInp32)GetProcAddress(hInpOutDll, "Inp32"); gfpIsInpOutDriverOpen = (lpIsInpOutDriverOpen)GetProcAddress(hInpOutDll, "IsInpOutDriverOpen"); gfpIsXP64Bit = (lpIsXP64Bit)GetProcAddress(hInpOutDll, "IsXP64Bit"); if (gfpIsInpOutDriverOpen()) { //Make some noise through the PC Speaker - hey it can do more that a single beep using InpOut32 Beep(2000); Sleep(200); Beep(1000); Sleep(300); Beep(2000); Sleep(250); StopBeep(); if (!strcmp(argv[1], "read")) { short iPort = atoi(argv[2]); WORD wData = gfpInp32(iPort); //Read the port printf("Data read from address %s is %d \n\n\n\n", argv[2], wData); } else if (!strcmp(argv[1], "write")) { if (argc < 4) { printf("Error in arguments supplied"); printf("\n***** Usage *****\n\nInpoutTest read <ADDRESS> \nor \nInpoutTest write <ADDRESS> <DATA>\n\n\n\n\n"); } else { short iPort = atoi(argv[2]); WORD wData = atoi(argv[3]); gfpOut32(iPort, wData); printf("data written to %s\n\n\n", argv[2]); } } } else { printf("Unable to open InpOut32 Driver!\n"); } //All done FreeLibrary(hInpOutDll); return 0; } else { printf("Unable to load InpOut32 DLL!\n"); return -1; } }