source: ResearchApps/PHY/WARPLAB/WARPLab7/M_Code_Examples/user_extension/user_extension_script.m

Last change on this file was 2052, checked in by chunter, 10 years ago

slight modification to user extension script and wl_ver now prints the location of the WARPLab framework that is currently in MATLAB's path

File size: 1.1 KB
Line 
1%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2% user_extension_script.m
3%
4% In this example, we attach a user_extension_example_class object to a
5% node and use it to send custom commands that allow us to write to and
6% read from the EEPROM located on the board.
7%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8
9clear;
10NUMNODES = 1;
11nodes = wl_initNodes(NUMNODES);
12wl_setUserExtension(nodes,user_extension_example_class);
13
14eeprom_address = 0; %starting address
15
16num_characters = 11;
17curr_eeprom = wl_userExtCmd(nodes,'eeprom_read_string',eeprom_address,num_characters);
18
19fprintf('\n\nCurrent EEPROM Contents:\n');
20for n = 1:NUMNODES
21    if(iscell(curr_eeprom))
22        fprintf('Node %d: ''%s''\n',n,curr_eeprom{n});
23    else
24        %In the case of 1 node, the return will not be a cell array,
25        %so we can just directly print it.
26        fprintf('Node %d: ''%s''\n',n,curr_eeprom);
27    end
28end
29
30strWrite = 'Hello World';
31fprintf('\n\nWriting EEPROM Contents:''%s''\n',strWrite);
32wl_userExtCmd(nodes,'eeprom_write_string',eeprom_address, strWrite);
Note: See TracBrowser for help on using the repository browser.