Page 1 of 1

How to react to incoming UART Messages?

Posted: Thu Jan 30, 2014 11:12 pm
by Stomper85
Hi,

i need some help - i want to do following:

I have serial connection to a PC and I want to send commands from PC to the Board.

A command from the PC could be "comm_setRelais1" or what ever.

My idea was, to send escape sing in front and after each command, so that i can parse the string with chibi easyly.
But it is not so easy as I thought.

I have no idea, wich Driver Routine I should use - how do the different receive methods behave?
Does uartStartReceive capture ALL received signs? What happens if buffer is full? Do I have to manualy empty it?
I couldn't find any good example or explanation on the UART Driver for such things - is there a part in the Docu I have missed?

Best regards
Stomper

Re: How to react to incoming UART Messages?

Posted: Thu Jan 30, 2014 11:17 pm
by Giovanni
Hi,

The Serial driver is better than the UART driver in that scenario, you can read one char at time because the driver is buffered.

Giovanni

Re: How to react to incoming UART Messages?

Posted: Fri Jan 31, 2014 1:53 am
by Stomper85
Thanks for that information.

Is there some example code how to manage receiving strings with the UART Driver?

And:
Stomper85 wrote:Hi,
What happens if buffer is full? Do I have to manualy empty it?


Best regards
Stomper

Re: How to react to incoming UART Messages?

Posted: Fri Jan 31, 2014 9:47 am
by Giovanni
Yes, look into shell.c, there is a function reading lines of text using streams (so SERIAL driver, not UART driver).

Giovanni

Re: How to react to incoming UART Messages?

Posted: Fri Jan 31, 2014 10:43 am
by Stomper85
But in your first post you said, the UART Driver would be better.
What should I use now?

SERIAL or UART?

And how does the Buffer behave? Is it a ring-buffer or do I have to empty it manually?
What happens if several messages coming in very fast?

Isn“t there a small code snippet to see how to use UART the right way as receiver?

Re: How to react to incoming UART Messages?

Posted: Fri Jan 31, 2014 11:00 am
by Giovanni
I wrote that serial would be better...

It has ring buffers and you are responsible for reading them quick enough, no explicit empting required.

Giovanni

Re: How to react to incoming UART Messages?

Posted: Fri Jan 31, 2014 2:49 pm
by Stomper85
Sorry,

I got that wrong.

Normaly I am hardware developer - so software is kind of strange for me :D

I try the SERIAL driver, the examples of the shell.c should do.

Best regards
Stomper