BlueAndi / vscp-framework

Very Simple Control Protocol (VSCP) Level 1 Framework
Other
12 stars 8 forks source link

Maybe vscp_core_process should return true if vscp_core_extPageReadData has to send data #43

Closed benys closed 2 years ago

benys commented 2 years ago

Hi,

My implementation your framework uses events.So I would like to "sleep" MCU during waiting for CAN messages or IRQ. But I discovered when ext page read is requested - "outside" program doesn't know and it cannot execute loop something like this:

while(event is handled) {
  while(vscp_core_process());
  //do work
}

What do you think? Maybe vscp_core_process should return true if something is need to handle?

Thanks Kamil

BlueAndi commented 2 years ago

Hi Kamil, if you send the MCU in sleep mode, does the CAN controller trigger an ISR via ext. interrupt to wake the MCU up again? In sleep mode the code itself is not running, therefore vscp_core_process() is not called.

Note, dealing with the ISR is MCU/user specific and not part of the framework.

If the MCU is running, vscp_core_process() will return TRUE for a handled event. If there isn't a event to handle, it will return FALSE.

benys commented 2 years ago

My true - enviroment is that I have timer which executes every second:

while(vscp_core_process());

And also it execute if CAN message is arrives. It works very well.

But I found problem, that if controller ask about ext page read with many data to send, your framework assume that vscp_core_process is executed inity in loop. In my case this framework potion of code:

/* Continue a extended page read? */
    if (0 < vscp_core_extPageReadData.count)
    {
        vscp_core_extendedPageReadRegister(&vscp_core_extPageReadData);
    }

will execute only once per second :-)

I think that it should looks like this:

/* Continue a extended page read? */
    if (0 < vscp_core_extPageReadData.count)
    {
        vscp_core_extendedPageReadRegister(&vscp_core_extPageReadData);
        return true
    }
BlueAndi commented 2 years ago

Yes, you are right. The ext. page read depends on your sleep interval in this case. I will update the vscp-framework correspondingly.

benys commented 2 years ago

@BlueAndi thank you!

BlueAndi commented 2 years ago

You are welcome. Note, the next release of the vscp-framework and the Arduino lib will probably come in my christmas vacation.