obcsim/msp_obc_link.c
struct msp_response msp_abort_transaction(msp_link_t *lnk)
{
	int code;
	struct msp_obc_frame frame;
	unsigned long len;

	if (lnk == NULL)
		return msp_response_error(MSP_OBC_ERR_NULL_POINTER);

	/* Take no action if we already are in a transaction */
	if (lnk->state == MSP_LINK_STATE_READY)
		return msp_response_error(MSP_OBC_ERR_NOT_IN_A_TRANSACTION);

	/* Setup NULL frame */
	frame.type = MSP_OBC_FRAME_HEADER;
	frame.id = 0;
	frame.opcode = MSP_OP_NULL;
	frame.dl = 0;

	code = msp_obc_encode_frame(lnk, lnk->buffer, &len, frame);
	if (code) {
		lnk->corrupt_frame_count += 1;
		return msp_response_error(code);
	}

	/* Now at this point in time, we do not care about if the frame was sent
	 * over I2C or not. We set ourselves in the ready state no matter what. */

	msp_set_as_ready(lnk);

	code = msp_i2c_write(lnk->slave_address, lnk->buffer, len);
	if (code) {
		/* Do not report an error here as we are aborting the transaction
		 * anyway. */
		return msp_response_error(MSP_OBC_ERR_I2C_ERROR);
	}


	return msp_response_ok();
}
/*
 * Blocking (send over I2C)
 * 
 * Aborts the current transaction and sends a null frame to the experiment.
 * Even if something went wrong when trying to send the frame, the state of the
 * link will still be set to ready.
 *
 * If the link is not active in a transaction, then no null frame is sent and
 * an error response is returned.
 */
Blocking (send over I2C)

Aborts the current transaction and sends a null frame to the experiment.
Even if something went wrong when trying to send the frame, the state of the
link will still be set to ready.

If the link is not active in a transaction, then no null frame is sent and
an error response is returned.
Blocking ( send over I2C ) Aborts the current transaction and sends a null frame to the experiment . Even if something went wrong when trying to send the frame the state of the link will still be set to ready . If the link is not active in a transaction then no null frame is sent and an error response is returned .
struct msp_response msp_abort_transaction(msp_link_t *lnk)
{
	int code;
	struct msp_obc_frame frame;
	unsigned long len;
	if (lnk == NULL)
		return msp_response_error(MSP_OBC_ERR_NULL_POINTER);
	if (lnk->state == MSP_LINK_STATE_READY)
		return msp_response_error(MSP_OBC_ERR_NOT_IN_A_TRANSACTION);
	frame.type = MSP_OBC_FRAME_HEADER;
	frame.id = 0;
	frame.opcode = MSP_OP_NULL;
	frame.dl = 0;
	code = msp_obc_encode_frame(lnk, lnk->buffer, &len, frame);
	if (code) {
		lnk->corrupt_frame_count += 1;
		return msp_response_error(code);
	}
	msp_set_as_ready(lnk);
	code = msp_i2c_write(lnk->slave_address, lnk->buffer, len);
	if (code) {
		return msp_response_error(MSP_OBC_ERR_I2C_ERROR);
	}
	return msp_response_ok();
}
struct msp_response msp_abort_transaction ( msp_link_t * lnk ) { int code ; struct msp_obc_frame frame ; unsigned long len ; if ( lnk == NULL ) return msp_response_error ( MSP_OBC_ERR_NULL_POINTER ) ; if ( lnk -> state == MSP_LINK_STATE_READY ) return msp_response_error ( MSP_OBC_ERR_NOT_IN_A_TRANSACTION ) ; frame . type = MSP_OBC_FRAME_HEADER ; frame . id = 0 ; frame . opcode = MSP_OP_NULL ; frame . dl = 0 ; code = msp_obc_encode_frame ( lnk , lnk -> buffer , & len , frame ) ; if ( code ) { lnk -> corrupt_frame_count += 1 ; return msp_response_error ( code ) ; } msp_set_as_ready ( lnk ) ; code = msp_i2c_write ( lnk -> slave_address , lnk -> buffer , len ) ; if ( code ) { return msp_response_error ( MSP_OBC_ERR_I2C_ERROR ) ; } return msp_response_ok ( ) ; }
Blocking (send over I2C)
Blocking ( send over I2C )
/* Take no action if we already are in a transaction */ /* Setup NULL frame */ /* Now at this point in time, we do not care about if the frame was sent
	 * over I2C or not. We set ourselves in the ready state no matter what. */ /* Do not report an error here as we are aborting the transaction
		 * anyway. */