Skip to content
Snippets Groups Projects
Commit 0b496b1a authored by Tim Stadtmann's avatar Tim Stadtmann
Browse files

Implement new CommandLayer structure

The former Command-class is split up in several subclasses; implemented
new outputStart()-method exemplarily, the rest is WIP.
parent 88f5c568
No related tags found
No related merge requests found
......@@ -126,6 +126,8 @@ classdef CommunicationInterface < handle
properties (Hidden, Access = 'private')
% Connection handle
conn;
currentData = Packet();
end
methods
......@@ -231,6 +233,12 @@ classdef CommunicationInterface < handle
brick.debug = p.Results.debug;
end
function sendStream(brick)
brick.currentData.addHeader();
brick.conn.write(brick.currentData.msg);
brick.currentData.clear();
end
function send(brick, cmd)
% Brick.send Send data to the brick
%
......@@ -287,7 +295,7 @@ classdef CommunicationInterface < handle
% Check if reply is corrupt or error byte is set
try
reply = Command(rmsg);
reply = Packet(rmsg);
catch ME
corrupt = 1;
if ~isempty(strfind(ME.identifier, 'CorruptPacket'))
......@@ -311,7 +319,7 @@ classdef CommunicationInterface < handle
while corrupt && retries
rmsg = brick.conn.read();
try
reply = Command(rmsg);
reply = Packet(rmsg);
corrupt = 0;
catch
retries = retries-1;
......@@ -353,7 +361,7 @@ classdef CommunicationInterface < handle
% Example::
% voltage = b.uiReadVbatt()
cmd = Command();
cmd = Packet();
cmd.addHeaderDirectReply(42,4,0);
cmd.opUI_READ_GET_VBATT(0);
cmd.addLength();
......@@ -375,7 +383,7 @@ classdef CommunicationInterface < handle
% Example::
% level = b.uiReadLbatt()
cmd = Command();
cmd = Packet();
cmd.addHeaderDirectReply(42,1,0);
cmd.opUI_READ_GET_LBATT(0);
cmd.addLength();
......@@ -402,7 +410,7 @@ classdef CommunicationInterface < handle
% Example::
% b.soundTest()
cmd = Command();
cmd = Packet();
cmd.addHeaderDirectReply(42,1,0);
cmd.opSOUND_TEST(0);
cmd.addLength();
......@@ -423,7 +431,7 @@ classdef CommunicationInterface < handle
% Example::
% b.soundReady()
cmd = Command();
cmd = Packet();
cmd.addHeaderDirectReply(42,0,0);
cmd.opSOUND_READY();
cmd.addLength();
......@@ -446,7 +454,7 @@ classdef CommunicationInterface < handle
% Example::
% b.soundPlayTone(5,400,500)
cmd = Command();
cmd = Packet();
cmd.addHeaderDirect(42,0,0);
cmd.opSOUND_TONE(volume,frequency,duration);
cmd.addLength();
......@@ -462,7 +470,7 @@ classdef CommunicationInterface < handle
% Example::
% b.soundStopTone()
cmd = Command();
cmd = Packet();
cmd.addHeaderDirect(42,0,0);
cmd.opSOUND_BREAK;
cmd.addLength();
......@@ -505,7 +513,7 @@ classdef CommunicationInterface < handle
% types = b.inputDeviceList();
%
cmd = Command();
cmd = Packet();
cmd.addHeaderDirectReply(42,5,0);
cmd.opINPUT_DEVICE_LIST(4,0,4);
cmd.addLength();
......@@ -531,7 +539,7 @@ classdef CommunicationInterface < handle
% Example::
% name = b.inputDeviceGetName(0,SensorPort.Sensor1)
cmd = Command();
cmd = Packet();
cmd.addHeaderDirectReply(42,12,0);
cmd.opINPUT_DEVICE_GET_NAME(layer,no,12,0);
cmd.addLength();
......@@ -559,7 +567,7 @@ classdef CommunicationInterface < handle
%
% Example::
% [type,mode] = b.inputDeviceTypeMode(0,SensorPort.Sensor1)
cmd = Command();
cmd = Packet();
cmd.addHeaderDirectReply(42,2,0);
cmd.opINPUT_DEVICE_GET_TYPEMODE(layer,no,0,1);
cmd.addLength();
......@@ -574,7 +582,7 @@ classdef CommunicationInterface < handle
% Implemented @ MMI
function inputDeviceSetTypeMode(brick,oldType,oldMode,newType,newMode)
cmd = Command();
cmd = Packet();
cmd.addHeaderDirectReply(42,0,0);
cmd.opINPUT_DEVICE_SET_TYPEMODE(oldType,oldMode,newType,newMode);
cmd.addLength();
......@@ -599,7 +607,7 @@ classdef CommunicationInterface < handle
% mode = b.inputDeviceGetModeName(0,SensorPort.Sensor1,Device.Bumps)
% -> mode = BUMPS afterwards, if touch sensor is connected.
cmd = Command();
cmd = Packet();
cmd.addHeaderDirectReply(42,12,0);
cmd.opINPUT_DEVICE_GET_MODENAME(layer,no,mode,12,0);
cmd.addLength();
......@@ -629,7 +637,7 @@ classdef CommunicationInterface < handle
% conn = b.inputDeviceGetConnection(0,SensorPort.Sensor1)
% -> conn = Device.CONN_NONE (if no sensor is detected at Port1)
cmd = Command();
cmd = Packet();
cmd.addHeaderDirectReply(42,1,0);
cmd.opINPUT_DEVICE_GET_CONNECTION(layer,no,0);
cmd.addLength();
......@@ -656,7 +664,7 @@ classdef CommunicationInterface < handle
% Example::
% [min,max] = brick.inputDeviceGetMinMax(0,SensorPort.Sensor1);
cmd = Command();
cmd = Packet();
cmd.addHeaderDirectReply(42,8,0);
cmd.opINPUT_DEVICE_GET_MINMAX(layer,no,0,4);
cmd.addLength();
......@@ -688,7 +696,7 @@ classdef CommunicationInterface < handle
% Example::
% changes = brick.inputDeviceGetChanges(0,SensorPort.Sensor1)
cmd = Command();
cmd = Packet();
cmd.addHeaderDirectReply(42,4,0);
cmd.opINPUT_DEVICE_GET_CHANGES(layer,no,0);
cmd.addLength();
......@@ -724,7 +732,7 @@ classdef CommunicationInterface < handle
% Example::
% changes = brick.inputDeviceGetFormat(0,SensorPort.Sensor1)
cmd = Command();
cmd = Packet();
cmd.addHeaderDirectReply(42,4,0);
cmd.opINPUT_DEVICE_GET_FORMAT(layer,no,0,1,2,3);
cmd.addLength();
......@@ -754,7 +762,7 @@ classdef CommunicationInterface < handle
% Example::
% changes = brick.inputDeviceGetBumps(0,SensorPort.Sensor1)
cmd = Command();
cmd = Packet();
cmd.addHeaderDirectReply(42,4,0);
cmd.opINPUT_DEVICE_GET_BUMPS(layer,no,0);
cmd.addLength();
......@@ -784,7 +792,7 @@ classdef CommunicationInterface < handle
% Example::
% name = b.inputDeviceSymbol(0,SensorPort.Sensor1)
cmd = Command();
cmd = Packet();
cmd.addHeaderDirectReply(42,5,0);
cmd.opINPUT_DEVICE_GET_SYMBOL(layer,no,5,0);
cmd.addLength();
......@@ -810,7 +818,7 @@ classdef CommunicationInterface < handle
% Example::
% name = b.inputDeviceClrChanges(0,SensorPort.Sensor1)
cmd = Command();
cmd = Packet();
cmd.addHeaderDirect(42,0,0);
cmd.opINPUT_DEVICE_CLR_CHANGES(layer,no);
cmd.addLength();
......@@ -829,7 +837,7 @@ classdef CommunicationInterface < handle
% Example::
% name = b.inputDeviceClrAll(0)
cmd = Command();
cmd = Packet();
% cmd.addHeaderDirectReply(42,5,0);
cmd.addHeaderDirect(42,0,0);
cmd.opINPUT_DEVICE_CLR_ALL(layer);
......@@ -852,7 +860,7 @@ classdef CommunicationInterface < handle
% Example::
% b.inputReady(0,SensorPort.Sensor1)
cmd = Command();
cmd = Packet();
cmd.addHeaderDirectReply(42,0,0);
cmd.opINPUT_READY(layer,no);
cmd.addLength();
......@@ -877,7 +885,7 @@ classdef CommunicationInterface < handle
% Example::
% state = b.inputTest(0,SensorPort.Sensor1)
cmd = Command();
cmd = Packet();
cmd.addHeaderDirectReply(42,1,0);
cmd.opINPUT_TEST(layer,no,0);
cmd.addLength();
......@@ -911,7 +919,7 @@ classdef CommunicationInterface < handle
% -> returns seemingly pointless values (as
% expected)
cmd = Command();
cmd = Packet();
cmd.addHeaderDirectReply(42,1,0);
cmd.opINPUT_READ(layer,no,0,mode,0);
cmd.addLength();
......@@ -941,7 +949,7 @@ classdef CommunicationInterface < handle
% reading = b.inputReadSI(0,SensorPort.Sensor1,Device.USDistCM)
% reading = b.inputReadSI(0,SensorPort.Sensor1,Device.Pushed)
cmd = Command();
cmd = Packet();
cmd.addHeaderDirectReply(42,4,0);
cmd.opINPUT_READSI(layer,no,0,mode,0);
cmd.addLength();
......@@ -971,7 +979,7 @@ classdef CommunicationInterface < handle
% reading = b.inputReadSI(0,SensorPort.Sensor1,Device.USDistCM)
% reading = b.inputReadSI(0,SensorPort.Sensor1,Device.Pushed)
cmd = Command();
cmd = Packet();
cmd.addHeaderDirectReply(42,4,0);
cmd.opINPUT_READSI(layer,no,type,mode,0);
cmd.addLength();
......@@ -998,7 +1006,7 @@ classdef CommunicationInterface < handle
% Example::
% b.outputStop(0,MotorBitfield.MotorA,BrakeMode.Brake)
cmd = Command();
cmd = Packet();
cmd.addHeaderDirect(42,0,0);
cmd.opOUTPUT_STOP(layer,nos,brake)
cmd.addLength();
......@@ -1017,7 +1025,7 @@ classdef CommunicationInterface < handle
% Example::
% b.outputStopAll(0)
cmd = Command();
cmd = Packet();
cmd.addHeaderDirect(42,0,0);
cmd.opOUTPUT_STOP(0,15,BrakeMode.Brake);
cmd.addLength();
......@@ -1038,7 +1046,7 @@ classdef CommunicationInterface < handle
% Example::
% b.outputPower(0,MotorBitfield.MotorA,50)
cmd = Command();
cmd = Packet();
cmd.addHeaderDirect(42,0,0);
cmd.opOUTPUT_POWER(layer,nos,power);
cmd.addLength();
......@@ -1059,7 +1067,7 @@ classdef CommunicationInterface < handle
% Example::
% b.outputSpeed(0,MotorBitfield.MotorA,50)
cmd = Command();
cmd = Packet();
cmd.addHeaderDirect(42,0,0);
cmd.opOUTPUT_SPEED(layer,nos,speed);
cmd.addLength();
......@@ -1079,11 +1087,15 @@ classdef CommunicationInterface < handle
% Example::
% b.outputStart(0,MotorBitfield.MotorA)
cmd = Command();
cmd.addHeaderDirect(42,0,0);
cmd.opOUTPUT_START(layer,nos);
cmd.addLength();
brick.send(cmd);
% cmd = Packet();
% cmd.addHeaderDirect(42,0,0);
% cmd.opOUTPUT_START(layer,nos);
% cmd.addLength();
% brick.send(cmd);
brick.currentData.opOUTPUT_START(layer, nos);
if brick.autoSend
brick.sendStream();
end
end
function state = outputTest(brick,layer,nos)
......@@ -1100,7 +1112,7 @@ classdef CommunicationInterface < handle
% Example::
% state = b.outputTest(0,MotorBitfield.MotorA)
cmd = Command();
cmd = Packet();
cmd.addHeaderDirectReply(42,1,0);
cmd.opOUTPUT_TEST(layer,nos,0);
cmd.addLength();
......@@ -1125,7 +1137,7 @@ classdef CommunicationInterface < handle
% Example::
% b.outputReady(0,MotorBitfield.MotorA)
cmd = Command();
cmd = Packet();
cmd.addHeaderDirectReply(42,0,0);
cmd.opOUTPUT_READY(layer,nos);
cmd.addLength();
......@@ -1151,7 +1163,7 @@ classdef CommunicationInterface < handle
% Example::
% b.outputPolarity(0, MotorBitfield.MotorA, -1);
cmd = Command();
cmd = Packet();
cmd.addHeaderDirect(42,0,0);
cmd.opOUTPUT_POLARITY(layer,nos,pol);
cmd.addLength();
......@@ -1178,7 +1190,7 @@ classdef CommunicationInterface < handle
% Example::
% b.outputStepPower(0,MotorBitfield.MotorA,50,50,360,50,BrakeMode.Coast)
cmd = Command();
cmd = Packet();
cmd.addHeaderDirect(42,0,0);
cmd.opOUTPUT_STEP_POWER(layer,nos,power,step1,step2,step3,brake);
cmd.addLength();
......@@ -1205,7 +1217,7 @@ classdef CommunicationInterface < handle
% Example::
% b.outputTimePower(0,MotorBitfield.MotorA,50,50,360,50,BrakeMode.Coast)
cmd = Command();
cmd = Packet();
cmd.addHeaderDirect(42,0,0);
cmd.opOUTPUT_TIME_POWER(layer,nos,power,step1,step2,step3,brake);
cmd.addLength();
......@@ -1231,7 +1243,7 @@ classdef CommunicationInterface < handle
% Example::
% b.outputStepSpeed(0,MotorBitfield.MotorA,50,50,360,50,BrakeMode.Coast)
cmd = Command();
cmd = Packet();
cmd.addHeaderDirect(42,0,0);
cmd.opOUTPUT_STEP_SPEED(layer,nos,speed,step1,step2,step3,brake);
cmd.addLength();
......@@ -1258,7 +1270,7 @@ classdef CommunicationInterface < handle
% Example::
% b.outputTimeSpeed(0,MotorBitfield.MotorA,50,50,360,50,BrakeMode.Coast)
cmd = Command();
cmd = Packet();
cmd.addHeaderDirect(42,0,0);
cmd.opOUTPUT_TIME_SPEED(layer,nos,speed,step1,step2,step3,brake);
cmd.addLength();
......@@ -1295,7 +1307,7 @@ classdef CommunicationInterface < handle
% Example::
% b.outputStepSync(0,MotorBitfield.MotorA+MotorBitfield.MotorB,50,50,360,BrakeMode.Coast)
cmd = Command();
cmd = Packet();
cmd.addHeaderDirect(42,0,0);
cmd.opOUTPUT_STEP_SYNC(layer,nos,power,turn,step,brake);
cmd.addLength();
......@@ -1331,7 +1343,7 @@ classdef CommunicationInterface < handle
% Example::
% b.outputTimeSync(0,MotorBitfield.MotorA+MotorBitfield.MotorB,50,50,360,BrakeMode.Coast)
cmd = Command();
cmd = Packet();
cmd.addHeaderDirect(42,0,0);
cmd.opOUTPUT_TIME_SYNC(layer,nos,power,turn,time,brake);
cmd.addLength();
......@@ -1351,7 +1363,7 @@ classdef CommunicationInterface < handle
% Example::
% b.outputClrCount(0,MotorBitfield.MotorA)
cmd = Command();
cmd = Packet();
cmd.addHeaderDirect(42,0,0);
cmd.opOUTPUT_CLR_COUNT(layer,nos);
cmd.addLength();
......@@ -1372,7 +1384,7 @@ classdef CommunicationInterface < handle
% Example::
% b.outputReset(0,MotorBitfield.MotorA)
cmd = Command();
cmd = Packet();
cmd.addHeaderDirect(42,0,0);
cmd.opOUTPUT_RESET(layer,nos);
cmd.addLength();
......@@ -1396,7 +1408,7 @@ classdef CommunicationInterface < handle
% tacho = b.outputGetCount(0,MotorPort.MotorA)
cmd = Command();
cmd = Packet();
cmd.addHeaderDirectReply(42,4,0);
cmd.opOUTPUT_GET_COUNT(layer,no,0);
cmd.addLength();
......@@ -1432,7 +1444,7 @@ classdef CommunicationInterface < handle
% Example::
% [speed,tacho] = b.outputRead(0,MotorPort.MotorA)
cmd = Command();
cmd = Packet();
cmd.addHeaderDirectReply(42,5,0);
cmd.opOUTPUT_READ(layer,no,0,4); %%
cmd.addLength();
......@@ -1480,7 +1492,7 @@ classdef CommunicationInterface < handle
% Example::
% state = b.comTest(1, '0');
cmd = Command();
cmd = Packet();
cmd.addHeaderDirectReply(42,1,0);
cmd.opCOM_TEST(hardware,name,0);
cmd.addLength();
......@@ -1506,7 +1518,7 @@ classdef CommunicationInterface < handle
% Example::
% b.comReady(2, '0');
cmd = Command();
cmd = Packet();
cmd.addHeaderDirectReply(42,0,0);
cmd.opCOM_READY(hardware,name);
cmd.addLength();
......@@ -1523,7 +1535,7 @@ classdef CommunicationInterface < handle
% Example::
% name = b.comGetBrickName()
cmd = Command();
cmd = Packet();
cmd.addHeaderDirectReply(42,10,0);
cmd.opCOMGET_GET_BRICKNAME(10,0);
cmd.addLength();
......@@ -1542,7 +1554,7 @@ classdef CommunicationInterface < handle
% Example::
% b.comSetBrickName('EV3')
cmd = Command();
cmd = Packet();
cmd.addHeaderDirect(42,0,0);
cmd.opCOMSET_SET_BRICKNAME(name);
cmd.addLength();
......@@ -1557,7 +1569,7 @@ classdef CommunicationInterface < handle
% Example::
% mac = b.comGetMACAddress()
cmd = Command();
cmd = Packet();
cmd.addHeaderDirectReply(42,36,0);
cmd.opCOMGET_NETWORK(3,36,0,8,20);
cmd.addLength();
......@@ -1576,7 +1588,7 @@ classdef CommunicationInterface < handle
% Example::
% mac = b.comGetBTID()
cmd = Command();
cmd = Packet();
cmd.addHeaderDirectReply(42,12,0);
cmd.opCOMGET_ID(2,12,0);
cmd.addLength();
......@@ -1605,7 +1617,7 @@ classdef CommunicationInterface < handle
% b.mailBoxWrite('T500','abc','numeric',4.24)
% b.mailBoxWrite('T500','abc','text','hello!')
cmd = Command();
cmd = Packet();
cmd.addHeaderDirect(42,0,0);
cmd.opMAILBOX_WRITE(brickname,boxname,type,msg);
cmd.addLength();
......@@ -1632,7 +1644,7 @@ classdef CommunicationInterface < handle
input = fread(fid,inf,'uint8=>uint8');
fclose(fid);
% begin upload
cmd = Command();
cmd = Packet();
cmd.addHeaderSystemReply(10);
cmd.BEGIN_DOWNLOAD(length(input),dest);
cmd.addLength();
......@@ -1670,7 +1682,7 @@ classdef CommunicationInterface < handle
% b.fileDownload('../apps/tst/tst.rbf','prg.rbf',59)
% begin download
cmd = Command();
cmd = Packet();
cmd.addHeaderSystemReply(12);
cmd.BEGIN_UPLOAD(maxlength,dest);
cmd.addLength();
......@@ -1703,7 +1715,7 @@ classdef CommunicationInterface < handle
% Example::
% b.listFiles('/home/root/lms2012/',100)
cmd = Command();
cmd = Packet();
cmd.addHeaderSystemReply(13);
cmd.LIST_FILES(maxlength,pathname);
cmd.addLength();
......@@ -1725,7 +1737,7 @@ classdef CommunicationInterface < handle
% Example::
% b.createDir('/home/root/lms2012/newdir')
cmd = Command();
cmd = Packet();
cmd.addHeaderSystemReply(14);
cmd.CREATE_DIR(pathname);
cmd.addLength();
......@@ -1746,7 +1758,7 @@ classdef CommunicationInterface < handle
% Example::
% b.deleteFile('/home/root/lms2012/newdir')
cmd = Command();
cmd = Packet();
cmd.addHeaderSystemReply(15);
cmd.DELETE_FILE(pathname);
cmd.addLength();
......@@ -1769,7 +1781,7 @@ classdef CommunicationInterface < handle
% Example::
% b.writeMailBox('abc','text','hello!')
cmd = Command();
cmd = Packet();
cmd.addHeaderSystem(16);
cmd.WRITEMAILBOX(title,type,msg);
cmd.addLength();
......@@ -1822,7 +1834,7 @@ classdef CommunicationInterface < handle
% Example::
% b.threeToneByteCode('threetone')
cmd = Command();
cmd = Packet();
% program header
cmd.PROGRAMHeader(0,1,0); % VersionInfo,NumberOfObjects,GlobalBytes
cmd.VMTHREADHeader(0,0); % OffsetToInstructions,LocalBytes
......
This diff is collapsed.
classdef Packet < DataStream
properties
packetType;
counter;
nGlobalVariables;
nLocalVariables;
end
methods
function addHeader(packet, varargin)
packet.msg = [packet.msg typecast(uint16(packet.counter), 'uint8') uint8(packet.packetType)];
if packet.packetType == PacketType.DirectCommandReply || packet.packetType == PacketType.DirectCommandNoReply
packet.addVariables();
end
end
function addLength(packet)
% Command.addLength Add command length
%
% Command.addLength() adds the command message length to the
% start of command object message.
%
% Example::
% cmd.addLength()
cmd.msg = [typecast( uint16(length(packet.msg)), 'uint8') packet.msg];
end
function opOUTPUT_START(packet,layer,nos)
packet.packetType = PacketType.DirectCommandNoReply;
packet.counter = 42;
packet.nGlobalVariables = 0;
packet.nLocalVariables = 0;
opOUTPUT_START@DataStream(packet,layer,nos);
end
end
methods (Access = private)
function addVariables(packet)
packet.msg = [packet.msg typecast( bitor(bitshift(uint16(packet.nLocalVariables),10),uint16(packet.nGlobalVariables)), 'uint8')];
end
end
end
classdef PacketType < uint8
enumeration
DirectCommandReply (0)
DirectCommandNoReply (128)
SystemCommandReply (1)
SystemCommandNoReply (129)
end
end
classdef Program < DataStream
properties
end
methods
function addHeader(packet, varargin)
end
function PROGRAMHeader(cmd,VersionInfo,NumberOfObjects,GlobalBytes)
% Command.PROGRAMHeader add a PROGRAMHeader
%
% Command.PROGRAMHeader(VersionInfo,NumberOfObjects,GlobalBytes)
% adds a PROGRAMHeader to the command object.
%
% Notes::
% - VersionInfo is not used in the current byte implementation
% (hardcoded to 1.04)
% - NumberOfObjects is the number of objects used
% - GlobalBytes is the number of global bytes
% - PROGRAMHEADER is defined as 'L','E','G','O',LONGToBytes(0),WORDToBytes((UWORD)(BYTECODE_VERSION * 100.0)),WORDToBytes(NumberOfObjects),LONGToBytes(GlobalBytes)
%
% Example::
% cmd.PROGRAMHeader(0,1,0)
BYTECODE_VERSION = 1.04;
cmd.msg = [cmd.msg,uint8('L'),uint8('E'),uint8('G'),uint8('O')] ;
cmd.LONGToBytes(0);
cmd.WORDToBytes(BYTECODE_VERSION*100);
cmd.WORDToBytes(NumberOfObjects);
cmd.LONGToBytes(GlobalBytes);
end
function VMTHREADHeader(cmd,OffsetToInstructions,LocalBytes)
% Command.VMTHREADHeader Add a VMTHREADHeader
%
% Command.VMTHREADHeader(OffsetToInstructions,LocalBytes)
% adds a VMTHREADHeader to the command object.
%
% Notes::
% - OffsetToInstructions is the offset to the instructions
% - LocalBytes is the number of local bytes
% - VMTHREADHeader is defined as LONGToBytes(OffsetToInstructions),0,0,0,0,LONGToBytes(LocalBytes)
%
% Example::
% cmd.VMTHREADHeader(0,1)
cmd.LONGToBytes(OffsetToInstructions);
cmd.msg = [cmd.msg uint8(0),uint8(0),uint8(0),uint8(0)];
cmd.LONGToBytes(LocalBytes) ;
end
function SUBCALLHeader(cmd,OffsetToInstructions,LocalBytes)
% Command.SUBCALLHeader Add a SUBCALLHeader
%
% Command.SUBCALLHeader(OffsetToInstructions,LocalBytes)
% adds a SUBCALLHeader to the command object.
%
% Notes::
% - OffsetToInstructions is the offset to the instructions
% - LocalBytes is the number of local bytes
% - SUBCALLHeader is defined as LONGToBytes(OffsetToInstructions),0,0,1,0,LONGToBytes(LocalBytes)
%
% Example::
% cmd.SUBCALLHeader(0,1)
cmd.LONGToBytes(OffsetToInstructions);
cmd.msg = [cmd.msg uint8(0),uint8(0),uint8(1),uint8(0)];
cmd.LONGToBytes(LocalBytes) ;
end
function BLOCKHeader(cmd,OffsetToInstructions,OwnerObjectId,TriggerCount)
% Command.BLOCKHeader
%
% Command.BLOCKHeader(OffsetToInstructions,OwnerObjectId,TriggerCount)
% adds a BLOCKHeader to the command object.
%
% Notes::
% - OffsetToInstructions is the offset to the instructions
% - OwnerObjectId is the owner object id
% - TriggerCount is the trigger count
% - BLOCKHeader is defined as LONGToBytes(OffsetToInstructions),WORDToBytes(OwnerObjectId),WORDToBytes(TriggerCount),LONGToBytes(0)
%
% Example::
% cmd.BLOCKHeader(0,0,0)
cmd.LONGToBytes(OffsetToInstructions);
cmd.WORDToBytes(OwnerObjectId);
cmd.WORDToBytes(TriggerCount)
cmd.LONGToBytes(0);
end
function addLength(cmd)
% Command.addFileSize Add file size
%
% Command.addFileSize() adds the file size to the command
% object.
%
% Notes::
% - With bytecode compiling using "Old header", the file size is
% inserted at byte number 5 which corresponds to the two bytes
% after 'L','E','G','O'
%
% Example::
% cmd.addFileSize
cmd.msg(5:6) = typecast(uint16(length(cmd.msg)),'uint8');
end
function opOBJECT_END(cmd)
% Command.opOBJECT_END Add a opOBJECT_END
%
% Command.opOBJECT_END() adds a opOBJECT_END opcode to the
% command object.
%
% Notes::
% - opOBJECT_END
%
% Example::
% cmd.opOBJECT_END()
cmd.addDirectCommand(ByteCodes.ObjectEnd);
end
function opNOP(cmd)
% Command.opNOP Add a opNOP
%
% Command.opNOP() adds a opNOP opcode to the command object.
%
% Example::
% cmd.opNOP()
cmd.addDirectCommand(ByteCodes.Nop);
end
function opJR(cmd,offset)
% Command.opJR Add a opJR
%
% Command.opJR(offset) adds a opJR opcode to the command
% object.
%
% Notes::
% - offset is the number of command to jump where the sign
% indicates the jump direction
% - opJR,LC0(offset)
%
% Example::
% cmd.opJR(-10)
cmd.addDirectCommand(ByteCodes.Jr);
cmd.LC0(offset);
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment