Code Monkey home page Code Monkey logo

Comments (6)

driftregion avatar driftregion commented on May 16, 2024

It looks like you're using ST's HAL: https://www.disca.upv.es/aperles/arm_cortex_m3/llibre/st/STM32F439xx_User_Manual/group__can__exported__functions__group3.html#gaf25698a35af7f78d01b036fcb80d81f3

HAL_CAN_GetRxMessage returns HAL_OK if there was a message otherwise HAL_ERROR.

Try this:

static enum Iso14229CANRxStatus mockClientCANRxPoll(uint32_t *arb_id, uint8_t *data, uint8_t *dlc) {
    if (HAL_OK == HAL_CAN_GetRxMessage(&hcan1, CAN_RX_FIFO0, &rxHeader, TxData))  {
	*arb_id = rxHeader.ExtId;
	*dlc = rxHeader.DLC;
	memmove(data,TxData,*dlc);
        return kCANRxSome;
    }
    else {
        return kCANRxNone;    
    }
}

from iso14229.

imecar-github avatar imecar-github commented on May 16, 2024

It looks like you're using ST's HAL: https://www.disca.upv.es/aperles/arm_cortex_m3/llibre/st/STM32F439xx_User_Manual/group__can__exported__functions__group3.html#gaf25698a35af7f78d01b036fcb80d81f3

HAL_CAN_GetRxMessage returns HAL_OK if there was a message otherwise HAL_ERROR.

Try this:

static enum Iso14229CANRxStatus mockClientCANRxPoll(uint32_t *arb_id, uint8_t *data, uint8_t *dlc) {
    if (HAL_OK == HAL_CAN_GetRxMessage(&hcan1, CAN_RX_FIFO0, &rxHeader, TxData))  {
	*arb_id = rxHeader.ExtId;
	*dlc = rxHeader.DLC;
	memmove(data,TxData,*dlc);
        return kCANRxSome;
    }
    else {
        return kCANRxNone;    
    }
}

Yes I am using ST's HAL. Thanks for response.

But whenever I want to debug code, mockClientCANRxPoll function is not triggered.

Iso14229Client udsClient;
    	struct Iso14229ClientConfig cfg = {
    	    .phys_send_id = 0x18DA66AA,
    	    .func_send_id = 0x18da55aa,
    	    .recv_id = 0x18DAAA66,
    	    .p2_ms = CLIENT_DEFAULT_P2_MS,
    	    .p2_star_ms = CLIENT_DEFAULT_P2_STAR_MS,
  	        .link = &g.clientLink,
  	        .link_receive_buffer = g.clientLinkRxBuf,
  	        .link_recv_buf_size = sizeof(g.clientLinkRxBuf),
  	        .link_send_buffer = g.clientLinkTxBuf,
  	        .link_send_buf_size = sizeof(g.clientLinkTxBuf),
  	        .userCANTransmit = mockClientSendCAN,
  	        .userGetms = mockUserGetms,
  	        .userCANRxPoll = mockClientCANRxPoll,
  	        .userDebug = mockClientLinkDbg,
    	    };

Here is my configuration.

from iso14229.

driftregion avatar driftregion commented on May 16, 2024

That configuration looks fine.

The callback function mockClientCANRxPoll will only be called when you call iso14229SequenceRunBlocking or the lower-level API Iso14229ClientPoll from your program.

You can try implementing a sequence like the one here:

iso14229/examples/client.c

Lines 111 to 124 in 27cc02e

static Iso14229ClientCallback callbacks[] = {
sendHardReset,
awaitPositiveResponse,
requestSomeData,
awaitPositiveResponse,
printTheData,
enterDiagnosticSession,
awaitResponse,
sendExitReset,
awaitPositiveResponse,
};

from iso14229.

imecar-github avatar imecar-github commented on May 16, 2024

I do not know how it is possible but,

In my

__weak void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan)
{
	CAN_RxHeaderTypeDef   RxHeader;
	    	uint8_t               RxData[8];
  /* Prevent unused argument(s) compilation warning */
	    	 HAL_CAN_GetRxMessage(hcan, CAN_RX_FIFO0, &RxHeader, RxData);
	    	 if(RxData[1] == 80)
	    	 {
	    		 int i = 1;
	    	 }
  /* NOTE : This function Should not be modified, when the callback is needed,
            the HAL_CAN_RxFifo0MsgPendingCallback could be implemented in the
            user file
   */
}

Function, I can see the response message correctly, But,

static enum Iso14229CANRxStatus mockClientCANRxPoll(uint32_t *arb_id, uint8_t *data, uint8_t *dlc) {
    if (HAL_OK == HAL_CAN_GetRxMessage(&hcan1, CAN_RX_FIFO0, &rxHeader, TxData))  {
	*arb_id = rxHeader.ExtId;
	*dlc = rxHeader.DLC;
	memmove(data,TxData,*dlc);
        return kCANRxSome;
    }
    else {
        return kCANRxNone;    
    }
}

In this function HAL_CAN_GetRxMessage function can not get anything from bus. Because of this, I can not run sequences.

from iso14229.

driftregion avatar driftregion commented on May 16, 2024

You can try either:

from iso14229.

imecar-github avatar imecar-github commented on May 16, 2024

When I disable Interrupts, TX and RX functions triggered. Thanks.

from iso14229.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.