/* * Class: com_sun_electric_tool_simulation_test_GPIB * Method: ibcmd * Signature: (I[BJ[I)I */ JNIEXPORT jint JNICALL Java_com_sun_electric_tool_simulation_test_GPIB_ibcmd (JNIEnv *penv, jclass cls, jint ud, jbyteArray cmd, jlong cnt, jintArray err) { unsigned int ret; //variable preparation phase jbyte *dataP = (*penv)->GetByteArrayElements(penv, cmd, 0); jint *perr = (*penv)->GetIntArrayElements(penv, err, 0); //excution phase ret = ibcmd(ud, dataP, cnt); *perr = iberr; //release phase (*penv)->ReleaseByteArrayElements(penv, cmd, dataP, 0); (*penv)->ReleaseIntArrayElements(penv, err, perr, 0); return ret; }
int wxGPIB_x::Ioctl(int cmd,void* args) { switch(cmd) { case CTB_RESET: if(m_hd >= 0) { if(m_asyncio) { ibstop(m_hd); m_asyncio = 0; } ibclr(m_hd); return 0; } return -1; case CTB_GPIB_GETRSP: { char spr = 0; if(m_hd >= 0) { ibrsp(m_hd,&spr); *(int*)args = (int)spr; return 0; } return 1; } case CTB_GPIB_GETSTA: *(int*)args = m_state; return 0; case CTB_GPIB_GETERR: *(int*)args = m_error; return 0; case CTB_GPIB_GETLINES: { short state = 0; if(m_hd >= 0) { iblines(m_board,&state); *(int*)args = (int)state; return 0; } return -1; } case CTB_GPIB_SETTIMEOUT: { if(m_hd >= 0) { wxGPIB_Timeout timeout; unsigned long to = *(unsigned long*)args; // convert the timeout in ms (given by args) into the // traditional NI-488.2 timeout period if(to > 1000000) timeout = wxGPIB_TO_1000s; else if(to > 300000) timeout = wxGPIB_TO_300s; else if(to > 100000) timeout = wxGPIB_TO_100s; else if(to > 30000) timeout = wxGPIB_TO_30s; else if(to > 10000) timeout = wxGPIB_TO_10s; else if(to > 3000) timeout = wxGPIB_TO_3s; else if(to > 1000) timeout = wxGPIB_TO_1s; else if(to > 300) timeout = wxGPIB_TO_300ms; else if(to > 100) timeout = wxGPIB_TO_100ms; else if(to > 30) timeout = wxGPIB_TO_30ms; else if(to > 10) timeout = wxGPIB_TO_10ms; else if(to > 3) timeout = wxGPIB_TO_3ms; else if(to > 1) timeout = wxGPIB_TO_1ms; else timeout = wxGPIB_TO_NONE; ibtmo(m_hd,timeout); return 0; } return -1; } case CTB_GPIB_GTL: // Forces the specified device to go to local program mode if(m_hd >= 0) { ibloc(m_hd); return 0; } return -1; case CTB_GPIB_REN: // This routine can only be used if the specified GPIB // Interface Board is the System Controller. // Remember that even though the REN line is asserted, // the device(s) will not be put into remote state until is // addressed to listen by the Active Controller if(m_hd) { char adr = (char)m_dcs.m_address1; ibsre(m_board,1); ibcmd(m_board,&adr,1); return 0; } return -1; case CTB_GPIB_RESET_BUS: ibsic(m_board); return 0; } // error or unknown command return -1; };
void SendCmds( int boardID, const void *buffer, long count ) { ibcmd( boardID, buffer, count ); }
int wxGPIB::Ioctl(int cmd,void* args) { switch(cmd) { case CTB_RESET: if(m_hd >= 0) { ibclr(m_hd); return 0; } return -1; case CTB_GPIB_GETRSP: { char spr = 0; if(m_hd >= 0) { ibrsp(m_hd,&spr); *(int*)args = (int)spr; return 0; } return 1; } case CTB_GPIB_GETSTA: *(int*)args = m_state; return 0; case CTB_GPIB_GETERR: *(int*)args = m_error; return 0; case CTB_GPIB_GETLINES: { short state = 0; if(m_hd >= 0) { iblines(m_board,&state); *(int*)args = (int)state; return 0; } return -1; } case CTB_GPIB_SETTIMEOUT: { if(m_hd >= 0) { wxGPIB_Timeout timeout; unsigned long to = *(unsigned long*)args; // convert the timeout in ms (given by args) into the // traditional NI-488.2 timeout period if(to > 1000000) timeout = wxGPIB_TO_1000s; else if(to >= 300000) timeout = wxGPIB_TO_300s; else if(to >= 100000) timeout = wxGPIB_TO_100s; else if(to >= 30000) timeout = wxGPIB_TO_30s; else if(to >= 10000) timeout = wxGPIB_TO_10s; else if(to >= 3000) timeout = wxGPIB_TO_3s; else if(to >= 1000) timeout = wxGPIB_TO_1s; else if(to >= 300) timeout = wxGPIB_TO_300ms; else if(to >= 100) timeout = wxGPIB_TO_100ms; else if(to >= 30) timeout = wxGPIB_TO_30ms; else if(to >= 10) timeout = wxGPIB_TO_10ms; else if(to >= 3) timeout = wxGPIB_TO_3ms; else if(to >= 1) timeout = wxGPIB_TO_1ms; else timeout = wxGPIB_TO_NONE; ibtmo(m_hd,timeout); return 0; } return -1; } case CTB_GPIB_GTL: // Forces the specified device to go to local program mode if(m_hd >= 0) { ibloc(m_hd); return 0; } return -1; case CTB_GPIB_REN: // This routine can only be used if the specified GPIB // Interface Board is the System Controller. // Remember that even though the REN line is asserted, // the device(s) will not be put into remote state until is // addressed to listen by the Active Controller if(m_hd) { char adr = (char)m_dcs.m_address1; ibsre(m_board,1); ibcmd(m_board,&adr,1); return 0; } return -1; case CTB_GPIB_RESET_BUS: ibsic(m_board); return 0; case CTB_GPIB_GET_EOS_CHAR: if( m_hd ) { *(int*)args = (int)m_dcs.m_eosChar; return 0; } return -1; case CTB_GPIB_SET_EOS_CHAR: #ifdef __GNUG__ // FIXME! // Doesn't work with linux-gpib-3.2.08. All EOS beside 0x00 // are blocking during sending data to the device. (Look at // function my_ibwrt in linux-gpib-3.2.08/lib/ibWrt.c if( m_hd ) { m_dcs.m_eosChar = (char)*(int*)args; ibeos(m_hd,(m_dcs.m_eosMode << 8) | m_dcs.m_eosChar); return 0; } #endif return -1; case CTB_GPIB_GET_EOS_MODE: if( m_hd ) { *(int*)args = (int)m_dcs.m_eosMode; return 0; } return -1; case CTB_GPIB_SET_EOS_MODE: if( m_hd ) { m_dcs.m_eosMode = (char)*(int*)args; ibeos(m_hd,(m_dcs.m_eosMode << 8) | m_dcs.m_eosChar); return 0; } return -1; } // error or unknown command return -1; };