[[TracNav(WARPLab/TOC)]] = WARPLab 7: Porting Code from old WARPLab = The basic flow of an experiment is the same across all versions of WARPLab. However WARPLab 7 has been designed to simplify experiments utilizing multiple nodes, each with multiple RF interfaces. The code samples below illustrate equivalent processes in WARPLab 6 and WARPLab 7, emphasizing the more compact and portable syntax available in the WARPLab 7 framework. The code on this page is '''not''' a complete example; please see [wiki:../Examples the WARPLab 7 examples] for ready-to-use scripts. ---- '''Initialization''': WARPLab 7 provides a utility script [wiki:../Reference/Utility#wl_initNodes wl_initNodes] which simplifies the process of establishing a connection from MATLAB to multiple WARP nodes running the WARPLab reference design. The array returned by {{{wl_initNodes}}} replaces the individual socket handles used in WARPLab 6. {{{#!html
}}} {{{ %WARPLab 6 %Load the many global variables for the framework warplab_defines %Initialize two WARP nodes [socketHandles, packetNum] = warplab_initialize(2); %Retrieve socket handles for the trigger and both nodes udp_Sync = socketHandles(1); udp_node1 = socketHandles(2); udp_node2 = socketHandles(3); }}} {{{#!html | }}} {{{ %WARPLab 7 %Initialize two WARP nodes nodes = wl_initNodes(2); %Retrieve IDs for available RF interfaces [RFA, RFB] = wl_getInterfaceIDs(nodes(1)); %Create an Ethernet trigger and assign it to both nodes eth_trig = wl_trigger_eth_udp_broadcast; wl_triggerManagerCmd(nodes, 'add_ethernet_trigger', eth_trig); }}} {{{#!html |
}}} {{{ %WARPLab 6 warplab_writeRegister(udp_node1, TX_DELAY, 0); warplab_writeRegister(udp_node1, TX_LENGTH, 2^14); warplab_writeRegister(udp_node2, TX_DELAY, 0); warplab_writeRegister(udp_node2, TX_LENGTH, 2^14); warplab_setRadioParameter(udp_node1, CARRIER_CHANNEL, 11); warplab_setRadioParameter(udp_node2, CARRIER_CHANNEL, 11); }}} {{{#!html | }}} {{{ %WARPLab 7 wl_basebandCmd(nodes, 'tx_delay', 0); wl_basebandCmd(nodes, 'tx_length', 2^14); wl_interfaceCmd(nodes, 'RF_ALL', 'channel', 2.4, 11); }}} {{{#!html |
}}} {{{ %WARPLab 6 %Time vector (assumes 40MHz sampling rate) t = (1/40e6) .* [0 : 2^14-1]; %Generate a 1MHz sinusoid txSigA = exp(1i*2*pi*t*1e6); %Generate a 2MHz sinusoid txSigB = exp(1i*2*pi*t*2e6); %Write the two signals to RF A and B on both nodes warplab_writeSMWO(udp_node1, RADIO2_TXDATA, txSigA); warplab_writeSMWO(udp_node1, RADIO3_TXDATA, txSigB); warplab_writeSMWO(udp_node2, RADIO2_TXDATA, txSigA); warplab_writeSMWO(udp_node2, RADIO3_TXDATA, txSigB); }}} {{{#!html | }}} {{{ %WARPLab 7 %Time column vector (assumes 40MHz sampling rate) t = (1/40e6) .* [0 : 2^14-1].'; %Generate a 1MHz sinusoid txSigA = exp(1i*2*pi*t*1e6); %Generate a 2MHz sinusoid txSigB = exp(1i*2*pi*t*2e6); %Write the two signals to RF A and B on both nodes % Use vector arguments for interface selection and per-interface signals wl_basebandCmd(nodes, [RFA RFB], 'write_IQ', [txSigA txSigB]); }}} {{{#!html |
}}} {{{ %WARPLab 6 %Enable the RF transceivers warplab_sendCmd(udp_node1, RADIO2_TXEN, packetNum); warplab_sendCmd(udp_node1, RADIO3_TXEN, packetNum); warplab_sendCmd(udp_node2, RADIO2_RXEN, packetNum); warplab_sendCmd(udp_node2, RADIO3_RXEN, packetNum); %Enable the Tx/Rx buffers warplab_sendCmd(udp_node1, RADIO2TXBUFF_TXEN, packetNum); warplab_sendCmd(udp_node1, RADIO3TXBUFF_TXEN, packetNum); warplab_sendCmd(udp_node2, RADIO2RXBUFF_RXEN, packetNum); warplab_sendCmd(udp_node2, RADIO3RXBUFF_RXEN, packetNum); %Prepare nodes for trigger reception warplab_sendCmd(udp_node1, TX_START, packetNum); warplab_sendCmd(udp_node2, RX_START, packetNum); % Send the trigger warplab_sendSync(udp_Sync); %Disable the RF transceivers warplab_sendCmd(udp_node1, RADIO2_TXDIS, packetNum); warplab_sendCmd(udp_node1, RADIO3_TXDIS, packetNum); warplab_sendCmd(udp_node2, RADIO2_RXDIS, packetNum); warplab_sendCmd(udp_node2, RADIO3_RXDIS, packetNum); %Disable the Tx/Rx buffers warplab_sendCmd(udp_node1, RADIO2TXBUFF_TXDIS, packetNum); warplab_sendCmd(udp_node1, RADIO3TXBUFF_TXDIS, packetNum); warplab_sendCmd(udp_node2, RADIO2RXBUFF_RXDIS, packetNum); warplab_sendCmd(udp_node2, RADIO3RXBUFF_RXDIS, packetNum); }}} {{{#!html | }}} {{{ %WARPLab 7 %Enable the RF transceivers wl_interfaceCmd(nodes(1), [RFA RFB], 'tx_en'); wl_interfaceCmd(nodes(2), [RFA RFB], 'rx_en'); %Enable the sample buffers wl_basebandCmd(nodes(1), [RFA RFB], 'tx_buff_en'); wl_basebandCmd(nodes(2), [RFA RFB], 'rx_buff_en'); %Send the broadcast trigger eth_trig.send(); %Disable the transceivers and buffers wl_basebandCmd(nodes, 'RF_ALL', 'tx_rx_buff_dis'); wl_interfaceCmd(nodes, 'RF_ALL', 'tx_rx_dis'); %Retrieve the IQ and RSSI samples from the Rx node rx_IQ = wl_basebandCmd(nodes(2), [RFA RFB], 'read_IQ', 0, 2^14); rx_RSSI = wl_basebandCmd(nodes(2), [RFA RFB], 'read_RSSI', 0, 2^12); }}} {{{#!html |
}}} {{{ %WARPLab 6 %Retrieve and format the IQ samples from RFA and RFB [Node2_Radio2_RawRxData] = warplab_readSMRO(udp_node2, RADIO2_RXDATA, 2^14); [Node2_Radio2_RxData] = warplab_processRawRxData(Node2_Radio2_RawRxData); [Node2_Radio3_RawRxData] = warplab_readSMRO(udp_node2, RADIO3_RXDATA, 2^14); [Node2_Radio3_RxData] = warplab_processRawRxData(Node2_Radio3_RawRxData); %Retrieve and format the RSSI samples from RFA and RFB [Node2_Radio2_RawRSSIData] = warplab_readSMRO(udp_node2, RADIO2_RSSIDATA, 2^12); [Node2_Radio2_RSSIData] = warplab_processRawRSSIData(Node2_Radio2_RawRSSIData); [Node2_Radio3_RawRSSIData] = warplab_readSMRO(udp_node2, RADIO3_RSSIDATA, 2^12); [Node2_Radio3_RSSIData] = warplab_processRawRSSIData(Node2_Radio3_RawRSSIData); }}} {{{#!html | }}} {{{ %WARPLab 7 %Retrieve the IQ and RSSI samples from both interfaces on the Rx node rx_IQ = wl_basebandCmd(nodes(2), [RFA RFB], 'read_IQ', 0, 2^14); rx_RSSI = wl_basebandCmd(nodes(2), [RFA RFB], 'read_RSSI', 0, 2^12); }}} {{{#!html |