Reputation: 28
I am trying to implement a TraCi command for mysumo scenario (traci.lane.setDisallowed) while using veins. I created a new command in the TraciCommandInterface.cpp like:
void TraCICommandInterface::Lane::setDisallowed(std::list<std::string> disallowedClasses)
{
TraCIBuffer buf = connection->query(CMD_SET_LANE_VARIABLE, TraCIBuffer() << LANE_DISALLOWED << laneId << TYPE_STRINGLIST << disallowedClasses);
ASSERT(buf.eof());
}
and called like:
std::list<std::string> disallowedClasses = {"all"};
if (simTime()==20) {
TraCICommandInterface* cInt = getCommandInterface();
cInt->lane("ed_1_0").setDisallowed(disallowedClasses);
}
The problem is that i get the error: Answered with error to command 0xc3: Wrong position in requestMessage after dispatching command 195. Expected command length was 38 but 18 Bytes were read.
Is there something wrong with the way i implemented the command? Any suggestions why this problems occurs?
Upvotes: 0
Views: 151
Reputation: 6943
As of Veins 5.0, TraCIBuffer
only has a few overloads for C++ data types, notably for std::string
, simtime_t
, and TraCICoord
(see here). All other types are sent as stored in memory (by casting to char*
) (see here) - certainly not a good idea for std::list
.
For copy/paste-able code for how to serialize a std::list<std::string>
to a binary blob representing the TYPE_STRINGLIST
SUMO/TraCI expects, see the code of TraCICommandInterface::Vehicle::changeVehicleRoute(const std::list<std::string>& edges)
, available here.
Upvotes: 1