obcsim/msp_obc_link.c
struct msp_response msp_start_transaction(msp_link_t *lnk,
                                          unsigned char opcode,
                                          unsigned long len)
{
	if (lnk == NULL)
		return msp_response_error(MSP_OBC_ERR_NULL_POINTER);

	switch (MSP_OP_TYPE(opcode)) {
	case MSP_OP_TYPE_SYS:
		if (len != 0)
			return msp_response_error(MSP_OBC_ERR_LENGTH_NOT_ZERO);

	case MSP_OP_TYPE_SEND:
		lnk->state = MSP_LINK_STATE_SEND_TX_HEADER;
		lnk->next_action = MSP_LINK_ACTION_TX_HEADER;
		lnk->corrupt_frame_count = 0;
		lnk->transaction_id = msp_seqflags_get_next(&lnk->flags, opcode);
		lnk->frame_id = lnk->transaction_id;
		lnk->opcode = opcode;
		lnk->total_length = len;
		lnk->processed_length = 0;
		break;
	case MSP_OP_TYPE_REQ:
		if (len != 0)
			return msp_response_error(MSP_OBC_ERR_LENGTH_NOT_ZERO);

		lnk->state = MSP_LINK_STATE_REQ_TX_HEADER;
		lnk->next_action = MSP_LINK_ACTION_TX_HEADER;
		lnk->corrupt_frame_count = 0;
		lnk->transaction_id = 0;
		lnk->frame_id = 0;
		lnk->opcode = opcode;
		lnk->total_length = 0;
		lnk->processed_length = 0;
		break;
	default:
		return msp_response_error(MSP_OBC_ERR_INVALID_OPCODE);
	}

	return msp_response_ok();
}
/*
 * Non-Blocking.
 * 
 * Starts a transaction with the given opcode. This function is non-blocking as
 * it only sets the state of the link.
 *
 * If the opcode has the trait DL0 (see the MSP specification), then an error
 * will be returned if the entered length is not also 0.
 */
Non-Blocking.

Starts a transaction with the given opcode. This function is non-blocking as
it only sets the state of the link.

If the opcode has the trait DL0 , then an error
will be returned if the entered length is not also 0.
Non - Blocking . Starts a transaction with the given opcode . This function is non - blocking as it only sets the state of the link . If the opcode has the trait DL0 then an error will be returned if the entered length is not also 0 .
struct msp_response msp_start_transaction(msp_link_t *lnk,
                                          unsigned char opcode,
                                          unsigned long len)
{
	if (lnk == NULL)
		return msp_response_error(MSP_OBC_ERR_NULL_POINTER);
	switch (MSP_OP_TYPE(opcode)) {
	case MSP_OP_TYPE_SYS:
		if (len != 0)
			return msp_response_error(MSP_OBC_ERR_LENGTH_NOT_ZERO);
	case MSP_OP_TYPE_SEND:
		lnk->state = MSP_LINK_STATE_SEND_TX_HEADER;
		lnk->next_action = MSP_LINK_ACTION_TX_HEADER;
		lnk->corrupt_frame_count = 0;
		lnk->transaction_id = msp_seqflags_get_next(&lnk->flags, opcode);
		lnk->frame_id = lnk->transaction_id;
		lnk->opcode = opcode;
		lnk->total_length = len;
		lnk->processed_length = 0;
		break;
	case MSP_OP_TYPE_REQ:
		if (len != 0)
			return msp_response_error(MSP_OBC_ERR_LENGTH_NOT_ZERO);
		lnk->state = MSP_LINK_STATE_REQ_TX_HEADER;
		lnk->next_action = MSP_LINK_ACTION_TX_HEADER;
		lnk->corrupt_frame_count = 0;
		lnk->transaction_id = 0;
		lnk->frame_id = 0;
		lnk->opcode = opcode;
		lnk->total_length = 0;
		lnk->processed_length = 0;
		break;
	default:
		return msp_response_error(MSP_OBC_ERR_INVALID_OPCODE);
	}
	return msp_response_ok();
}
struct msp_response msp_start_transaction ( msp_link_t * lnk , unsigned char opcode , unsigned long len ) { if ( lnk == NULL ) return msp_response_error ( MSP_OBC_ERR_NULL_POINTER ) ; switch ( MSP_OP_TYPE ( opcode ) ) { case MSP_OP_TYPE_SYS : if ( len != 0 ) return msp_response_error ( MSP_OBC_ERR_LENGTH_NOT_ZERO ) ; case MSP_OP_TYPE_SEND : lnk -> state = MSP_LINK_STATE_SEND_TX_HEADER ; lnk -> next_action = MSP_LINK_ACTION_TX_HEADER ; lnk -> corrupt_frame_count = 0 ; lnk -> transaction_id = msp_seqflags_get_next ( & lnk -> flags , opcode ) ; lnk -> frame_id = lnk -> transaction_id ; lnk -> opcode = opcode ; lnk -> total_length = len ; lnk -> processed_length = 0 ; break ; case MSP_OP_TYPE_REQ : if ( len != 0 ) return msp_response_error ( MSP_OBC_ERR_LENGTH_NOT_ZERO ) ; lnk -> state = MSP_LINK_STATE_REQ_TX_HEADER ; lnk -> next_action = MSP_LINK_ACTION_TX_HEADER ; lnk -> corrupt_frame_count = 0 ; lnk -> transaction_id = 0 ; lnk -> frame_id = 0 ; lnk -> opcode = opcode ; lnk -> total_length = 0 ; lnk -> processed_length = 0 ; break ; default : return msp_response_error ( MSP_OBC_ERR_INVALID_OPCODE ) ; } return msp_response_ok ( ) ; }
Non-Blocking.
Non - Blocking .