UART vs. APS_DataInd()

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi !

I use BitCloud v13 on ATZB-A24-UFL.

My problem is like this:

I have network with COORDINATOR(gateway to PC through UART) and few nodes ROUTERS or END DEVICES.

My application on COORDINATOR "crushes"(messed state machine I suppose) when I'm receiving something on UART(information sended from PC to some node) and in the same time I receive some
information on COORDINATOR form one node(doesn't matter which one) through APS_DataInd().

So UART communication is interrupted by APS_DataInd() function.
And also can be vice versa APS_DataInd() function is interrupted by USART.

So both actions(let's call it that way) UART and APS_DataInd() can happen at random times on COORDINATOR.

I use UART in callback mode.
I noticed that if I send 20 bytes of data to COORDINATOR by UART usartMessageReceived(uint16_t readBytesLength) function is called 20 times, so each time for each byte that is received.

Can I make it that usartMessageReceived(uint16_t readBytesLength) is called ONLY ONCE and then I have these 20 bytes?

How to achieve that?

Can I solve this problem by using APS_StartReq() and APS_StopReq() eg. when COORDINATOR starts receiving UART message, APS_StopReq() function is called in usartMessageReceived(uint16_t readBytesLength) to stop processing incomming messages
form APS_DataInd()?

Or can you suggest me another way?

Thank you !

Best regards !

Last Edited: Fri. Oct 16, 2015 - 02:16 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

APS_DataInd() and usartMessageReceived() can't interrupt program execution, they are called from task scheduler only when it has control, so no other task is running.

Quote:
Can I make it that usartMessageReceived(uint16_t readBytesLength) is called ONLY ONCE and then I have these 20 bytes?
No, this function is called as soon as data arrives or there is some buffered data.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Take a look at "WSNUARTManager.c" in WSNDemo (BitCloud megaRF 1.14). See how it is implemented the callback function "readByteEvent". It has a non-blocking implementation. Everything you need is there and pretty simple!

I already made my usart manager to receive some data from PC and I figured it out with that example. It works perfect.