Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[sumo-dev] Issue with `traci4matlab\+traci\sendExact.m`

Hi,
I am a undergrad student and i am trying to use SUMO for a simulation script on matlab. This script invokes sumo.exe and sends some data to simulate an environment with mobile vehicles to study some networking algorithms for V2X communication.

While trying to invoke SUMO for the same i am hitting the following issue:
 
Dot indexing is not supported for variables of this type.
Error in traci.sendExact (line 19)
activeConnection.dos.writeInt(len);

The variable in question here is the "connection" variable in the following script `\SUMO\tools\contributed\traci4matlab\+traci\sendExact.m` .

function result = sendExact()
%sendExact An internal function to send a message to the SUMO server and
%parse the result.
% Copyright 2019 Universidad Nacional de Colombia,
% Politecnico Jaime Isaza Cadavid.
% Authors: Andres Acosta, Jairo Espinosa, Jorge Espinosa.
% $Id: sendExact.m 48 2018-12-26 15:35:20Z afacostag $
global message connections
import traci.constants
% warning('off','instrument:fread:unsuccessfulRead');
% Length of the command
len = 4 + length(message.string);
activeConnection = connections('');
% Write the message to the tcp socket
activeConnection.dos.writeInt(len);
activeConnection.dos.write(message.string);
% Read the result from the socket
result = traci.recvExact();
if isempty(result)
fclose(connections(''));
clear connections('')
throw(MException('traci:FatalTraciError','Connection closed by SUMO\n'))
end
% Parse the result
for i= 1:length(message.queue)
prefix = result.read(3);
if prefix(3)==0
strresult = 'OK';
elseif prefix(3)==1
strresult = 'Not Implemented';
else
strresult = 'Error';
end
err = result.readString();
if prefix(3) || ~isempty(err)
message.string = [];
message.queue = [];
traci.close();
throw(MException('traci:FatalTraciError','%s %s %s\n', num2str(prefix), strresult, err));
elseif prefix(2) ~= message.queue(i)
traci.close();
throw(MException('traci:FatalTraciError','Received answer 0x%.2X for command 0x%.2x.\n',...
prefix(2), message.queue(i)));
elseif strcmp(prefix(2),constants.CMD_STOP)
len = result.read(1) - 1;
result.read(len + 1);
end
end
% Clear the message contents
message.string = [];
message.queue = [];
In the above code the "connections" variable is defined as a global variable and later it is used as a function and the output is stored in the variable "activeConnections". This seemingly is faulty in nature.

It would be really helpful if someone could help me navigate through this issue.

Regards

--

Back to the top