Пример #1
0
MSA MSAConnection::getAobjectFromBuffer(MSBuffer *buf_)
{
  MSBuffer *hb=headBuffer();
  MSBuffer *db=readBuffer();
  int s,n;
  if (isSet(MSProtocolConnection<MSA>::Reset)==MSTrue) return MSA();
  if((s=hb->put()-hb->get())<4)
   {
     if((n=MSBuffer::buffToBuff(buf_,hb,4-s))<0) return MSA();
     if((s=hb->put()-hb->get())<4) return MSA();
     _bytesToNextMessage=MSA::longAt(hb->get());
     if (_bytesToNextMessage<=0) 
      {
	hb->reset();
        unset(MSProtocolConnection<MSA>::Read);
	return MSA();
      }
   }
  if((n=MSBuffer::buffToBuff(buf_,db,_bytesToNextMessage))<0) return MSA();
  if((_bytesToNextMessage-=n)==0)
   {
     MSA d=MSA::importAObject( (char *) db->get(), db->put()-db->get(), (char *)0);
     hb->reset();
     db->clear();
     unset(MSProtocolConnection<MSA>::Read);
     if(d.isNullMSA()==MSTrue)
      {
        resetWithError(MSProtocolConnection<MSA>::Read);return MSA();
      }
     return d;
   }
  return MSA(); 
}
Пример #2
0
unsigned int create_send_setup( const ibBoard_t *board,
	const Addr4882_t addressList[], uint8_t *cmdString )
{
	unsigned int i, j;
	unsigned int board_pad;
	int board_sad;

	if( addressList == NULL )
	{
		fprintf(stderr, "libgpib: bug! addressList NULL in create_send_setup()\n");
		return 0;
	}
	if( addressListIsValid( addressList ) == 0 )
	{
		fprintf(stderr, "libgpib: bug! bad address list\n");
		return 0;
	}

	i = 0;
	/* controller's talk address */
	if(query_pad(board, &board_pad) < 0) return 0;
	cmdString[i++] = MTA(board_pad);
	if(query_sad(board, &board_sad) < 0) return 0;
	if(board_sad >= 0 )
		cmdString[i++] = MSA(board_sad);
	cmdString[ i++ ] = UNL;
	for( j = 0; j < numAddresses( addressList ); j++ )
	{
		unsigned int pad;
		int sad;

		pad = extractPAD( addressList[ j ] );
		sad = extractSAD( addressList[ j ] );
		cmdString[ i++ ] = MLA( pad );
		if( sad >= 0)
			cmdString[ i++ ] = MSA( sad );
	}

	return i;
}
Пример #3
0
irqreturn_t tms9914_interrupt_have_status(gpib_board_t *board, tms9914_private_t *priv, int status0,
		int status1)
{
	// record reception of END
	if(status0 & HR_END)
	{
		set_bit(RECEIVED_END_BN, &priv->state);
	}

	// get incoming data in PIO mode
	if((status0 & HR_BI))
	{
		set_bit(READ_READY_BN, &priv->state);
	}

	if((status0 & HR_BO))
	{
		if(read_byte(priv, ADSR) & HR_ATN)
		{
			set_bit(COMMAND_READY_BN, &priv->state);
		}else
		{
			set_bit(WRITE_READY_BN, &priv->state);
		}
	}

	if(status0 & HR_SPAS)
	{
		priv->spoll_status &= ~request_service_bit;
		write_byte(priv, priv->spoll_status, SPMR);
		//FIXME: set SPOLL status bit
	}

	// record service request in status
	if(status1 & HR_SRQ)
	{
		set_bit(SRQI_NUM, &board->status);
	}

	// have been addressed (with secondary addressing disabled)
	if(status1 & HR_MA)
	{
		// clear dac holdoff
		write_byte(priv, AUX_VAL, AUXCR);
	}

	// unrecognized command received
	if(status1 & HR_UNC)
	{
		unsigned short command_byte = read_byte(priv, CPTR);
// 		printk("tms9914: command pass thru 0x%x\n", command_byte);
		switch(command_byte)
		{
		case PPConfig:
			priv->ppoll_configure_state = 1;
			write_byte(priv, AUX_PTS, AUXCR);
			write_byte(priv, AUX_VAL, AUXCR);
			break;
		case PPU:
			tms9914_parallel_poll_configure(board, priv, PPD);
			write_byte(priv, AUX_VAL, AUXCR);	
		default:
			if(priv->ppoll_configure_state)
			{
				priv->ppoll_configure_state = 0;
				if(command_byte >= PPE && command_byte <= PPD + 0xd)
				{
					tms9914_parallel_poll_configure(board, priv, command_byte);
					write_byte(priv, AUX_VAL, AUXCR);
				}else
				{
					printk("tms9914: bad parallel poll configure byte, command pass thru 0x%x\n", command_byte);
					write_byte(priv, AUX_INVAL, AUXCR);
				}
				break;
			}
			printk("tms9914: unknown gpib command pass thru 0x%x\n", command_byte);
			// clear dac holdoff
			write_byte(priv, AUX_INVAL, AUXCR);
			break;
		}
	}

	if(status1 & HR_ERR)
	{
		GPIB_DPRINTK( "gpib bus error\n");
		set_bit( BUS_ERROR_BN, &priv->state );
	}

	if( status1 & HR_IFC )
	{
		push_gpib_event( board, EventIFC );
		clear_bit(CIC_NUM, &board->status);
	}

	if( status1 & HR_GET )
	{
		push_gpib_event( board, EventDevTrg );
		// clear dac holdoff
		write_byte(priv, AUX_VAL, AUXCR);
	}

	if( status1 & HR_DCAS )
	{
		push_gpib_event( board, EventDevClr );
		// clear dac holdoff
		write_byte(priv, AUX_VAL, AUXCR);
		set_bit( DEV_CLEAR_BN, &priv->state );
	}

	// check for being addressed with secondary addressing
	if( status1 & HR_APT )
	{
		if( board->sad < 0 )
		{
			printk( "tms9914: bug, APT interrupt without secondary addressing?\n" );
		}
		if( read_byte( priv, CPTR ) == MSA( board->sad ) )
		{
			write_byte(priv, AUX_VAL, AUXCR);
		}else
			write_byte(priv, AUX_INVAL, AUXCR);
	}

	if( ( status0 & priv->imr0_bits ) || ( status1 & priv->imr1_bits ) )
	{
		GPIB_DPRINTK("isr0 0x%x, imr0 0x%x, isr1 0x%x, imr1 0x%x\n",
			status0, priv->imr0_bits, status1, priv->imr1_bits );
		update_status_nolock( board, priv );
		wake_up_interruptible( &board->wait );
	}
	return IRQ_HANDLED;
}