resetSerialShims() { int stat; pputchr(shimPort, '\n'); stat = cmddone(shimPort, 500); DPRINT1( -1, "cmddone returned %d in reset serial shims\n", stat ); pputchr(shimPort, '\r'); stat = cmddone(shimPort, 500); DPRINT1( -1, "cmddone returned %d in reset serial shims\n", stat ); }
/* * Wait for a floppy interrupt. If none occurs in 5 seconds, we * may have missed one. This only happens on some portables which * do power management behind our backs. Call the interrupt * routine to try to clear any conditions. */ static void floppywait(int slow) { timedsleep(cmddone, 0, slow ? 5000 : 1000); if(!cmddone(0)) { floppyintr(0); fl.confused = 1; } }
static testSerialShims( int port ) { char *omtMsg = 0; int rtn = 0; int ival; if (pShimMutex != NULL) { semTake(pShimMutex,WAIT_FOREVER); /* protect shim serial comm */ } else { errLogRet(LOGIT,debugInfo,"testSerialShims: Mutex Pointer NULL\n"); return(-1); } clearport( port ); /* printf("testSerialShims: put B, wait for responce\n"); */ pputchr(port, 'B'); if (cmdecho(port, CMD)) { /* if command times out, try again */ pputchr( port, 'B'); /* RRI peripheral responds on the 2nd try */ /* printf("testSerialShims: again put B, wait for responce\n"); */ if (cmdecho(port, CMD)) /* even though RRI calls it an error. */ { /* No response yet */ pputchr(port, '\r'); /* Make OMT serial shims respond */ omtMsg = getstring(port, '\r', OMT_TIMEOUT, NULL, 0); if (!omtMsg){ semGive(pShimMutex); return( TIMEOUT ); } } } if (!omtMsg) ival = cmddone(port, 300 ); semGive(pShimMutex); return( 0 ); }
setTimShim( int port, int board, int dac, int value, int prtmod ) { int localValue, stat; if (port < 0) return( -1 ); if (pShimMutex != NULL) { semTake(pShimMutex,WAIT_FOREVER); /* protect shim serial comm */ } else { errLogRet(LOGIT,debugInfo,"setTimShim: Mutex Pointer NULL\n"); return(-1); } /* For some reason on the U+ system a positive shim parameter value resulted in a negative voltage in the shim coil. On the inova system a positive value sent to the shim computer causes a positive voltage in the shim coil. This change was ajudged to be not acceptable so we change the sign of the parameter here. */ localValue = -value; clearport(port); pputchr(port, 'S'); if (cmdecho(port, CMD)) { errLogRet( LOGIT, debugInfo, "set tim shim failed on the S command\n" ); semGive(pShimMutex); return(TIMEOUT); } pputchr(port, 'D'); if (cmdecho(port,ECHO)) { errLogRet( LOGIT, debugInfo, "set tim shim failed on the D command\n" ); semGive(pShimMutex); return(TIMEOUT); } pputchr(port, ' '); if (cmdecho(port,ECHO)) { errLogRet( LOGIT, debugInfo, "set tim shim failed on the ' ' command\n" ); semGive(pShimMutex); return(TIMEOUT); } if (echoval(port, board )) { errLogRet( LOGIT, debugInfo, "set tim shim failed selecting the board\n" ); semGive(pShimMutex); return(TIMEOUT); } pputchr(port, ' '); if (cmdecho(port,ECHO)) { errLogRet( LOGIT, debugInfo, "set tim shim failed on the 2nd ' '\n" ); semGive(pShimMutex); return(TIMEOUT); } if (echoval(port, dac )) { errLogRet( LOGIT, debugInfo, "set tim shim failed selecting the DAC\n" ); semGive(pShimMutex); return(TIMEOUT); } pputchr(port, ' '); if (cmdecho(port,ECHO)) { errLogRet( LOGIT, debugInfo, "set tim shim failed on the 3rd ' '\n" ); semGive(pShimMutex); return(TIMEOUT); } if (echoval(port, localValue )) { errLogRet( LOGIT, debugInfo, "set tim shim failed setting the DAC value\n" ); semGive(pShimMutex); return(TIMEOUT); } pputchr(port, '\n'); stat = cmddone(port, 500); semGive(pShimMutex); return( 0 ); }
setRRIShim( int dac, int value, int fifoFlag/*NOTUSED*/) { /* Note: "fifoFlag" arg is for compatibility with Nirvana header file. */ char *chrptr; if (dac < 0) return( -1 ); if (shimPort < 0) return( -1 ); if (dac >= sizeof( rriShimTable ) / sizeof( rriShimTable[ 0 ] )) return( -1 ); if (gradOK[dac] == 0) { DPRINT1(1,"turned off dac %d\n",dac); return(0); } chrptr = rriShimTable[dac]; if (chrptr == NULL) return( -1 ); if (pShimMutex != NULL) { semTake(pShimMutex,WAIT_FOREVER); /* protect shim serial comm */ } else { errLogRet(LOGIT,debugInfo,"setRRIShim: Mutex Pointer NULL\n"); return(-1); } clearport(shimPort); pputchr(shimPort, RRIcmd); if (cmdecho(shimPort, ECHO)) { errLogRet( LOGIT, debugInfo, "set RRI shim failed on the S command\n" ); semGive(pShimMutex); return(TIMEOUT); } /* First character is C(oarse) or F(ine). RRI echoes it with an EOM (^C). CMD for 2nd argument to cmdecho tells cmdecho to expect EOM. */ pputchr(shimPort, *chrptr); if (cmdecho(shimPort, CMD)) { errLogRet( LOGIT, debugInfo, "set RRI shim failed on the %c command\n", *chrptr ); semGive(pShimMutex); return(TIMEOUT); } chrptr++; while (*chrptr != '\0') { pputchr(shimPort, *chrptr); if (cmdecho(shimPort, ECHO)) { errLogRet( LOGIT, debugInfo, "set RRI shim failed on the %c command\n", *chrptr ); semGive(pShimMutex); return(TIMEOUT); } chrptr++; } pputchr(shimPort, ' '); if (cmdecho(shimPort,ECHO)) { errLogRet( LOGIT, debugInfo, "set RRI shim failed on the ' '\n" ); semGive(pShimMutex); return(TIMEOUT); } if (echoval(shimPort, value )) { errLogRet( LOGIT, debugInfo, "set RRI shim failed setting DAC value\n" ); semGive(pShimMutex); return(TIMEOUT); } pputchr(shimPort, '\r'); /* NOT <L/F> !!! */ shimstat = cmddone(shimPort, 500); semGive(pShimMutex); return( 0 ); }
/* * This routine is called only for RRI shims. It first decides if * the old shimmer software or the new mxserver software is present * in the RRI. It does this by testing whether or not the PC (prepare * coarse) command is present. It is not present in old software. * If the new software is present, we use the PC command to disable * DACs which are not present. Finally, if the z7 dac is not present, * we assume the ULTRA18 shims are present. */ initGradTest() { int index; int stat; /* Set all dacs to present */ for (index = 0; index < sizeof(rriShimTable)/sizeof(rriShimTable[0]); index++) { gradOK[index] = 1; } if (pShimMutex != NULL) { semTake(pShimMutex,WAIT_FOREVER); /* protect shim serial comm */ } else { return(ULTRA); } clearport(shimPort); pputchr(shimPort, 'P'); cmdecho(shimPort, ECHO); pputchr(shimPort, 'C'); stat = cmddone(shimPort, 100); if (stat == 200) { /* * The PC command is not recognized. This must be old RRI SHIMMER software */ semGive(pShimMutex); return(ULTRA); } pputchr(shimPort, '\r'); /* * At this point an error should occur for the MXSERVER RRI software. * There are two cases. * 1. MxServer with no error handling should not give an error number * but it will give an error message about "Incorrect number of * arguments". * 2. MxServer with error handling should give error 201 ""Incorrect number of * argument". */ stat = cmddone(shimPort, 500); semGive(pShimMutex); if (stat != 201) return(ULTRA); RRIcmd = 'P'; for (index = 0; index < sizeof(rriShimTable)/sizeof(rriShimTable[0]); index++) { setRRIShim(index, 0, 0); /* * A return value of 202 is given by RRI's mxserver if a gradient is * not present */ if (shimstat == 202) { DPRINT1(1,"turn off dac %d\n",index); gradOK[index] = 0; } else if (shimstat != 0) { DPRINT3(1,"dac %d (%s) status= %d\n", index,rriShimTable[index],shimstat); } } RRIcmd = 'S'; /* test if z7 (dac 10) is present */ return( (gradOK[10] == 0) ? ULTRA18 : ULTRA); }