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 | |
---|
9 | clear; |
---|
10 | NUMNODES = 1; |
---|
11 | nodes = wl_initNodes(NUMNODES); |
---|
12 | wl_setUserExtension(nodes,user_extension_example_class); |
---|
13 | |
---|
14 | eeprom_address = 0; %starting address |
---|
15 | |
---|
16 | num_characters = 11; |
---|
17 | curr_eeprom = wl_userExtCmd(nodes,'eeprom_read_string',eeprom_address,num_characters); |
---|
18 | |
---|
19 | fprintf('\n\nCurrent EEPROM Contents:\n'); |
---|
20 | for 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 |
---|
28 | end |
---|
29 | |
---|
30 | strWrite = 'Hello World'; |
---|
31 | fprintf('\n\nWriting EEPROM Contents:''%s''\n',strWrite); |
---|
32 | wl_userExtCmd(nodes,'eeprom_write_string',eeprom_address, strWrite); |
---|