Open Library, UART RingBuffer

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Open Library, UART RingBuffer

1,445件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by riscy00 on Sat Jul 26 20:28:18 MST 2014
What the key difference between RingBuffer_Pop(...) and RingBuffer_Insert(...)? (including the multi pop and insert)

I'm puzzled as the code looks very much the same and why?

An application example when/how to use RingBuffer_Pop and RingBuffer_Insert would be helpful.

After inserting data into ringbuffer does it actually start the UART TX operation?, if not what command to start?

Thanks

PS: very interesting using void rather than char or unsigned char on parameter, how that work?

--------------------------------------------------------------||
int RingBuffer_Pop(RINGBUFF_T *RingBuff, void *data)
--------------------------------------------------------------||
0 件の賞賛
返信
4 返答(返信)

1,238件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by OldManVimes on Tue Jul 29 05:21:54 MST 2014
Actually, there should be no need to cast since the "C" standard has specific rules when dealing with void pointers.
Try your code without the cast and find out whether the compiler still likes you. ;-)

See: http://stackoverflow.com/questions/20469958/c-when-is-casting-void-pointer-needed
The answers near the bottom are most relevant.

Any sufficiently advanced compiler performs acts indistinguishable from magic.

Vimes
0 件の賞賛
返信

1,238件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by HCTEK on Tue Jul 29 03:24:38 MST 2014
int RingBuffer_Pop(RINGBUFF_T *RingBuff, void *data)

ok maybe I cause a little confusion. This function has a pointer void as second argument which means that what it points to is not known, but the ideia for it is to work as like a "neutral pointer" . it could point to any particular type.  Void* help to write generic funtions.

When the function is called the second argument must be casted. I already tried and it worked well.

0 件の賞賛
返信

1,238件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by LabRat on Tue Jul 29 02:35:28 MST 2014

Quote: Hugo Cruz
...of that fuction....

:O  :quest:  :O


0 件の賞賛
返信

1,238件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by HCTEK on Tue Jul 29 02:04:37 MST 2014
Hello,

the "pop" function remove an element and "insert" function insert an element. The "multi" function do the previous function but for multiple elements. If you search for ring buffer on internet you will understand this basic funtions.

In the download page of LPCOpen (http://www.lpcware.com/content/nxpfile/lpcopen-platform) you will find examples using UART and I think that some of them use that functions.

The void type allow you to use any variable type as input of that fuction. Thus, you are not restricted to one type like char.


Best Regards,
Hugo
0 件の賞賛
返信