[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r4427 - gnuradio/branches/developers/trondeau/udp/gnur
From: |
trondeau |
Subject: |
[Commit-gnuradio] r4427 - gnuradio/branches/developers/trondeau/udp/gnuradio-core/src/lib/io |
Date: |
Wed, 7 Feb 2007 21:11:06 -0700 (MST) |
Author: trondeau
Date: 2007-02-07 21:11:06 -0700 (Wed, 07 Feb 2007)
New Revision: 4427
Modified:
gnuradio/branches/developers/trondeau/udp/gnuradio-core/src/lib/io/gr_udp_sink.cc
gnuradio/branches/developers/trondeau/udp/gnuradio-core/src/lib/io/gr_udp_sink.h
gnuradio/branches/developers/trondeau/udp/gnuradio-core/src/lib/io/gr_udp_sink.i
gnuradio/branches/developers/trondeau/udp/gnuradio-core/src/lib/io/gr_udp_source.cc
gnuradio/branches/developers/trondeau/udp/gnuradio-core/src/lib/io/gr_udp_source.h
gnuradio/branches/developers/trondeau/udp/gnuradio-core/src/lib/io/gr_udp_source.i
Log:
minor fixes: data types, variable names, some handling
Modified:
gnuradio/branches/developers/trondeau/udp/gnuradio-core/src/lib/io/gr_udp_sink.cc
===================================================================
---
gnuradio/branches/developers/trondeau/udp/gnuradio-core/src/lib/io/gr_udp_sink.cc
2007-02-07 21:12:21 UTC (rev 4426)
+++
gnuradio/branches/developers/trondeau/udp/gnuradio-core/src/lib/io/gr_udp_sink.cc
2007-02-08 04:11:06 UTC (rev 4427)
@@ -83,7 +83,7 @@
}
// Turn on reuse address
- bool opt_val = true;
+ int opt_val = true;
if(setsockopt(d_socket, SOL_SOCKET, SO_REUSEADDR, (void*)&opt_val,
sizeof(int)) == -1) {
perror("SO_REUSEADDR");
throw std::runtime_error("can't set socket option SO_REUSEADDR");
@@ -131,8 +131,8 @@
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
- char *in = (char *) input_items[0];
- ssize_t bytes=0, bytes_sent=0, bytes_to_send=0;
+ const char *in = (const char *) input_items[0];
+ ssize_t r=0, bytes_sent=0, bytes_to_send=0;
ssize_t total_size = noutput_items*d_itemsize;
#if SNK_VERBOSE
@@ -140,11 +140,11 @@
#endif
while(bytes_sent < total_size) {
- //bytes_to_send = (bytes_sent+d_mtu < total_size ? d_mtu :
total_size-bytes_sent);
bytes_to_send = std::min(d_mtu, (total_size-bytes_sent));
- bytes = send(d_socket, (in+bytes_sent), bytes_to_send, 0);
- bytes_sent += bytes;
+ r = send(d_socket, (in+bytes_sent), bytes_to_send, 0);
+ // FIX ERROR HANDLING
+ bytes_sent += r;
#if SNK_VERBOSE
printf("\tbyte sent: %d bytes\n", bytes);
Modified:
gnuradio/branches/developers/trondeau/udp/gnuradio-core/src/lib/io/gr_udp_sink.h
===================================================================
---
gnuradio/branches/developers/trondeau/udp/gnuradio-core/src/lib/io/gr_udp_sink.h
2007-02-07 21:12:21 UTC (rev 4426)
+++
gnuradio/branches/developers/trondeau/udp/gnuradio-core/src/lib/io/gr_udp_sink.h
2007-02-08 04:11:06 UTC (rev 4427)
@@ -34,6 +34,10 @@
/*!
* \brief Write stream to an Udp port (over UDP).
* \ingroup sink
+ * source
+ * destination
+ * domain name
+ * mtu size (default=1500)
*/
gr_udp_sink_sptr
@@ -87,9 +91,6 @@
*/
void close();
- /*! \brief set the MTU of the socket */
- void set_mtu(int mtu) { d_mtu = mtu; }
-
/*! \brief return the MTU of the socket */
int mtu() { return d_mtu; }
Modified:
gnuradio/branches/developers/trondeau/udp/gnuradio-core/src/lib/io/gr_udp_sink.i
===================================================================
---
gnuradio/branches/developers/trondeau/udp/gnuradio-core/src/lib/io/gr_udp_sink.i
2007-02-07 21:12:21 UTC (rev 4426)
+++
gnuradio/branches/developers/trondeau/udp/gnuradio-core/src/lib/io/gr_udp_sink.i
2007-02-08 04:11:06 UTC (rev 4427)
@@ -39,7 +39,6 @@
bool open();
void close();
- void set_mtu(int mtu) { d_mtu = mtu; }
int mtu() { return d_mtu; }
public:
Modified:
gnuradio/branches/developers/trondeau/udp/gnuradio-core/src/lib/io/gr_udp_source.cc
===================================================================
---
gnuradio/branches/developers/trondeau/udp/gnuradio-core/src/lib/io/gr_udp_source.cc
2007-02-07 21:12:21 UTC (rev 4426)
+++
gnuradio/branches/developers/trondeau/udp/gnuradio-core/src/lib/io/gr_udp_source.cc
2007-02-08 04:11:06 UTC (rev 4427)
@@ -73,7 +73,7 @@
}
// Turn on reuse address
- bool opt_val = true;
+ int opt_val = 1;
if(setsockopt(d_socket, SOL_SOCKET, SO_REUSEADDR, (void*)&opt_val,
sizeof(int)) == -1) {
perror("SO_REUSEADDR");
throw std::runtime_error("can't set socket option SO_REUSEADDR");
@@ -126,7 +126,7 @@
gr_vector_void_star &output_items)
{
char *out = (char *) output_items[0];
- ssize_t bytes_to_receive=0, bytes_received=0, bytes=0;
+ ssize_t r=0, nbytes=0, bytes_received=0;
ssize_t total_bytes = (ssize_t)(d_itemsize*noutput_items);
#if SRC_VERBOSE
@@ -135,12 +135,12 @@
// Remove items from temp buffer if they are in there
if(d_residual) {
- bytes_to_receive = std::min(d_residual, total_bytes);
- memcpy(out, d_temp_buff+d_temp_offset, bytes_to_receive);
- bytes_received = bytes_to_receive;
+ nbytes = std::min(d_residual, total_bytes);
+ memcpy(out, d_temp_buff+d_temp_offset, nbytes);
+ bytes_received = nbytes;
#if SRC_VERBOSE
- printf("\tTemp buff size: %d offset: %d (bytes_to_receive: %d)
(noutput_items: %d)\n",
+ printf("\tTemp buff size: %d offset: %d (bytes_received: %d)
(noutput_items: %d)\n",
d_residual, d_temp_offset, bytes_received, noutput_items);
#endif
@@ -148,22 +148,22 @@
out += bytes_received;
// Update indexing of amount of bytes left in the buffer
- d_residual -= bytes_to_receive;
+ d_residual -= nbytes;
d_temp_offset = d_temp_offset+d_residual;
}
- while((bytes_received < total_bytes) && (bytes>-1)) {
+ while(bytes_received < total_bytes) {
// get the data into our output buffer and record the number of bytes
// This is a non-blocking call with a timeout set in the constructor
- bytes = recv(d_socket, d_temp_buff, d_mtu, 0); // get the entire MTU or
the rest of what's available
+ r = recv(d_socket, d_temp_buff, d_mtu, 0); // get the entire MTU or the
rest of what's available
// Check if there was a problem; forget it if the operation just timed out
- if(bytes == -1) {
+ if(r == -1) {
if(errno == EAGAIN) { // handle non-blocking call timeout
#if SRC_VERBOSE
printf("UDP receive timed out\n");
#endif
- break;
+ continue;
}
else {
perror("udp_source");
@@ -172,23 +172,26 @@
}
else {
// Calculate the number of bytes we can take from the buffer in this call
- bytes_to_receive = std::min(bytes, total_bytes-bytes_received);
+ nbytes = std::min(r, total_bytes-bytes_received);
// copy the number of bytes we want to look at here
- memcpy(out, d_temp_buff, bytes_to_receive);
+ memcpy(out, d_temp_buff, nbytes);
- d_residual=bytes-bytes_to_receive; // save the
number of bytes stored
- d_temp_offset=bytes_to_receive; // reset buffer
index
+ d_residual = r - nbytes; // save the number of
bytes stored
+ d_temp_offset=nbytes; // reset buffer index
// keep track of the total number of bytes received
- bytes_received += bytes_to_receive;
+ bytes_received += nbytes;
// increment the pointer
- out += bytes_to_receive;
+ out += nbytes;
+
+ // break here
+ // Immediately return when data comes in
}
#if SNK_VERBOSE
- printf("\tbytes received: %d bytes (bytes_to_receive: %d)\n", bytes,
bytes_to_receive);
+ printf("\tbytes received: %d bytes (nbytes: %d)\n", bytes, nbytes);
#endif
}
@@ -196,5 +199,7 @@
printf("Total Bytes Received: %d (noutput_items=%d)\n", bytes_received,
noutput_items);
#endif
+ // return biggest legal increment (not fractional)
return noutput_items;
}
+
Modified:
gnuradio/branches/developers/trondeau/udp/gnuradio-core/src/lib/io/gr_udp_source.h
===================================================================
---
gnuradio/branches/developers/trondeau/udp/gnuradio-core/src/lib/io/gr_udp_source.h
2007-02-07 21:12:21 UTC (rev 4426)
+++
gnuradio/branches/developers/trondeau/udp/gnuradio-core/src/lib/io/gr_udp_source.h
2007-02-08 04:11:06 UTC (rev 4427)
@@ -79,9 +79,6 @@
*/
void close();
- /*! \brief set the MTU of the socket */
- void set_mtu(int mtu) { d_mtu = mtu; }
-
/*! \brief return the MTU of the socket */
int mtu() { return d_mtu; }
Modified:
gnuradio/branches/developers/trondeau/udp/gnuradio-core/src/lib/io/gr_udp_source.i
===================================================================
---
gnuradio/branches/developers/trondeau/udp/gnuradio-core/src/lib/io/gr_udp_source.i
2007-02-07 21:12:21 UTC (rev 4426)
+++
gnuradio/branches/developers/trondeau/udp/gnuradio-core/src/lib/io/gr_udp_source.i
2007-02-08 04:11:06 UTC (rev 4427)
@@ -37,7 +37,6 @@
bool open();
void close();
- void set_mtu(int mtu) { d_mtu = mtu; }
int mtu() { return d_mtu; }
};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r4427 - gnuradio/branches/developers/trondeau/udp/gnuradio-core/src/lib/io,
trondeau <=