[1950] | 1 | classdef user_extension_example_class < wl_user_ext |
---|
| 2 | properties |
---|
| 3 | description; |
---|
| 4 | end |
---|
| 5 | properties(Hidden = true,Constant = true) |
---|
| 6 | CMD_EEPROM_WRITE_STRING = 1; |
---|
| 7 | CMD_EEPROM_READ_STRING = 2; |
---|
| 8 | end |
---|
| 9 | methods |
---|
| 10 | function obj = user_extension_example_class() |
---|
| 11 | obj@wl_user_ext(); |
---|
| 12 | obj.description = 'This is an example user extension class.'; |
---|
| 13 | end |
---|
| 14 | |
---|
| 15 | function out = procCmd(obj, nodeInd, node, varargin) |
---|
| 16 | %user_extension_example_class procCmd(obj, nodeInd, node, varargin) |
---|
| 17 | % obj: baseband object (when called using dot notation) |
---|
| 18 | % nodeInd: index of the current node, when wl_node is iterating over nodes |
---|
| 19 | % node: current node object (the owner of this baseband) |
---|
| 20 | % varargin: |
---|
| 21 | % Two forms of arguments for commands: |
---|
| 22 | % (...,'theCmdString', someArgs) - for commands that affect all buffers |
---|
| 23 | % (..., RF_SEL, 'theCmdString', someArgs) - for commands that affect specific RF paths |
---|
| 24 | out = []; |
---|
| 25 | |
---|
| 26 | if(ischar(varargin{1})) |
---|
| 27 | %No RF paths specified |
---|
| 28 | cmdStr = varargin{1}; |
---|
| 29 | if(length(varargin)>1) |
---|
| 30 | varargin = varargin(2:end); |
---|
| 31 | else |
---|
| 32 | varargin = {}; |
---|
| 33 | end |
---|
| 34 | else |
---|
| 35 | %RF paths specified |
---|
| 36 | rfSel = (varargin{1}); |
---|
| 37 | cmdStr = varargin{2}; |
---|
| 38 | |
---|
| 39 | if(length(varargin)>2) |
---|
| 40 | varargin = varargin(3:end); |
---|
| 41 | else |
---|
| 42 | varargin = {}; |
---|
| 43 | end |
---|
| 44 | end |
---|
| 45 | |
---|
| 46 | cmdStr = lower(cmdStr); |
---|
| 47 | switch(cmdStr) |
---|
| 48 | case 'eeprom_write_string' |
---|
| 49 | myCmd = wl_cmd(node.calcCmd(obj.GRP,obj.CMD_EEPROM_WRITE_STRING)); |
---|
| 50 | eeprom_addr = varargin{1}; |
---|
| 51 | myCmd.addArgs(eeprom_addr); |
---|
| 52 | inputString = varargin{2}; |
---|
| 53 | inputString = [inputString,0]; %null-terminate |
---|
| 54 | padLength = mod(-length(inputString),4); |
---|
| 55 | inputByte = [uint8(inputString),zeros(1,padLength)]; |
---|
| 56 | inputInt = typecast(inputByte,'uint32'); |
---|
| 57 | myCmd.addArgs(inputInt); |
---|
| 58 | node.sendCmd(myCmd); |
---|
| 59 | case 'eeprom_read_string' |
---|
| 60 | myCmd = wl_cmd(node.calcCmd(obj.GRP,obj.CMD_EEPROM_READ_STRING)); |
---|
| 61 | eeprom_addr = varargin{1}; |
---|
| 62 | myCmd.addArgs(eeprom_addr); |
---|
| 63 | readLength = varargin{2}+1; %the +1 is for the termination character |
---|
| 64 | padLength = mod(-readLength,4); |
---|
| 65 | myCmd.addArgs(readLength+padLength); |
---|
| 66 | resp = node.sendCmd(myCmd); |
---|
| 67 | ret = resp.getArgs(); |
---|
| 68 | outputByte = typecast(ret,'uint8'); |
---|
| 69 | out = char(outputByte); |
---|
| 70 | out = out(1:varargin{2}); |
---|
| 71 | end |
---|
| 72 | end |
---|
| 73 | |
---|
| 74 | end |
---|
| 75 | end |
---|