Il giorno mar, 20/03/2007 alle 10.09 +0100, Davide Anastasia ha scritto:
> > Maybe we should make gr_complex_short be  a typedef for
> > complex<short> 
> > and output those. 
> 
> Yep, in this way std::complex make conversion between float and short
> transparently. Ok, I'll work in this direction. Actually I'm working
> on
> usrp1_source_s.cc. I'll send you my work when is completed, tested and
> fully working. Soon maybe.
> 
> Regards, 

Hi List,
I attach to this mail the works I've done on the gr-usrp driver, in
special way on usrp1_source_s. It's not a very beautiful code, but work!
Any suggestion is appreciate.

Regards,
-- 
Davide Anastasia

web: http://www.davideanastasia.com/
email: [EMAIL PROTECTED]
Binary files gr-usrp.old/src/.libs/_usrp1.so and gr-usrp/src/.libs/_usrp1.so differ
Binary files gr-usrp.old/src/.libs/_usrp1.soT and gr-usrp/src/.libs/_usrp1.soT differ
Binary files gr-usrp.old/src/.libs/usrp1_source_base.o and gr-usrp/src/.libs/usrp1_source_base.o differ
Binary files gr-usrp.old/src/.libs/usrp1_source_s.o and gr-usrp/src/.libs/usrp1_source_s.o differ
Only in gr-usrp.old/src: usrp1.pyc
diff -ru gr-usrp.old/src/usrp1_source_base.cc gr-usrp/src/usrp1_source_base.cc
--- gr-usrp.old/src/usrp1_source_base.cc	2007-01-31 08:36:56.000000000 +0100
+++ gr-usrp/src/usrp1_source_base.cc	2007-03-22 11:56:51.000000000 +0100
@@ -71,7 +71,9 @@
 unsigned int
 usrp1_source_base::sizeof_basic_sample() const
 {
-  return usrp_standard_rx::format_width(d_usrp->format()) / 8;
+  unsigned int usrp_width = usrp_standard_rx::format_width(d_usrp->format());
+  if (usrp_width >= 8) return usrp_standard_rx::format_width(d_usrp->format()) / 8;
+  else return 1;
 }
 
 bool
diff -ru gr-usrp.old/src/usrp1_source_s.cc gr-usrp/src/usrp1_source_s.cc
--- gr-usrp.old/src/usrp1_source_s.cc	2007-01-31 08:36:56.000000000 +0100
+++ gr-usrp/src/usrp1_source_s.cc	2007-03-22 12:03:26.000000000 +0100
@@ -28,9 +28,16 @@
 #include <gr_io_signature.h>
 #include <usrp_standard.h>
 #include <usrp_bytesex.h>
+// #include <iostream>
+
 
 static const int NBASIC_SAMPLES_PER_ITEM = 1;
 
+static const int RANGE_1BIT = 1;		// setting gain
+static const int RANGE_2BIT = 1;
+static const int RANGE_4BIT = 1;
+static const int RANGE_8BIT = 8;
+
 usrp1_source_s_sptr
 usrp1_make_source_s (int which_board, 
 		     unsigned int decim_rate,
@@ -103,6 +110,9 @@
   unsigned sbs = sizeof_basic_sample();
   unsigned nusrp_bytes_per_item = NBASIC_SAMPLES_PER_ITEM * sbs;
 
+  unsigned char traw;		// 8 bit
+  unsigned short tcycle;
+
   int nitems = std::min (output_items_available,
 			 (int)(usrp_buffer_length / nusrp_bytes_per_item));
 
@@ -111,8 +121,44 @@
 
   switch(sbs){
   case 1:
-    for (int i = 0; i < nitems; i++){
-      out[i] = s8[i] << 8;
+    for (int i = 0, i_in = 0; i < nitems; i++, i_in++){
+	switch ( format_width(format()) ) {	// Same as d_usrp->format_width()
+		case 1:
+		traw = s8[i_in];
+		for ( int j = 0; j <= 7; j++ ) {
+			out[i] = 0;						// Setting zero
+			tcycle = (short int)(( traw >> j ) & 0x01);	// Masking
+			out[i] = (tcycle * RANGE_1BIT);			// Saving sample
+			
+			(j != 7) ? i++ : 0;
+			if ( i >= nitems ) break;
+		}
+		
+		break;
+		case 2:		
+		traw = s8[i_in];
+		for ( int j=0; j <= 3; j++) {
+			tcycle = (short int)((traw >> (j*2)) & 0x03 );
+			out[i] = ( tcycle * RANGE_2BIT );
+
+			(j != 3) ? i++ : 0;
+			if ( i >= nitems ) break;
+		}
+		break;
+		case 4:		
+		traw = s8[i];
+		for ( int j=0; j <= 1; j++) {	//  Ugly code!
+			tcycle = (short int)((traw >> (j*4)) & 0x0F );
+			out[i] = ( tcycle * RANGE_4BIT );
+
+			(j != 1) ? i++ : 0;
+			if ( i >= nitems ) break;
+		}
+		break;
+		case 8:
+		default:
+      		out[i] = usrp_to_host_short(s8[i] * RANGE_8BIT);
+	}
     }
     break;
 
_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to