int CVIFUNC mouth_OutBufferCommand (dnaBufferRF*buffer)
{
	int l;
	int err=0;
	require(0<buffer->CommandCounter);
	l = dna_LengthBufferRF (buffer);
	if (l) {
//		ibwrt (gpibDS345, buffer->Buffer+buffer->PosByte, l);
		ibwait (gpibDS345, 0);					// re-synch
		if (ThreadIbsta() & ERR)
			return -2;							// TODO BUG GOTCHA : make more verbose
//		errChk(mouth_Error("mouth_WriteDS345{ibwait call failed}",0,0));
		ibwrta (gpibDS345, buffer->Buffer+buffer->PosByte, l);
		if (ThreadIbsta() & ERR)
			return -3;
//		err = mouth_Error("mouth_WriteDS345{ibwrta call failed}",0,0);
#if VERBOSE > 1
		printf("%s\n",&buffer->Buffer[buffer->PosByte]);
		if (err)
			printf("mouth_OutBufferCommand{ibwrt call failed} %d %d %d %d %d\n",
				buffer->PosByte,buffer->PosCommand,ERR,ThreadIbsta(),ThreadIberr());
#endif
		if (err) goto Error;
		errChk(dna_AdvanceRunBufferRF (buffer));
	}
	else {
		errChk(dna_AdvanceRunBufferRF (buffer));
#if VERBOSE > 0
		printf("mouth_OutBufferCommand{Length was zero} %d %d\n",
				buffer->PosByte,buffer->PosCommand);
#endif
	}
Error:
	return (err?-1:0);
}
int CVIFUNC mouth_WriteDS345 (const char command[], int numberofBytes)
{
 	int err=0;

//	ibwrt (gpibDS345, command, numberofBytes);
	ibwait (gpibDS345, 0);					// re-synch
	errChk(mouth_Error("mouth_WriteDS345{ibwait call failed}",0,0));
	ibwrta (gpibDS345, command, numberofBytes);
	errChk(mouth_Error("mouth_WriteDS345{ibwrta call failed}",0,0));
Error:
	return (err?-1:0);
}
int CVIFUNC mouth_ZeroDS345 (void)
{
 	int err=0,l;
	char *command;

	mouth_MakeIdleCommand(&command,0.0,0.0,0.0);
	l=strlen(command);
//	ibwrt (gpibDS345, "OFFS, numberofBytes);
	ibwait (gpibDS345, 0);					// re-synch
	errChk(mouth_Error("mouth_ZeroDS345{ibwait call failed}",0,0));
	ibwrta (gpibDS345, command, l);
	errChk(mouth_Error("mouth_ZeroDS345{ibwrta call failed}",0,0));
Error:
	return (err?-1:0);
}
int wxGPIB_x::Write(char* buf,size_t len)
{
    if(!m_asyncio) {
        m_asyncio |= ASYNCWR;
        // start the asynchron data transfer
        ibwrta(m_hd,buf,len);
    }
    if(m_asyncio & ASYNCWR) {
        ibwait(m_hd,0);
        int state = ThreadIbsta();
        if((state & CMPL+ERR) == 0) {
            return 0;
        }
        m_asyncio = 0;
        // save state, error and count
        m_state = ThreadIbsta();
        m_count = ThreadIbcnt();
        m_error = ThreadIberr();
        return m_count;
    }
    // at this time, return 0 Bytes
    return 0;
};