commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r6023 - gnuradio/branches/developers/gnychis/inband/us


From: gnychis
Subject: [Commit-gnuradio] r6023 - gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband
Date: Wed, 18 Jul 2007 16:14:12 -0600 (MDT)

Author: gnychis
Date: 2007-07-18 16:14:09 -0600 (Wed, 18 Jul 2007)
New Revision: 6023

Modified:
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_inband_usb_packet.h
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
Log:
USRP server now reading SPI read replies and checking the RID to pass it back to
the proper application.


Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_inband_usb_packet.h
===================================================================
--- 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_inband_usb_packet.h
   2007-07-18 22:06:15 UTC (rev 6022)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_inband_usb_packet.h
   2007-07-18 22:14:09 UTC (rev 6023)
@@ -788,8 +788,20 @@
       }
 
       case OP_SPI_READ_REPLY:
-        return PMT_NIL;
+      {
+        pmt_t rid       = pmt_from_long((subpkt >> CS_RID_SHIFT) & 
CS_RID_MASK);
+        
+        // Make a u8 vector to dump the data from the packet into
+        size_t spi_data_len;
+        pmt_t spi_data  = pmt_make_u8vector(len - 2, 0);   // skip 
rid+mbz+addr = 2 bytes
+        uint8_t *w_data  = 
+            (uint8_t *) pmt_u8vector_writeable_elements(spi_data, 
spi_data_len);
 
+        memcpy(w_data, d_payload + payload_offset + 4, spi_data_len);  // skip 
first word
+
+        return pmt_list3(s_op_spi_read_reply, rid, spi_data);
+      }
+
       case OP_PING_FIXED:
       {
         pmt_t rid     = pmt_from_long((subpkt >> CS_RID_SHIFT) & CS_RID_MASK);

Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
===================================================================
--- 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc 
    2007-07-18 22:06:15 UTC (rev 6022)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc 
    2007-07-18 22:14:09 UTC (rev 6023)
@@ -1207,6 +1207,33 @@
                                              pmt_list3(rid, i2c_addr, 
i2c_data))));
     }
 
+    //------------------ SPI READ REPLY -------------------//
+    else if(pmt_eq(op_symbol, s_op_spi_read_reply)) {
+      
+      pmt_t rid       = pmt_nth(1, sub_packet);
+      pmt_t spi_data  = pmt_nth(2, sub_packet);
+
+      if(verbose)
+        std::cout << "[USRP_SERVER] Found SPI read reply "
+                  << "("
+                  << "RID: " << rid << ", "
+                  << "Data: " << spi_data
+                  << ")\n";
+
+      // Bounds check the RID
+      if(pmt_to_long(rid) > D_OP_SPI_READ_MAX_RID)
+        return;
+
+      pmt_t owner = d_op_spi_read_owners[pmt_to_long(rid)];
+
+      if((port = tx_port_index(owner)) != -1)
+        d_tx[port]->send(s_response_from_control_channel,
+                         pmt_list3(invocation_handle,
+                                   PMT_T,
+                                   pmt_list2(s_op_spi_read_reply,
+                                             pmt_list2(rid, spi_data))));
+    }
+
     // Each subpacket has an unaccounted for 2 bytes which is the opcode
     // and the length field
     curr_payload += len + 2;





reply via email to

[Prev in Thread] Current Thread [Next in Thread]