# O5 new driver integration ## MPLAB - error message Bad CPU in executable indicates that tool chain doesn't support 32-bit builds - if using OSX Catalina, must use tool chain that supports building 32-bit apps - MPLABX v5.40+ - XC32 v2.50+ - update tool packs (PIC32 MX_DFP) headers // OASIS controller definitions #include // Log record definitions #include // OASIS driver functions #include // OASIS Utility routines #include // O5 Standard I/O, for dprintf #include // Standard I/O #include // String library functions #include #include "cwgdic.h" // // Function Prototype // void cwgdic_drv(Driver *dp); LastSampleType lastCwgdicSample(Driver *dp, char *buf, Int32 *len); // Drive Descriptors for Drivers in this module // // Parameters used: // PARM0: Retry count // PARM1: TBD // PARM2: logging: 0:file 1:oasis log 2+:both const ParmNameType cwgdicParmDesc = {3, {"Retry count", "TBD", "Log: file[0] oasis[1] both[2]"}}; const DrvDesc cwgdicDrvDesc = { "cwgdic", cwgdic_drv, nullWakeFunc, lastCwgdicSample, &cwgdicParmDesc, 3600, NO_SERIAL, 9600, MODE_N81, PWR_PERM, LOG_ASCII, 0, 3, 3, 300, 0}; // // Module Local Data // MLocal char *cwgdicFile = "CWGDIC.TXT"; ## implement driver, lastSample, and any helper functions // this implementation allows logging to OASIS log or separate file // Function : lastCwgdicSample // Purpose : get the last sample // Inputs : Driver pointer // Outputs : OK or ERROR LastSampleType lastCwgdicSample(Driver *dp, char *buf, Int32 *len) { if (dp->drv_parms[PARM2] == 1) return(getLastLogSample(dp, buf, len)); else return(getLastFileSample(dp, cwgdicFile, buf, len)); } // Function : cwgdic_drv // Purpose : Driver for DIC/pCO2 sampler // Inputs : Driver Pointer // Outputs : None void cwgdic_drv(Driver *dp) { Int32 retries, nchars; char *p, *data_buf; // power up sensor serial port if (drvSerPortAndMalloc(dp, 2*CWGDIC_BUFSIZE, &data_buf) != OK){ return; } memset(data_buf, 0, 2*CWGDIC_BUFSIZE); retries = dp->drv_parms[PARM0]; if (retries < 1){ retries = 1; } for ( ; (retries > 0); retries--){ // do stuff here } // release the serial port drv_ser_release(dp); // Free the buffer free(data_buf); } ## add driver, header(s) files to MPLAB Project ## verify that it compiles ## update drvTbl.h - add data declaration (e.g., Extern DrvDesc cwgdicDrvDesc; ) - add entry for driver to drvDescs array (e.g. &cwgdicDrvDesc) ## load firmware ## add entry to oasis.cfg - DOS line ends required - upload using ymodem