DSPRelated.com
Forums

TI NDK Functions Usage

Started by Kandy January 5, 2012
Hi All,

I am using TMS320C642 DSP processor with whole set of TI libraries. I would
like to know more about insights of NDK library for the following scenarios

I use the "send" method to send as much bytes as per the need. As far as I
have seen, this does not block until the client reads them. It basically
pushes it into some buffer and says no error if it is able to do it. Let
say if the client is not able to read it at all, only when the buffer gets
overflowed it results in error. That too it gets into a loop inside "send"
command and prints "Persist Timeout" in Code composer studio and it is not
coming out at all.

a) Generally the buffer size is of 80K. When I tried setting the buffer
through "setsockopt" function, I was not able to do it properly. A simple
example would help in this case which explains how to set buffer size.

b) Is it possible for me to know, by some means that a connection is lost.
Say the client is closed abruptly or it is restarted. Will I be knowing it
by any standard means. A example will help me a lot.

c) As of now, as I told, even if connection is lost, when I send some n
bytes through "send" function, if the TX buffer size is N where N > n, it
puts into buffer and then says it is successful. Is there a way to predict
if client is not receiving properly. Let us say i write m bytes first where
m < n and check the size of TX buffer and get the value of m and based on
that arrive a conclusion that client is not reading back, then close the
socket connection properly and start listening on it. Please explain me
what functions I can use to read TX buffer data count.

Thanks In Advance
Kandy
Kandy-
> I am using TMS320C642 DSP processor with whole set of TI libraries. I would like to
> know more about insights of NDK library for the following scenarios I use the
> "send" method to send as much bytes as per the need. As far as I have seen, this
> does not block until the client reads them. It basically pushes it into some buffer
> and says no error if it is able to do it. Let say if the client is not able to read
> it at all, only when the buffer gets overflowed it results in error. That too it
> gets into a loop inside "send" command and prints "Persist Timeout" in Code
> composer studio and it is not coming out at all. a) Generally the buffer size is of
> 80K. When I tried setting the buffer through "setsockopt" function, I was not able
> to do it properly. A simple example would help in this case which explains how to
> set buffer size. b) Is it possible for me to know, by some means that a connection
> is lost. Say the client is closed abruptly or it is restarted. Will I be knowing it
> by any standard means. A example will help me a lot. c) As of now, as I told, even
> if connection is lost, when I send some n bytes through "send" function, if the TX
> buffer size is N where N > n, it puts into buffer and then says it is successful.
> Is there a way to predict if client is not receiving properly. Let us say i write m
> bytes first where m < n and check the size of TX buffer and get the value of m and
> based on that arrive a conclusion that client is not reading back, then close the
> socket connection properly and start listening on it. Please explain me what
> functions I can use to read TX buffer data count.

I assume you're using an Ethernet port (maybe the EVM DM642 board?) If not, and
you're sending data back to CCS, then over Ethernet from there, that's different, so
you have to be clear on this.

Your questions have more to do with understanding basic sockets C code, and less to
do with TI DSPs. If you want to send data without blocking you can use IP/UDP. If
you want to know whether a client has received data (or how much) you can use TCP/IP
and check status of the connection using other sockets functions. Sockets code is
widely used -- servers, microprocessors, Windows, etc -- so lots of examples on the
web.

-Jeff
Hi Jeff and Everyone,
Thanks for the reply. I am using a custom prototype board developed by
myself which has a Ethernet port and have been able to communicate with a
client (which is a UI written in C#). This UI emulates functioning of a
PLC, which establishes TCP communication through Ethernet wire with DSP and
controls a motor.

On the field sometimes the firmware hangs, when we reasoned it out, the way
TCP IP was implemented using NDK libraries was not good enough to address
the issues that I have listed out. I checked out a lot of examples and I
was not able to find specific to issues which I have listed below.

1) Checking the status of TX buffer. So that if Client is not receiving on
the other end, we will be able to find ourselves through the size of Tx
buffer getting decreased.
2) Ability to check and find whether a connection status is good or not
without sending or receiving data. If the status is bad then I will close
the socket and start listening on that port.
It would be nice if I get explanation about what function would be very
useful to me and directions to examples of it in the web.

Thanks
Kandy

On Fri, Jan 6, 2012 at 1:03 AM, Jeff Brower wrote:

> ** Kandy-
> I am using TMS320C642 DSP processor with whole set of TI libraries. I
> would like to know more about insights of NDK library for the following
> scenarios I use the "send" method to send as much bytes as per the need.
> As far as I have seen, this does not block until the client reads them. It
> basically pushes it into some buffer and says no error if it is able to do
> it. Let say if the client is not able to read it at all, only when the
> buffer gets overflowed it results in error. That too it gets into a loop
> inside "send" command and prints "Persist Timeout" in Code composer studio
> and it is not coming out at all. a) Generally the buffer size is of 80K.
> When I tried setting the buffer through "setsockopt" function, I was not
> able to do it properly. A simple example would help in this case which
> explains how to set buffer size. b) Is it possible for me to know, by
> some means that a connection is lost. Say the client is closed abruptly or
> it is restarted. Will I be knowing it by any standard means. A example will
> help me a lot. c) As of now, as I told, even if connection is lost, when
> I send some n bytes through "send" function, if the TX buffer size is N
> where N > n, it puts into buffer and then says it is successful. Is there a
> way to predict if client is not receiving properly. Let us say i write m
> bytes first where m < n and check the size of TX buffer and get the value
> of m and based on that arrive a conclusion that client is not reading back,
> then close the socket connection properly and start listening on it. Please
> explain me what functions I can use to read TX buffer data count.
> I assume you're using an Ethernet port (maybe the EVM DM642 board?) If
> not, and you're sending data back to CCS, then over Ethernet from there,
> that's different, so you have to be clear on this.
>
> Your questions have more to do with understanding basic sockets C code,
> and less to do with TI DSPs. If you want to send data without blocking you
> can use IP/UDP. If you want to know whether a client has received data (or
> how much) you can use TCP/IP and check status of the connection using other
> sockets functions. Sockets code is widely used -- servers,
> microprocessors, Windows, etc -- so lots of examples on the web.
>
> -Jeff
>